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\Envelope; |
||
9 | use DigitalCz\DigiSign\Resource\EnvelopeDocument; |
||
10 | use DigitalCz\DigiSign\Resource\EnvelopeDocumentSignatureSheets; |
||
11 | use DigitalCz\DigiSign\Resource\EnvelopeTag; |
||
12 | use DigitalCz\DigiSign\Resource\ListResource; |
||
13 | use DigitalCz\DigiSign\Stream\FileResponse; |
||
14 | |||
15 | /** |
||
16 | * @extends ResourceEndpoint<EnvelopeDocument> |
||
17 | * @method EnvelopeDocument get(string $id) |
||
18 | * @method EnvelopeDocument create(array $body) |
||
19 | * @method EnvelopeDocument update(string $id, array $body) |
||
20 | */ |
||
21 | final class EnvelopeDocumentsEndpoint extends ResourceEndpoint |
||
22 | { |
||
23 | /** @use CRUDEndpointTrait<EnvelopeDocument> */ |
||
24 | use CRUDEndpointTrait; |
||
25 | |||
26 | /** |
||
27 | * @param Envelope|string $envelope |
||
28 | */ |
||
29 | public function __construct(EnvelopesEndpoint $parent, $envelope) |
||
30 | { |
||
31 | parent::__construct($parent, '/{envelope}/documents', EnvelopeDocument::class, ['envelope' => $envelope]); |
||
32 | } |
||
33 | |||
34 | public function assignments(): EnvelopeDocumentAssignmentsEndpoint |
||
35 | { |
||
36 | return new EnvelopeDocumentAssignmentsEndpoint($this); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param mixed[] $body |
||
41 | */ |
||
42 | public function positions(array $body): void |
||
43 | { |
||
44 | $this->putRequest('/positions', ['json' => $body]); |
||
45 | } |
||
46 | |||
47 | public function merge(): EnvelopeDocument |
||
48 | { |
||
49 | $response = $this->postRequest("/merge"); |
||
50 | |||
51 | return $this->makeResource($response); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param mixed[] $query |
||
56 | */ |
||
57 | public function download(string $id, array $query = []): FileResponse |
||
58 | { |
||
59 | return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param mixed[] $query |
||
64 | * @return ListResource<EnvelopeTag> |
||
65 | */ |
||
66 | public function tags(string $id, array $query = []): ListResource |
||
67 | { |
||
68 | return $this->createListResource( |
||
69 | $this->getRequest('/{id}/tags', ['id' => $id, 'query' => $query]), |
||
70 | EnvelopeTag::class |
||
71 | ); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @param EnvelopeDocument|string $document |
||
76 | * @param mixed[] $body |
||
77 | */ |
||
78 | public function replaceFile($document, array $body): EnvelopeDocument |
||
79 | { |
||
80 | return $this->makeResource( |
||
0 ignored issues
–
show
|
|||
81 | $this->postRequest('/{document}/replace-file', ['document' => $document, 'json' => $body]) |
||
82 | ); |
||
83 | } |
||
84 | |||
85 | public function signatureSheets(): EnvelopeDocumentSignatureSheets |
||
86 | { |
||
87 | return $this->createResource($this->getRequest('/signature-sheets'), EnvelopeDocumentSignatureSheets::class); |
||
88 | } |
||
89 | } |
||
90 |