Passed
Pull Request — 1.x (#57)
by
unknown
02:00
created

EnvelopeTemplateDocumentsEndpoint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A download() 0 3 1
A __construct() 0 7 1
A positions() 0 3 1
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