DeliveriesEndpoint::__construct()   A
last analyzed

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\Delivery;
11
12
/**
13
 * @extends ResourceEndpoint<Delivery>
14
 * @method Delivery get(string $id)
15
 * @method Delivery create(array $body)
16
 * @method Delivery update(string $id, array $body)
17
 */
18
final class DeliveriesEndpoint extends ResourceEndpoint
19
{
20
    /** @use CRUDEndpointTrait<Delivery> */
21
    use CRUDEndpointTrait;
22
23
    public function __construct(DigiSign $parent)
24
    {
25
        parent::__construct($parent, '/api/deliveries', Delivery::class);
26
    }
27
28
    /**
29
     * @param Delivery|string $delivery
30
     */
31
    public function documents($delivery): DeliveryDocumentsEndpoint
32
    {
33
        return new DeliveryDocumentsEndpoint($this, $delivery);
34
    }
35
36
    /**
37
     * @param Delivery|string $delivery
38
     */
39
    public function recipients($delivery): DeliveryRecipientsEndpoint
40
    {
41
        return new DeliveryRecipientsEndpoint($this, $delivery);
42
    }
43
44
    public function cancel(string $id): BaseResource
45
    {
46
        return $this->createResource($this->postRequest('/{id}/cancel', ['id' => $id]));
47
    }
48
49
    public function send(string $id): BaseResource
50
    {
51
        return $this->createResource($this->postRequest('/{id}/send', ['id' => $id]));
52
    }
53
}
54