diff --git a/src/Endpoint/BatchSendingItemsEndpoint.php b/src/Endpoint/BatchSendingItemsEndpoint.php index af296ec..39a0f9d 100644 --- a/src/Endpoint/BatchSendingItemsEndpoint.php +++ b/src/Endpoint/BatchSendingItemsEndpoint.php @@ -4,20 +4,26 @@ namespace DigitalCz\DigiSign\Endpoint; -use DigitalCz\DigiSign\Endpoint\Traits\CRUDEndpointTrait; +use DigitalCz\DigiSign\Endpoint\Traits\DeleteEndpointTrait; +use DigitalCz\DigiSign\Endpoint\Traits\GetEndpointTrait; +use DigitalCz\DigiSign\Endpoint\Traits\ListEndpointTrait; +use DigitalCz\DigiSign\Endpoint\Traits\UpdateEndpointTrait; use DigitalCz\DigiSign\Resource\BatchSending; use DigitalCz\DigiSign\Resource\BatchSendingItem; /** * @extends ResourceEndpoint * @method BatchSendingItem get(string $id) - * @method BatchSendingItem create(array $body) * @method BatchSendingItem update(string $id, array $body) + * @method BatchSendingItem delete(string $id) */ final class BatchSendingItemsEndpoint extends ResourceEndpoint { - /** @use CRUDEndpointTrait */ - use CRUDEndpointTrait; + /** @use ListEndpointTrait */ + use ListEndpointTrait; + use GetEndpointTrait; + use UpdateEndpointTrait; + use DeleteEndpointTrait; public function __construct(BatchSendingsEndpoint $parent, BatchSending|string $batchSending) { @@ -36,4 +42,12 @@ public function import(array $body): void { $this->postRequest('/import', ['json' => $body]); } + + /** + * @param mixed[] $body + */ + public function create(array $body): BatchSendingItem + { + return $this->makeResource($this->putRequest('', ['json' => $body])); + } } diff --git a/src/Resource/BatchSendingItem.php b/src/Resource/BatchSendingItem.php index 39a64a5..8335a69 100644 --- a/src/Resource/BatchSendingItem.php +++ b/src/Resource/BatchSendingItem.php @@ -26,6 +26,6 @@ class BatchSendingItem extends BaseResource /** @var array */ public array $recipients; - /** @var array|null */ - public ?array $violations; + /** @var array */ + public array $violations; } diff --git a/tests/Endpoint/BatchSendingItemsEndpointTest.php b/tests/Endpoint/BatchSendingItemsEndpointTest.php index af4ac58..aee0582 100644 --- a/tests/Endpoint/BatchSendingItemsEndpointTest.php +++ b/tests/Endpoint/BatchSendingItemsEndpointTest.php @@ -15,9 +15,34 @@ public function testImport(): void self::assertLastRequest('POST', "/api/batch-sendings/bar/items/import", ['file' => 'bar']); } - public function testCRUD(): void + public function testList(): void { - self::assertCrudRequests(self::endpoint(), '/api/batch-sendings/bar/items'); + self::endpoint()->list(['foo' => 'bar']); + self::assertLastRequest('GET', '/api/batch-sendings/bar/items?foo=bar'); + } + + public function testGet(): void + { + self::endpoint()->get('foo'); + self::assertLastRequest('GET', '/api/batch-sendings/bar/items/foo'); + } + + public function testCreate(): void + { + self::endpoint()->create(['foo' => 'bar']); + self::assertLastRequest('PUT', '/api/batch-sendings/bar/items', ['foo' => 'bar']); + } + + public function testUpdate(): void + { + self::endpoint()->update('foo', ['foo' => 'bar']); + self::assertLastRequest('PUT', '/api/batch-sendings/bar/items/foo', ['foo' => 'bar']); + } + + public function testDelete(): void + { + self::endpoint()->delete('foo'); + self::assertLastRequest('DELETE', '/api/batch-sendings/bar/items/foo'); } protected static function endpoint(): BatchSendingItemsEndpoint