Passed
Push — master ( a1417a...6e4df4 )
by ihomyak
06:46
created

Invoices   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A download() 0 3 1
1
<?php
2
3
/**
4
 * Copyright (c) 2020. CDEK-IT. All rights reserved.
5
 * See LICENSE.md for license details.
6
 *
7
 * @author Chizhekov Viktor
8
 */
9
10
namespace CdekSDK2\Actions;
11
12
use CdekSDK2\BaseTypes\Invoice;
13
use CdekSDK2\Exceptions\RequestException;
14
use CdekSDK2\Http\ApiResponse;
15
16
/**
17
 * Class Invoices
18
 * @package CdekSDK2\Actions
19
 */
20
class Invoices extends Action
21
{
22
    /**
23
     * URL для запросов к API на формирование квитаниции
24
     * @var string
25
     */
26
    public const URL = '/print/orders';
27
28
    /**
29
     * Запрос на формирование квитанции к заказу
30
     * @param Invoice $invoice
31
     * @return ApiResponse
32
     * @throws RequestException
33
     */
34 1
    public function add(Invoice $invoice): ApiResponse
35
    {
36 1
        $params = $this->serializer->toArray($invoice);
37 1
        return $this->preparedAdd($params);
0 ignored issues
show
Bug introduced by
$params of type PhpOption\T is incompatible with the type array expected by parameter $params of CdekSDK2\Actions\Action::preparedAdd(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return $this->preparedAdd(/** @scrutinizer ignore-type */ $params);
Loading history...
38
    }
39
40
    /**
41
     * Запрос на получение данных печатной формы
42
     * @param string $uuid
43
     * @return ApiResponse
44
     * @throws RequestException
45
     */
46 1
    public function download(string $uuid): ApiResponse
47
    {
48 1
        return $this->http_client->get($this->slug($uuid) . '.pdf');
49
    }
50
}
51