DeliveryDocumentsEndpoint   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A positions() 0 3 1
A download() 0 3 1
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\Delivery;
9
use DigitalCz\DigiSign\Resource\DeliveryDocument;
10
use DigitalCz\DigiSign\Stream\FileResponse;
11
12
/**
13
 * @extends ResourceEndpoint<DeliveryDocument>
14
 * @method DeliveryDocument get(string $id)
15
 * @method DeliveryDocument create(array $body)
16
 * @method DeliveryDocument update(string $id, array $body)
17
 */
18
final class DeliveryDocumentsEndpoint extends ResourceEndpoint
19
{
20
    /** @use CRUDEndpointTrait<DeliveryDocument> */
21
    use CRUDEndpointTrait;
22
23
    /**
24
     * @param Delivery|string $delivery
25
     */
26
    public function __construct(DeliveriesEndpoint $parent, $delivery)
27
    {
28
        parent::__construct($parent, '/{delivery}/documents', DeliveryDocument::class, ['delivery' => $delivery]);
29
    }
30
31
    /**
32
     * @param mixed[] $body
33
     */
34
    public function positions(array $body): void
35
    {
36
        $this->putRequest('/positions', ['json' => $body]);
37
    }
38
39
    /**
40
     * @param mixed[] $query
41
     */
42
    public function download(string $id, array $query = []): FileResponse
43
    {
44
        return $this->stream(self::METHOD_GET, '/{id}/download', ['id' => $id, 'query' => $query]);
45
    }
46
}
47