|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of the bitrix24-php-sdk package. |
| 5 | + * |
| 6 | + * © Sally Fancen <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the MIT-LICENSE.txt |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace Bitrix24\SDK\Services\Disk\Service; |
| 15 | + |
| 16 | +use Bitrix24\SDK\Attributes\ApiEndpointMetadata; |
| 17 | +use Bitrix24\SDK\Attributes\ApiServiceMetadata; |
| 18 | +use Bitrix24\SDK\Core\Contracts\CoreInterface; |
| 19 | +use Bitrix24\SDK\Core\Credentials\Scope; |
| 20 | +use Bitrix24\SDK\Core\Exceptions\BaseException; |
| 21 | +use Bitrix24\SDK\Core\Exceptions\TransportException; |
| 22 | +use Bitrix24\SDK\Services\AbstractService; |
| 23 | +use Bitrix24\SDK\Services\Disk\Result\VersionItemResult; |
| 24 | +use Bitrix24\SDK\Services\Disk\Result\AttachedObjectItemResult; |
| 25 | +use Bitrix24\SDK\Services\Disk\Result\RightsResult; |
| 26 | +use Psr\Log\LoggerInterface; |
| 27 | + |
| 28 | +#[ApiServiceMetadata(new Scope(['disk']))] |
| 29 | +class Disk extends AbstractService |
| 30 | +{ |
| 31 | + public function __construct(CoreInterface $core, LoggerInterface $logger) |
| 32 | + { |
| 33 | + parent::__construct($core, $logger); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Returns the version by identifier. |
| 38 | + * |
| 39 | + * @link https://apidocs.bitrix24.com/api-reference/disk/version/disk-version-get.html |
| 40 | + * |
| 41 | + * @param int $id Version identifier |
| 42 | + * |
| 43 | + * @throws BaseException |
| 44 | + * @throws TransportException |
| 45 | + */ |
| 46 | + #[ApiEndpointMetadata( |
| 47 | + 'disk.version.get', |
| 48 | + 'https://apidocs.bitrix24.com/api-reference/disk/version/disk-version-get.html', |
| 49 | + 'Returns the version by identifier.' |
| 50 | + )] |
| 51 | + public function getVersion(int $id): VersionItemResult |
| 52 | + { |
| 53 | + return new VersionItemResult( |
| 54 | + $this->core->call( |
| 55 | + 'disk.version.get', |
| 56 | + ['id' => $id] |
| 57 | + )->getResponseData()->getResult() |
| 58 | + ); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns information about the attached file. |
| 63 | + * |
| 64 | + * @link https://apidocs.bitrix24.com/api-reference/disk/attached-object/disk-attached-object-get.html |
| 65 | + * |
| 66 | + * @param int $id Attachment binding identifier |
| 67 | + * |
| 68 | + * @throws BaseException |
| 69 | + * @throws TransportException |
| 70 | + */ |
| 71 | + #[ApiEndpointMetadata( |
| 72 | + 'disk.attachedObject.get', |
| 73 | + 'https://apidocs.bitrix24.com/api-reference/disk/attached-object/disk-attached-object-get.html', |
| 74 | + 'Returns information about the attached file.' |
| 75 | + )] |
| 76 | + public function getAttachedObject(int $id): AttachedObjectItemResult |
| 77 | + { |
| 78 | + return new AttachedObjectItemResult( |
| 79 | + $this->core->call( |
| 80 | + 'disk.attachedObject.get', |
| 81 | + ['id' => $id] |
| 82 | + )->getResponseData()->getResult() |
| 83 | + ); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Returns a list of available access levels that can be used for assigning permissions. |
| 88 | + * |
| 89 | + * @link https://apidocs.bitrix24.com/api-reference/disk/rights/disk-rights-get-tasks.html |
| 90 | + * |
| 91 | + * @param int|null $start The ordinal number of the list item from which to return the next items |
| 92 | + * |
| 93 | + * @throws BaseException |
| 94 | + * @throws TransportException |
| 95 | + */ |
| 96 | + #[ApiEndpointMetadata( |
| 97 | + 'disk.rights.getTasks', |
| 98 | + 'https://apidocs.bitrix24.com/api-reference/disk/rights/disk-rights-get-tasks.html', |
| 99 | + 'Returns a list of available access levels that can be used for assigning permissions.' |
| 100 | + )] |
| 101 | + public function getRightsTasks(?int $start = null): RightsResult |
| 102 | + { |
| 103 | + $params = []; |
| 104 | + if ($start !== null) { |
| 105 | + $params['start'] = $start; |
| 106 | + } |
| 107 | + |
| 108 | + return new RightsResult( |
| 109 | + $this->core->call( |
| 110 | + 'disk.rights.getTasks', |
| 111 | + $params |
| 112 | + ) |
| 113 | + ); |
| 114 | + } |
| 115 | +} |
0 commit comments