Completed
Push — 1.x ( 3966e7...6acb79 )
by
unknown
19s queued 12s
created

EnvelopeTemplateLabelsEndpoint::set()   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\Resource\Collection;
8
use DigitalCz\DigiSign\Resource\EnvelopeTemplate;
9
use DigitalCz\DigiSign\Resource\Label;
10
11
/**
12
 * @extends ResourceEndpoint<Label>
13
 */
14
final class EnvelopeTemplateLabelsEndpoint extends ResourceEndpoint
15
{
16
    /**
17
     * @param EnvelopeTemplate|string $template
18
     */
19
    public function __construct(EnvelopeTemplatesEndpoint $parent, $template)
20
    {
21
        parent::__construct($parent, '/{template}/labels', Label::class, ['template' => $template]);
22
    }
23
24
    /**
25
     * @return Collection<Label>
26
     */
27
    public function all(): Collection
28
    {
29
        return $this->createCollectionResource($this->getRequest(), $this->getResourceClass());
30
    }
31
32
    /**
33
     * @param array<string> $body
34
     * @return Collection<Label>
35
     */
36
    public function set(array $body): Collection
37
    {
38
        return $this->createCollectionResource($this->putRequest('', ['json' => $body]), $this->getResourceClass());
39
    }
40
41
    /**
42
     * @param Label|string $label
43
     */
44
    public function add($label): void
45
    {
46
        $this->putRequest('/{label}', ['label' => $label]);
47
    }
48
49
    /**
50
     * @param Label|string $label
51
     */
52
    public function remove($label): void
53
    {
54
        $this->deleteRequest('/{label}', ['label' => $label]);
55
    }
56
}
57