|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace DigitalCz\DigiSign\Endpoint; |
|
6
|
|
|
|
|
7
|
|
|
use DigitalCz\DigiSign\Endpoint\Traits\CRUDEndpointTrait; |
|
8
|
|
|
use DigitalCz\DigiSign\Resource\Collection; |
|
9
|
|
|
use DigitalCz\DigiSign\Resource\Envelope; |
|
10
|
|
|
use DigitalCz\DigiSign\Resource\EnvelopeRecipient; |
|
11
|
|
|
use DigitalCz\DigiSign\Resource\EnvelopeRecipientAttachment; |
|
12
|
|
|
use DigitalCz\DigiSign\Resource\EnvelopeTag; |
|
13
|
|
|
use DigitalCz\DigiSign\Resource\ListResource; |
|
14
|
|
|
use DigitalCz\DigiSign\Resource\ResourceInterface; |
|
15
|
|
|
use DigitalCz\DigiSign\Resource\VerifiedClaims; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @extends ResourceEndpoint<EnvelopeRecipient> |
|
19
|
|
|
* @method EnvelopeRecipient get(string $id) |
|
20
|
|
|
* @method EnvelopeRecipient create(array $body) |
|
21
|
|
|
* @method EnvelopeRecipient update(string $id, array $body) |
|
22
|
|
|
*/ |
|
23
|
|
|
final class EnvelopeRecipientsEndpoint extends ResourceEndpoint |
|
24
|
|
|
{ |
|
25
|
|
|
/** @use CRUDEndpointTrait<EnvelopeRecipient> */ |
|
26
|
|
|
use CRUDEndpointTrait; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param Envelope|string $envelope |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(EnvelopesEndpoint $parent, $envelope) |
|
32
|
|
|
{ |
|
33
|
|
|
parent::__construct($parent, '/{envelope}/recipients', EnvelopeRecipient::class, ['envelope' => $envelope]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param EnvelopeRecipient|string $recipient |
|
38
|
|
|
*/ |
|
39
|
|
|
public function block($recipient): RecipientBlockEndpoint |
|
40
|
|
|
{ |
|
41
|
|
|
return new RecipientBlockEndpoint($this, $recipient); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param EnvelopeRecipient|string $recipient |
|
46
|
|
|
*/ |
|
47
|
|
|
public function attachments($recipient): EnvelopeRecipientAttachmentsEndpoint |
|
48
|
|
|
{ |
|
49
|
|
|
return new EnvelopeRecipientAttachmentsEndpoint($this, $recipient); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param mixed[] $body |
|
54
|
|
|
* @return array<EnvelopeRecipient> |
|
55
|
|
|
*/ |
|
56
|
|
|
public function createMany(array $body): array |
|
57
|
|
|
{ |
|
58
|
|
|
$response = $this->patchRequest('', ['json' => $body]); |
|
59
|
|
|
$result = $this->parseResponse($response); |
|
60
|
|
|
|
|
61
|
|
|
return array_map(static function (array $recipientResult): EnvelopeRecipient { |
|
62
|
|
|
return new EnvelopeRecipient($recipientResult); |
|
63
|
|
|
}, $result); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param mixed[] $body |
|
68
|
|
|
*/ |
|
69
|
|
|
public function embed(string $id, array $body): ResourceInterface |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->createResource( |
|
72
|
|
|
$this->postRequest('/{id}/embed', ['id' => $id, 'json' => $body]) |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param mixed[] $query |
|
78
|
|
|
* @return ListResource<EnvelopeTag> |
|
79
|
|
|
*/ |
|
80
|
|
|
public function tags(string $id, array $query = []): ListResource |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->createListResource( |
|
83
|
|
|
$this->getRequest('/{id}/tags', ['id' => $id, 'query' => $query]), |
|
84
|
|
|
EnvelopeTag::class |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function resend(string $id): ResourceInterface |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->createResource($this->postRequest('/{id}/resend', ['id' => $id])); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function verifiedClaims(string $id): ResourceInterface |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->createResource($this->getRequest('/{id}/verified-claims', ['id' => $id]), VerifiedClaims::class); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param mixed[] $body |
|
100
|
|
|
*/ |
|
101
|
|
|
public function signingOrder(array $body): void |
|
102
|
|
|
{ |
|
103
|
|
|
$this->putRequest('/signing-order', ['json' => $body]); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return Collection<EnvelopeRecipientAttachment> |
|
108
|
|
|
*/ |
|
109
|
|
|
public function listAttachments(): Collection |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->createCollectionResource($this->getRequest('/attachments'), EnvelopeRecipientAttachment::class); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|