From 51ffb27665d7f7fd0c0b7c874fd3300f96bfa108 Mon Sep 17 00:00:00 2001 From: David Kalianko Date: Tue, 17 Sep 2024 15:37:30 +0200 Subject: [PATCH 1/2] Add `BatchSendingItems` endpoints and resources --- src/Endpoint/BatchSendingItemsEndpoint.php | 34 +++++++++++++++++++ src/Endpoint/BatchSendingsEndpoint.php | 4 +-- src/Endpoint/BatchSendingsItemsEndpoint.php | 26 -------------- src/Resource/BatchSending.php | 2 -- src/Resource/BatchSendingItem.php | 33 ++++++++++++++++++ src/Resource/BatchSendingItemRecipientRaw.php | 30 ++++++++++++++++ .../BatchSendingItemsEndpointTest.php | 9 +++-- 7 files changed, 106 insertions(+), 32 deletions(-) create mode 100644 src/Endpoint/BatchSendingItemsEndpoint.php delete mode 100644 src/Endpoint/BatchSendingsItemsEndpoint.php create mode 100644 src/Resource/BatchSendingItem.php create mode 100644 src/Resource/BatchSendingItemRecipientRaw.php 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..25c52ff --- /dev/null +++ b/src/Resource/BatchSendingItem.php @@ -0,0 +1,33 @@ + */ + public array $recipientsRawData; + + /** @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'); } From 2821479a21192ea29d4dc6b58fcae815159e6146 Mon Sep 17 00:00:00 2001 From: David Kalianko Date: Wed, 18 Sep 2024 10:23:20 +0200 Subject: [PATCH 2/2] Fix Fix `BatchSendingItem` Resource Edit Changelog Update BatchSendingItem Resource --- CHANGELOG.md | 2 +- src/Resource/BatchSendingItem.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) 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/Resource/BatchSendingItem.php b/src/Resource/BatchSendingItem.php index 25c52ff..39a64a5 100644 --- a/src/Resource/BatchSendingItem.php +++ b/src/Resource/BatchSendingItem.php @@ -13,9 +13,7 @@ class BatchSendingItem extends BaseResource public string $name; - public int $itemNumber; - - public ?string $envelope; + public ?string $envelopeId; public string $status; @@ -26,7 +24,7 @@ class BatchSendingItem extends BaseResource public ?string $failedMessage; /** @var array */ - public array $recipientsRawData; + public array $recipients; /** @var array|null */ public ?array $violations;