Skip to content

Commit

Permalink
Merge pull request #265 from IamDejv/add-batch-sending-items
Browse files Browse the repository at this point in the history
Add batch sending items
  • Loading branch information
IamDejv authored Sep 18, 2024
2 parents 3e39dce + 2821479 commit a340dc8
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions src/Endpoint/BatchSendingItemsEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Endpoint;

use DigitalCz\DigiSign\Endpoint\Traits\CRUDEndpointTrait;
use DigitalCz\DigiSign\Resource\BatchSending;
use DigitalCz\DigiSign\Resource\BatchSendingItem;

/**
* @extends ResourceEndpoint<BatchSendingItem>
* @method BatchSendingItem get(string $id)
* @method BatchSendingItem create(array $body)
* @method BatchSendingItem update(string $id, array $body)
*/
final class BatchSendingItemsEndpoint extends ResourceEndpoint
{
/** @use CRUDEndpointTrait<BatchSendingItem> */
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]);
}
}
4 changes: 2 additions & 2 deletions src/Endpoint/BatchSendingsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
26 changes: 0 additions & 26 deletions src/Endpoint/BatchSendingsItemsEndpoint.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Resource/BatchSending.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class BatchSending extends BaseResource
{
use EntityResourceTrait;

public string $id;

public ?string $name;

public ?string $envelopeTemplateId;
Expand Down
31 changes: 31 additions & 0 deletions src/Resource/BatchSendingItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

use DateTime;
use DigitalCz\DigiSign\Resource\Traits\EntityResourceTrait;

class BatchSendingItem extends BaseResource
{
use EntityResourceTrait;

public string $name;

public ?string $envelopeId;

public string $status;

public ?DateTime $sentAt;

public ?DateTime $failedAt;

public ?string $failedMessage;

/** @var array<BatchSendingItemRecipientRaw> */
public array $recipients;

/** @var array<Violation>|null */
public ?array $violations;
}
30 changes: 30 additions & 0 deletions src/Resource/BatchSendingItemRecipientRaw.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Resource;

class BatchSendingItemRecipientRaw extends BaseResource
{
public string $alias;

public string $name;

public string $email;

public ?string $mobile;

public ?string $company;

public ?string $function;

public ?string $contractingParty;

public ?string $birthdate;

public ?string $birthnumber;

public ?string $identificationNumber;

public ?string $address;
}
9 changes: 7 additions & 2 deletions tests/Endpoint/BatchSendingItemsEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace DigitalCz\DigiSign\Endpoint;

/**
* @covers \DigitalCz\DigiSign\Endpoint\BatchSendingsItemsEndpoint
* @covers \DigitalCz\DigiSign\Endpoint\BatchSendingItemsEndpoint
*/
class BatchSendingItemsEndpointTest extends EndpointTestCase
{
Expand All @@ -15,7 +15,12 @@ public function testImport(): void
self::assertLastRequest('POST', "/api/batch-sendings/foo/items/import", ['file' => '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');
}
Expand Down

0 comments on commit a340dc8

Please sign in to comment.