|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace DalliSDK\Requests\Stickers; |
|
6
|
|
|
|
|
7
|
|
|
use DalliSDK\Requests\AbstractRequest; |
|
8
|
|
|
use DalliSDK\Requests\RequestInterface; |
|
9
|
|
|
use JMS\Serializer\Annotation as JMS; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Получить ярлыки(наклейки) на заказы |
|
13
|
|
|
* |
|
14
|
|
|
* @see https://api.dalli-service.com/v1/doc/stickers |
|
15
|
|
|
*/ |
|
16
|
|
|
class BaseStickersRequest extends AbstractRequest implements RequestInterface |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Тег, который указывает формат бумаги. |
|
20
|
|
|
* Принимает значения 1 - Зебра, 2 - А4 с рамкой, 3 - А4 без рамки, 4 - A6. |
|
21
|
|
|
* По умолчанию 1 (необязательный элемент) |
|
22
|
|
|
* |
|
23
|
|
|
* @JMS\Type("int") |
|
24
|
|
|
* @JMS\SerializedName("format") |
|
25
|
|
|
*/ |
|
26
|
|
|
private ?int $format = 1; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Контейнер, который содержит штрих-коды заказов. |
|
30
|
|
|
* По-умолчанию все переданные заказы за сегодня (не обязательный элемент) |
|
31
|
|
|
* |
|
32
|
|
|
* @JMS\XmlList(inline = false, entry = "barcode") |
|
33
|
|
|
*/ |
|
34
|
|
|
private ?array $barcodes = null; |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param int $format |
|
39
|
|
|
* @param array|null $barcodes |
|
40
|
|
|
*/ |
|
41
|
5 |
|
public function __construct(int $format = 1, ?array $barcodes = null) |
|
42
|
|
|
{ |
|
43
|
5 |
|
$this->format = $format; |
|
44
|
5 |
|
$this->barcodes = $barcodes; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return int|null |
|
49
|
|
|
*/ |
|
50
|
2 |
|
public function getFormat(): ?int |
|
51
|
|
|
{ |
|
52
|
2 |
|
return $this->format; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param int $format |
|
57
|
|
|
* |
|
58
|
|
|
* @return $this |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function setFormat(int $format) |
|
61
|
|
|
{ |
|
62
|
2 |
|
$this->format = $format; |
|
63
|
2 |
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return array|null |
|
68
|
|
|
*/ |
|
69
|
2 |
|
public function getBarcodes(): ?array |
|
70
|
|
|
{ |
|
71
|
2 |
|
return $this->barcodes; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param array|null $barcodes |
|
76
|
|
|
* |
|
77
|
|
|
* @return $this |
|
78
|
|
|
*/ |
|
79
|
2 |
|
public function setBarcodes(?array $barcodes): BaseStickersRequest |
|
80
|
|
|
{ |
|
81
|
2 |
|
$this->barcodes = $barcodes; |
|
82
|
2 |
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param string $barcode |
|
87
|
|
|
* |
|
88
|
|
|
* @return $this |
|
89
|
|
|
*/ |
|
90
|
2 |
|
public function addBarcode(string $barcode): BaseStickersRequest |
|
91
|
|
|
{ |
|
92
|
2 |
|
if ($this->barcodes === null) { |
|
93
|
2 |
|
$this->barcodes = []; |
|
94
|
|
|
} |
|
95
|
2 |
|
if (in_array($barcode, $this->barcodes)) { |
|
|
|
|
|
|
96
|
1 |
|
throw new \InvalidArgumentException("Barcode: $barcode already exists."); |
|
97
|
|
|
} |
|
98
|
2 |
|
$this->barcodes[] = $barcode; |
|
99
|
2 |
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|