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

Barcodes::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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\Barcode;
13
use CdekSDK2\Exceptions\RequestException;
14
use CdekSDK2\Http\ApiResponse;
15
16
/**
17
 * Class Barcodes
18
 * @package CdekSDK2\Actions
19
 */
20
class Barcodes extends Action
21
{
22
    /**
23
     * URL для запросов к API на формирование ШК
24
     * @var string
25
     */
26
    public const URL = '/print/barcodes';
27
28
    /**
29
     * Запрос на формирование ШК-места к заказу
30
     * @param Barcode $barcode
31
     * @return ApiResponse
32
     * @throws RequestException
33
     */
34 1
    public function add(Barcode $barcode): ApiResponse
35
    {
36 1
        $params = $this->serializer->toArray($barcode);
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