Skip to content

Commit

Permalink
Merge pull request #266 from IamDejv/fix-batch-sending-item-endpoints
Browse files Browse the repository at this point in the history
Fix BatchSendingItem Endpoints
  • Loading branch information
IamDejv authored Sep 19, 2024
2 parents a340dc8 + b86592d commit 106cad9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DigiSignClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private function createUri(string $uri, array $options): UriInterface
{
// replace uri parameters with its values
preg_match_all('/{(\w+)}/', $uri, $matches);
$searches = $matches[1] ?? [];
$searches = $matches[1];
$replaces = [];

foreach ($searches as $search) {
Expand Down
7 changes: 6 additions & 1 deletion src/Endpoint/BatchSendingItemsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ final class BatchSendingItemsEndpoint extends ResourceEndpoint

public function __construct(BatchSendingsEndpoint $parent, BatchSending|string $batchSending)
{
parent::__construct($parent, '/{id}/items', BatchSendingItem::class, ['id' => $batchSending]);
parent::__construct(
$parent,
'/{batchSending}/items',
BatchSendingItem::class,
['batchSending' => $batchSending],
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Endpoint/BatchSendingItemsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class BatchSendingItemsEndpointTest extends EndpointTestCase
public function testImport(): void
{
self::endpoint()->import(['file' => 'bar']);
self::assertLastRequest('POST', "/api/batch-sendings/foo/items/import", ['file' => 'bar']);
self::assertLastRequest('POST', "/api/batch-sendings/bar/items/import", ['file' => 'bar']);
}

public function testCRUD(): void
{
self::assertCrudRequests(self::endpoint(), '/api/batch-sendings/foo/items');
self::assertCrudRequests(self::endpoint(), '/api/batch-sendings/bar/items');
}

protected static function endpoint(): BatchSendingItemsEndpoint
{
return self::dgs()->batchSendings()->items('foo');
return self::dgs()->batchSendings()->items('bar');
}
}

0 comments on commit 106cad9

Please sign in to comment.