DeliveryDocumentsEndpoint::__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 2
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