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

Invoices   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 5
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A download() 0 3 1
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