Passed
Push — master ( 77184d...7405ca )
by Alex
02:37
created

Invoices::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CdekSDK2\Actions;
6
7
use CdekSDK2\BaseTypes\Invoice;
8
use CdekSDK2\Exceptions\RequestException;
9
use CdekSDK2\Http\ApiResponse;
10
11
/**
12
 * Class Invoices
13
 * @package CdekSDK2\Actions
14
 */
15
class Invoices extends Action
16
{
17
    /**
18
     * URL для запросов к API на формирование квитаниции
19
     * @var string
20
     */
21
    public const URL = '/print/orders';
22
23
    /**
24
     * Запрос на формирование квитанции к заказу
25
     * @param Invoice $invoice
26
     * @return ApiResponse
27
     * @throws RequestException
28
     */
29
    public function add(Invoice $invoice): ApiResponse
30
    {
31
        $params = $this->serializer->toArray($invoice);
32
        return $this->preparedAdd($params);
33
    }
34
35
    /**
36
     * Запрос на получение данных печатной формы
37
     * @param string $uuid
38
     * @return ApiResponse
39
     * @throws RequestException
40
     */
41
    public function download(string $uuid): ApiResponse
42
    {
43
        return $this->http_client->get($this->slug($uuid) . '.pdf');
44
    }
45
}
46