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\EnvelopeTemplate; |
||
9 | use DigitalCz\DigiSign\Resource\EnvelopeTemplateDocument; |
||
10 | use DigitalCz\DigiSign\Stream\FileResponse; |
||
11 | |||
12 | /** |
||
13 | * @extends ResourceEndpoint<EnvelopeTemplateDocument> |
||
14 | * @method EnvelopeTemplateDocument get(string $id) |
||
15 | * @method EnvelopeTemplateDocument create(array $body) |
||
16 | * @method EnvelopeTemplateDocument update(string $id, array $body) |
||
17 | */ |
||
18 | final class EnvelopeTemplateDocumentsEndpoint extends ResourceEndpoint |
||
19 | { |
||
20 | /** @use CRUDEndpointTrait<EnvelopeTemplateDocument> */ |
||
21 | use CRUDEndpointTrait; |
||
22 | |||
23 | /** |
||
24 | * @param EnvelopeTemplate|string $template |
||
25 | */ |
||
26 | public function __construct(EnvelopeTemplatesEndpoint $parent, $template) |
||
27 | { |
||
28 | parent::__construct( |
||
29 | $parent, |
||
30 | '/{template}/documents', |
||
31 | EnvelopeTemplateDocument::class, |
||
32 | ['template' => $template] |
||
33 | ); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param mixed[] $query |
||
38 | */ |
||
39 | public function download(string $id, array $query = []): FileResponse |
||
40 | { |
||
41 | return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param mixed[] $body |
||
46 | */ |
||
47 | public function positions(array $body): void |
||
48 | { |
||
49 | $this->putRequest('/positions', ['json' => $body]); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param EnvelopeTemplateDocument|string $document |
||
54 | * @param mixed[] $body |
||
55 | */ |
||
56 | public function replaceFile($document, array $body): EnvelopeTemplateDocument |
||
57 | { |
||
58 | return $this->makeResource( |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
59 | $this->postRequest('/{document}/replace-file', ['document' => $document, 'json' => $body]) |
||
60 | ); |
||
61 | } |
||
62 | } |
||
63 |