Passed
Push — 1.x ( f2e382...7ae348 )
by Pavel
02:06
created

EnvelopesEndpoint::extend()   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 2
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\Resource\EnvelopeTemplate;
12
use DigitalCz\DigiSign\Stream\FileResponse;
13
14
/**
15
 * @extends ResourceEndpoint<Envelope>
16
 * @method Envelope get(string $id)
17
 * @method Envelope create(array $body)
18
 * @method Envelope update(string $id, array $body)
19
 */
20
final class EnvelopesEndpoint extends ResourceEndpoint
21
{
22
    /** @use CRUDEndpointTrait<Envelope> */
23
    use CRUDEndpointTrait;
24
25
    public function __construct(DigiSign $parent)
26
    {
27
        parent::__construct($parent, '/api/envelopes', Envelope::class);
28
    }
29
30
    /**
31
     * @param Envelope|string $envelope
32
     */
33
    public function documents($envelope): EnvelopeDocumentsEndpoint
34
    {
35
        return new EnvelopeDocumentsEndpoint($this, $envelope);
36
    }
37
38
    /**
39
     * @param Envelope|string $envelope
40
     */
41
    public function recipients($envelope): EnvelopeRecipientsEndpoint
42
    {
43
        return new EnvelopeRecipientsEndpoint($this, $envelope);
44
    }
45
46
    /**
47
     * @param Envelope|string $envelope
48
     */
49
    public function tags($envelope): EnvelopeTagsEndpoint
50
    {
51
        return new EnvelopeTagsEndpoint($this, $envelope);
52
    }
53
54
    /**
55
     * @param Envelope|string $envelope
56
     */
57
    public function notifications($envelope): EnvelopeNotificationsEndpoint
58
    {
59
        return new EnvelopeNotificationsEndpoint($this, $envelope);
60
    }
61
62
    /**
63
     * @param Envelope|string $envelope
64
     */
65
    public function labels($envelope): EnvelopeLabelsEndpoint
66
    {
67
        return new EnvelopeLabelsEndpoint($this, $envelope);
68
    }
69
70
    public function cancel(string $id): BaseResource
71
    {
72
        return $this->createResource($this->postRequest('/{id}/cancel', ['id' => $id]));
73
    }
74
75
    public function count(): BaseResource
76
    {
77
        return $this->createResource($this->getRequest('/count'));
78
    }
79
80
    /**
81
     * @param mixed[] $query
82
     */
83
    public function download(string $id, array $query = []): FileResponse
84
    {
85
        return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]);
86
    }
87
88
    /**
89
     * @param mixed[] $body
90
     */
91
    public function embedEdit(string $id, array $body = []): BaseResource
92
    {
93
        return $this->createResource($this->postRequest('/{id}/embed/edit', ['id' => $id, 'json' => $body]));
94
    }
95
96
    /**
97
     * @param mixed[] $body
98
     */
99
    public function embedSigning(string $id, array $body = []): BaseResource
100
    {
101
        return $this->createResource($this->postRequest('/{id}/embed/signing', ['id' => $id, 'json' => $body]));
102
    }
103
104
    /**
105
     * @param mixed[] $body
106
     */
107
    public function extend(string $id, array $body): Envelope
108
    {
109
        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...
110
    }
111
112
    public function send(string $id): BaseResource
113
    {
114
        return $this->createResource($this->postRequest('/{id}/send', ['id' => $id]));
115
    }
116
117
    public function resend(string $id): BaseResource
118
    {
119
        return $this->createResource($this->postRequest('/{id}/resend', ['id' => $id]));
120
    }
121
122
    /**
123
     * @param Envelope|string $id
124
     */
125
    public function template($id): EnvelopeTemplate
126
    {
127
        return $this->createResource($this->getRequest('/{id}/template', ['id' => $id]), EnvelopeTemplate::class);
128
    }
129
130
    /**
131
     * @param Envelope|string $id
132
     */
133
    public function clone($id): Envelope
134
    {
135
        return $this->makeResource($this->postRequest('/{id}/clone', ['id' => $id]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->makeResour...', array('id' => $id))) returns the type DigitalCz\DigiSign\Resource\ResourceInterface which includes types incompatible with the type-hinted return DigitalCz\DigiSign\Resource\Envelope.
Loading history...
136
    }
137
138
    /**
139
     * @param Envelope|string $id
140
     */
141
    public function discard($id): Envelope
142
    {
143
        return $this->makeResource($this->postRequest('/{id}/discard', ['id' => $id]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->makeResour...', array('id' => $id))) returns the type DigitalCz\DigiSign\Resource\ResourceInterface which includes types incompatible with the type-hinted return DigitalCz\DigiSign\Resource\Envelope.
Loading history...
144
    }
145
146
    /**
147
     * @param Envelope|string $id
148
     */
149
    public function restore($id): Envelope
150
    {
151
        return $this->makeResource($this->postRequest('/{id}/restore', ['id' => $id]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->makeResour...', array('id' => $id))) returns the type DigitalCz\DigiSign\Resource\ResourceInterface which includes types incompatible with the type-hinted return DigitalCz\DigiSign\Resource\Envelope.
Loading history...
152
    }
153
154
    /**
155
     * @param Envelope|string $id
156
     */
157
    public function validate($id): void
158
    {
159
        $this->getRequest('/{id}/validate', ['id' => $id]);
160
    }
161
}
162