diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bec0ca..0827cce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip - Add `IdentifyScenarioVersion.restrictedCountries` - Add `EnvelopeTemplateDocumentAssignments` endpoint - Add `Envelope.createdBy` and `Envelope.sentBy` -- Add `BatchSendings` and `BatchSendingsItems` endpoints +- Add `BatchSendings` and `BatchSendingsItems` endpoints and resources - Add `AccountSecurity.localSignature` to resource ## [2.4.0] - 2024-05-14 diff --git a/src/Endpoint/BatchSendingItemsEndpoint.php b/src/Endpoint/BatchSendingItemsEndpoint.php new file mode 100644 index 0000000..c8567e8 --- /dev/null +++ b/src/Endpoint/BatchSendingItemsEndpoint.php @@ -0,0 +1,34 @@ + + * @method BatchSendingItem get(string $id) + * @method BatchSendingItem create(array $body) + * @method BatchSendingItem update(string $id, array $body) + */ +final class BatchSendingItemsEndpoint extends ResourceEndpoint +{ + /** @use CRUDEndpointTrait */ + use CRUDEndpointTrait; + + public function __construct(BatchSendingsEndpoint $parent, BatchSending|string $batchSending) + { + parent::__construct($parent, '/{id}/items', BatchSendingItem::class, ['id' => $batchSending]); + } + + /** + * @param mixed[] $body + */ + public function import(array $body): void + { + $this->postRequest('/import', ['json' => $body]); + } +} diff --git a/src/Endpoint/BatchSendingsEndpoint.php b/src/Endpoint/BatchSendingsEndpoint.php index f325b4d..4606161 100644 --- a/src/Endpoint/BatchSendingsEndpoint.php +++ b/src/Endpoint/BatchSendingsEndpoint.php @@ -27,8 +27,8 @@ public function __construct(DigiSign $parent) parent::__construct($parent, '/api/batch-sendings'); } - public function items(string $id): BatchSendingsItemsEndpoint + public function items(BatchSending|string $id): BatchSendingItemsEndpoint { - return new BatchSendingsItemsEndpoint($this, $id); + return new BatchSendingItemsEndpoint($this, $id); } } diff --git a/src/Endpoint/BatchSendingsItemsEndpoint.php b/src/Endpoint/BatchSendingsItemsEndpoint.php deleted file mode 100644 index f55b7c0..0000000 --- a/src/Endpoint/BatchSendingsItemsEndpoint.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -final class BatchSendingsItemsEndpoint extends ResourceEndpoint -{ - public function __construct(BatchSendingsEndpoint $parent, string $batchSending) - { - parent::__construct($parent, '/{id}/items', BaseResource::class, ['id' => $batchSending]); - } - - /** - * @param mixed[] $body - */ - public function import(array $body): void - { - $this->postRequest('/import', ['json' => $body]); - } -} diff --git a/src/Resource/BatchSending.php b/src/Resource/BatchSending.php index 1f8d9a9..4105e3c 100644 --- a/src/Resource/BatchSending.php +++ b/src/Resource/BatchSending.php @@ -10,8 +10,6 @@ class BatchSending extends BaseResource { use EntityResourceTrait; - public string $id; - public ?string $name; public ?string $envelopeTemplateId; diff --git a/src/Resource/BatchSendingItem.php b/src/Resource/BatchSendingItem.php new file mode 100644 index 0000000..39a64a5 --- /dev/null +++ b/src/Resource/BatchSendingItem.php @@ -0,0 +1,31 @@ + */ + public array $recipients; + + /** @var array|null */ + public ?array $violations; +} diff --git a/src/Resource/BatchSendingItemRecipientRaw.php b/src/Resource/BatchSendingItemRecipientRaw.php new file mode 100644 index 0000000..ef5eec9 --- /dev/null +++ b/src/Resource/BatchSendingItemRecipientRaw.php @@ -0,0 +1,30 @@ + 'bar']); } - protected static function endpoint(): BatchSendingsItemsEndpoint + public function testCRUD(): void + { + self::assertCrudRequests(self::endpoint(), '/api/batch-sendings/foo/items'); + } + + protected static function endpoint(): BatchSendingItemsEndpoint { return self::dgs()->batchSendings()->items('foo'); }