Passed
Push — 1.x ( a1c5f0...5e562b )
by Pavel
02:30
created

EnvelopesEndpoint::documents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DigitalCz\DigiSign\Endpoint;
6
7
use DigitalCz\DigiSign\DigiSign;
8
use DigitalCz\DigiSign\Endpoint\Traits\CRUDEndpointTrait;
9
use DigitalCz\DigiSign\Resource\BaseResource;
10
use DigitalCz\DigiSign\Resource\Envelope;
11
use DigitalCz\DigiSign\Stream\FileResponse;
12
13
/**
14
 * @extends ResourceEndpoint<Envelope>
15
 * @method Envelope get(string $id)
16
 * @method Envelope create(array $body)
17
 * @method Envelope update(string $id, array $body)
18
 */
19
final class EnvelopesEndpoint extends ResourceEndpoint
20
{
21
    /** @use CRUDEndpointTrait<Envelope> */
22
    use CRUDEndpointTrait;
23
24
    public function __construct(DigiSign $parent)
25
    {
26
        parent::__construct($parent, '/api/envelopes', Envelope::class);
27
    }
28
29
    /**
30
     * @param Envelope|string $envelope
31
     */
32
    public function documents($envelope): EnvelopeDocumentsEndpoint
33
    {
34
        return new EnvelopeDocumentsEndpoint($this, $envelope);
35
    }
36
37
    /**
38
     * @param Envelope|string $envelope
39
     */
40
    public function recipients($envelope): EnvelopeRecipientsEndpoint
41
    {
42
        return new EnvelopeRecipientsEndpoint($this, $envelope);
43
    }
44
45
    /**
46
     * @param Envelope|string $envelope
47
     */
48
    public function tags($envelope): EnvelopeTagsEndpoint
49
    {
50
        return new EnvelopeTagsEndpoint($this, $envelope);
51
    }
52
53
    /**
54
     * @param Envelope|string $envelope
55
     */
56
    public function notifications($envelope): EnvelopeNotificationsEndpoint
57
    {
58
        return new EnvelopeNotificationsEndpoint($this, $envelope);
59
    }
60
61
    public function cancel(string $id): BaseResource
62
    {
63
        return $this->createResource($this->postRequest('/{id}/cancel', ['id' => $id]));
64
    }
65
66
    public function count(): BaseResource
67
    {
68
        return $this->createResource($this->getRequest('/count'));
69
    }
70
71
    /**
72
     * @param mixed[] $query
73
     */
74
    public function download(string $id, array $query = []): FileResponse
75
    {
76
        return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]);
77
    }
78
79
    public function embedEdit(string $id): BaseResource
80
    {
81
        return $this->createResource($this->postRequest('/{id}/embed/edit', ['id' => $id]));
82
    }
83
84
    /**
85
     * @param mixed[] $body
86
     */
87
    public function extend(string $id, array $body): Envelope
88
    {
89
        return $this->makeResource($this->putRequest('/{id}/extend', ['id' => $id, 'json' => $body]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->makeResour...$id, 'json' => $body))) returns the type DigitalCz\DigiSign\Resource\ResourceInterface which includes types incompatible with the type-hinted return DigitalCz\DigiSign\Resource\Envelope.
Loading history...
90
    }
91
92
    public function send(string $id): BaseResource
93
    {
94
        return $this->createResource($this->postRequest('/{id}/send', ['id' => $id]));
95
    }
96
97
    public function resend(string $id): BaseResource
98
    {
99
        return $this->createResource($this->postRequest('/{id}/resend', ['id' => $id]));
100
    }
101
}
102