Skip to content
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
->in(__DIR__ . '/src/Services/Sale/')
->in(__DIR__ . '/src/Services/Task/')
->in(__DIR__ . '/src/Services/Sale/')
->in(__DIR__ . '/src/Services/Disk/')
->in(__DIR__ . '/src/Services/Calendar/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,50 @@

### Added

- Added service `Services\Disk\Service\Disk` with support methods,
see [disk service methods](https://github.com/bitrix24/b24phpsdk/issues/265):
- `getVersion` returns the version by identifier
- `getAttachedObject` returns information about the attached file
- `getRightsTasks` returns a list of available access levels that can be used for assigning permissions
- Added service `Services\Disk\Storage\Service\Storage` with support methods,
see [disk.storage.* methods](https://github.com/bitrix24/b24phpsdk/issues/265):
- `fields` returns the description of the storage fields
- `get` returns the storage by identifier
- `rename` renames the storage
- `list` returns a list of available storages
- `getTypes` returns a list of storage types
- `addFolder` creates a folder in the root of the storage
- `getChildren` returns a list of files and folders in the root of the storage
- `uploadFile` uploads a new file to the root of the storage
- `getForApp` returns the description of the storage that the application can work with
- Added service `Services\Disk\Folder\Service\Folder` with support methods,
see [disk.folder.* methods](https://github.com/bitrix24/b24phpsdk/issues/265):
- `getFields` returns the description of folder fields
- `get` returns the folder by identifier
- `getChildren` returns a list of files and folders that are directly in the folder
- `addSubfolder` creates a subfolder
- `copyTo` copies the folder to the specified folder
- `moveTo` moves the folder to the specified folder
- `rename` renames the folder
- `markDeleted` moves the folder to the trash
- `restore` restores the folder from the trash
- `deleteTree` permanently destroys the folder and all its child elements
- `getExternalLink` returns a public link
- `uploadFile` uploads a new file to the specified folder
- Added service `Services\Disk\File\Service\File` with support methods,
see [disk.file.* methods](https://github.com/bitrix24/b24phpsdk/issues/265):
- `getFields` returns the description of file fields
- `get` returns the file by identifier
- `rename` renames the file
- `copyTo` copies the file to the specified folder
- `moveTo` moves the file to the specified folder
- `delete` permanently destroys the file
- `markDeleted` moves the file to the trash
- `restore` restores the file from the trash
- `uploadVersion` uploads a new version of the file
- `getVersions` returns a list of file versions
- `restoreFromVersion` restores the file from a specific version
- `getExternalLink` returns a public link to the file
- Added service `Services\CRM\Documentgenerator\Numerator` with support methods,
see [crm.documentgenerator.numerator.* methods](https://github.com/bitrix24/b24phpsdk/issues/215):
- `add` adds a new numerator, with batch calls support
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ test-integration-scope-log:
test-integration-scope-sale:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_sale

.PHONY: test-integration-scope-disk
test-integration-scope-disk:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_disk

.PHONY: test-integration-disk-service
test-integration-disk-service:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_disk_service

.PHONY: test-integration-disk-file
test-integration-disk-file:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_disk_file

.PHONY: test-integration-disk-storage
test-integration-disk-storage:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_disk_storage
.PHONY: test-integration-scope-calendar
test-integration-scope-calendar:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_calendar
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ parameters:
- tests/Integration/Services/CRM/Requisites
- tests/Integration/Services/Task
- tests/Integration/Services/Sale
- tests/Integration/Services/Disk
- tests/Integration/Services/Calendar
- tests/Integration/Services/CRM/Documentgenerator/Numerator
excludePaths:
Expand Down
12 changes: 12 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@
<testsuite name="integration_tests_scope_sale">
<directory>./tests/Integration/Services/Sale/</directory>
</testsuite>
<testsuite name="integration_tests_scope_disk">
<directory>./tests/Integration/Services/Disk/</directory>
</testsuite>
<testsuite name="integration_tests_disk_service">
<directory>./tests/Integration/Services/Disk/Service/</directory>
</testsuite>
<testsuite name="integration_tests_disk_file">
<directory>./tests/Integration/Services/Disk/File/</directory>
</testsuite>
<testsuite name="integration_tests_disk_storage">
<directory>./tests/Integration/Services/Disk/Storage/</directory>
</testsuite>
<testsuite name="integration_tests_task">
<directory>./tests/Integration/Services/Task/</directory>
</testsuite>
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
__DIR__ . '/tests/Integration/Services/Task',
__DIR__ . '/src/Services/Sale',
__DIR__ . '/tests/Integration/Services/Sale',
__DIR__ . '/src/Services/Disk',
__DIR__ . '/tests/Integration/Services/Disk',
__DIR__ . '/src/Services/Calendar',
__DIR__ . '/tests/Integration/Services/Calendar',
__DIR__ . '/src/Services/CRM/Documentgenerator/Numerator',
Expand Down
87 changes: 87 additions & 0 deletions src/Services/Disk/DiskServiceBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[email protected]>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Disk;

use Bitrix24\SDK\Attributes\ApiServiceBuilderMetadata;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Services\AbstractServiceBuilder;

/**
* Class DiskServiceBuilder
*
* @package Bitrix24\SDK\Services\Disk
*/
#[ApiServiceBuilderMetadata(new Scope(['disk']))]
class DiskServiceBuilder extends AbstractServiceBuilder
{
/**
* Get Folder service
*/
public function folder(): Folder\Service\Folder
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Folder\Service\Folder(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

/**
* Get File service
*/
public function file(): File\Service\File
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new File\Service\File(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

/**
* Get Storage service
*/
public function storage(): Storage\Service\Storage
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Storage\Service\Storage(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

/**
* Get Disk service
*/
public function disk(): Service\Disk
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Service\Disk(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}
}
44 changes: 44 additions & 0 deletions src/Services/Disk/File/Result/FileCopiedResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[email protected]>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Disk\File\Result;

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* File copied result
*/
class FileCopiedResult extends AbstractResult
{
/**
* Get copied file
*
* @throws BaseException
*/
public function file(): FileItemResult
{
return new FileItemResult($this->getCoreResponse()->getResponseData()->getResult());
}

/**
* Check if copy operation was successful
*
* @throws BaseException
*/
public function isSuccess(): bool
{
$result = $this->getCoreResponse()->getResponseData()->getResult();
return $result !== [] && isset($result['ID']);
}
}
33 changes: 33 additions & 0 deletions src/Services/Disk/File/Result/FileDeletedResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[email protected]>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Disk\File\Result;

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* File deleted result
*/
class FileDeletedResult extends AbstractResult
{
/**
* Check if delete operation was successful
*
* @throws BaseException
*/
public function isSuccess(): bool
{
return (bool)$this->getCoreResponse()->getResponseData()->getResult();
}
}
33 changes: 33 additions & 0 deletions src/Services/Disk/File/Result/FileExternalLinkResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[email protected]>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Disk\File\Result;

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* File external link result
*/
class FileExternalLinkResult extends AbstractResult
{
/**
* Get external link URL
*
* @throws BaseException
*/
public function getExternalLink(): string
{
return (string)$this->getCoreResponse()->getResponseData()->getResult()[0];
}
}
41 changes: 41 additions & 0 deletions src/Services/Disk/File/Result/FileItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[email protected]>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Disk\File\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;
use Carbon\CarbonImmutable;

/**
* File item result
*
* @property-read int $ID File identifier
* @property-read string $NAME File name
* @property-read string $TYPE File type (always "file")
* @property-read string|null $CODE Symbolic code
* @property-read int|null $STORAGE_ID Storage identifier
* @property-read int|null $PARENT_ID Parent folder identifier
* @property-read CarbonImmutable|null $CREATE_TIME Creation time in ISO format
* @property-read CarbonImmutable|null $UPDATE_TIME Modification time in ISO format
* @property-read CarbonImmutable|null $DELETE_TIME Time moved to trash in ISO format
* @property-read int $CREATED_BY User ID who created the file
* @property-read int $UPDATED_BY User ID who modified the file
* @property-read int $DELETED_BY User ID who moved the file to trash
* @property-read int $GLOBAL_CONTENT_VERSION
* @property-read int $FILE_ID
* @property-read int $SIZE
* @property-read int|null $DELETED_TYPE Deletion marker
*/
class FileItemResult extends AbstractItem
{
}
Loading