Skip to content

Commit

Permalink
Add MyEnvelopeRecipients.embed endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasDostalDS committed May 15, 2024
1 parent 1f83b2c commit 28e68f1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [Unreleased]
- Add `MyEnvelopeRecipients.embed` endpoint
- Add `MyIdentifications.info` endpoint
- Add `EnvelopeRecipient.certificateInfo` endpoint

Expand Down
27 changes: 27 additions & 0 deletions src/Endpoint/MyEnvelopeRecipientsEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Endpoint;

use DigitalCz\DigiSign\Resource\BaseResource;
use DigitalCz\DigiSign\Resource\Envelope;

/**
* @extends ResourceEndpoint<BaseResource>
*/
final class MyEnvelopeRecipientsEndpoint extends ResourceEndpoint
{
public function __construct(MyEnvelopesEndpoint $parent, string|Envelope $envelope)
{
parent::__construct($parent, '{envelope}/recipients', resourceOptions: ['envelope' => $envelope]);
}

/**
* @param mixed[] $body
*/
public function embed(string $recipient, array $body): void
{
$this->postRequest('/{recipient}/embed', ['recipient' => $recipient, 'json' => $body]);
}
}
6 changes: 6 additions & 0 deletions src/Endpoint/MyEnvelopesEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DigitalCz\DigiSign\Endpoint\Traits\GetEndpointTrait;
use DigitalCz\DigiSign\Endpoint\Traits\ListEndpointTrait;
use DigitalCz\DigiSign\Resource\Envelope;
use DigitalCz\DigiSign\Resource\ListResource;
use DigitalCz\DigiSign\Resource\MyEnvelope;
use DigitalCz\DigiSign\Resource\MyEnvelopeInfo;
Expand Down Expand Up @@ -46,4 +47,9 @@ public function info(string $id): MyEnvelopeInfo
{
return $this->createResource($this->getRequest('/{id}/info', ['id' => $id]), MyEnvelopeInfo::class);
}

public function recipients(string|Envelope $envelope): MyEnvelopeRecipientsEndpoint
{
return new MyEnvelopeRecipientsEndpoint($this, $envelope);
}
}
22 changes: 22 additions & 0 deletions tests/Endpoint/MyEnvelopeRecipientsEndpointTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace DigitalCz\DigiSign\Endpoint;

/**
* @covers \DigitalCz\DigiSign\Endpoint\MyEnvelopeRecipientsEndpoint
*/
class MyEnvelopeRecipientsEndpointTest extends EndpointTestCase
{
public function testEmbed(): void
{
self::endpoint()->embed('bar', []);
self::assertLastRequest('POST', '/api/my/envelopes/foo/recipients/bar/embed');
}

protected static function endpoint(): MyEnvelopeRecipientsEndpoint
{
return self::dgs()->my()->envelopes()->recipients('foo');
}
}

0 comments on commit 28e68f1

Please sign in to comment.