Passed
Pull Request — 1.x (#88)
by Pavel
09:07
created

EnvelopeTemplateDocumentsEndpoint::replaceFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
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\EnvelopeDocument;
9
use DigitalCz\DigiSign\Resource\EnvelopeTemplate;
10
use DigitalCz\DigiSign\Resource\EnvelopeTemplateDocument;
11
use DigitalCz\DigiSign\Stream\FileResponse;
12
13
/**
14
 * @extends ResourceEndpoint<EnvelopeTemplateDocument>
15
 * @method EnvelopeTemplateDocument get(string $id)
16
 * @method EnvelopeTemplateDocument create(array $body)
17
 * @method EnvelopeTemplateDocument update(string $id, array $body)
18
 */
19
final class EnvelopeTemplateDocumentsEndpoint extends ResourceEndpoint
20
{
21
    /** @use CRUDEndpointTrait<EnvelopeTemplateDocument> */
22
    use CRUDEndpointTrait;
23
24
    /**
25
     * @param EnvelopeTemplate|string $template
26
     */
27
    public function __construct(EnvelopeTemplatesEndpoint $parent, $template)
28
    {
29
        parent::__construct(
30
            $parent,
31
            '/{template}/documents',
32
            EnvelopeTemplateDocument::class,
33
            ['template' => $template]
34
        );
35
    }
36
37
    /**
38
     * @param mixed[] $query
39
     */
40
    public function download(string $id, array $query = []): FileResponse
41
    {
42
        return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]);
43
    }
44
45
    /**
46
     * @param mixed[] $body
47
     */
48
    public function positions(array $body): void
49
    {
50
        $this->putRequest('/positions', ['json' => $body]);
51
    }
52
53
    /**
54
     * @param EnvelopeTemplateDocument|string $document
55
     * @param mixed[] $body
56
     */
57
    public function replaceFile($document, array $body): EnvelopeTemplateDocument
58
    {
59
        return $this->makeResource(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->makeResour...ent, 'json' => $body))) returns the type DigitalCz\DigiSign\Resource\ResourceInterface which includes types incompatible with the type-hinted return DigitalCz\DigiSign\Resou...nvelopeTemplateDocument.
Loading history...
60
            $this->postRequest('/{document}/replace-file', ['document' => $document, 'json' => $body])
61
        );
62
    }
63
}
64