1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DalliSDK\Responses; |
6
|
|
|
|
7
|
|
|
use DalliSDK\Models\Price; |
8
|
|
|
use JMS\Serializer\Annotation as JMS; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Предварительный расчет стоимости |
12
|
|
|
* |
13
|
|
|
* @see https://api.dalli-service.com/v1/doc/cost-delivery |
14
|
|
|
* @JMS\XmlRoot("deliverycost") |
15
|
|
|
* |
16
|
|
|
* @template-implements \IteratorAggregate<int, Price> |
17
|
|
|
*/ |
18
|
|
|
class DeliveryCostResponse implements ResponseInterface, \IteratorAggregate |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Название компании, которая осуществляет доставку |
22
|
|
|
* |
23
|
|
|
* @JMS\XmlAttribute() |
24
|
|
|
* @JMS\Type("string") |
25
|
|
|
*/ |
26
|
|
|
private ?string $partner = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @JMS\XmlAttribute() |
30
|
|
|
* @JMS\Type("string") |
31
|
|
|
* @JMS\SerializedName("townto") |
32
|
|
|
*/ |
33
|
|
|
private ?string $townTo = null; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Зона, в которую попадает адрес |
37
|
|
|
* |
38
|
|
|
* @JMS\XmlAttribute() |
39
|
|
|
* @JMS\Type("string") |
40
|
|
|
*/ |
41
|
|
|
private ?string $zone = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Стоимость доставки |
45
|
|
|
* |
46
|
|
|
* @JMS\XmlAttribute() |
47
|
|
|
* @JMS\Type("int") |
48
|
|
|
*/ |
49
|
|
|
private ?int $price = null; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Дополнительная информация о доставке |
53
|
|
|
* |
54
|
|
|
* @JMS\XmlAttribute() |
55
|
|
|
* @JMS\Type("string") |
56
|
|
|
* @JMS\SerializedName("delivery_period") |
57
|
|
|
*/ |
58
|
|
|
private ?string $deliveryPeriod = null; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Сообщение |
62
|
|
|
* |
63
|
|
|
* @JMS\XmlAttribute() |
64
|
|
|
* @JMS\Type("string") |
65
|
|
|
*/ |
66
|
|
|
private ?string $msg = null; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Код ошибки |
70
|
|
|
* |
71
|
|
|
* @JMS\XmlAttribute() |
72
|
|
|
* @JMS\Type("int") |
73
|
|
|
*/ |
74
|
|
|
private ?int $error = null; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Текст ошибки |
78
|
|
|
* |
79
|
|
|
* @JMS\XmlAttribute() |
80
|
|
|
* @JMS\Type("string") |
81
|
|
|
* @JMS\SerializedName("errormsg") |
82
|
|
|
*/ |
83
|
|
|
private ?string $errorMsg = null; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @JMS\Type("array<DalliSDK\Models\Price>") |
87
|
|
|
* @JMS\XmlList(inline = true, entry = "price") |
88
|
|
|
* @var Price[] |
89
|
|
|
*/ |
90
|
|
|
private array $items = []; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return \Traversable|Price[] |
94
|
|
|
*/ |
95
|
1 |
|
public function getIterator(): \ArrayIterator |
96
|
|
|
{ |
97
|
1 |
|
return new \ArrayIterator($this->getItems()); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return Price[] |
102
|
|
|
*/ |
103
|
1 |
|
public function getItems(): array |
104
|
|
|
{ |
105
|
1 |
|
return $this->items; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string|null |
110
|
|
|
*/ |
111
|
3 |
|
public function getPartner(): ?string |
112
|
|
|
{ |
113
|
3 |
|
return $this->partner; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return string|null |
118
|
|
|
*/ |
119
|
3 |
|
public function getTownTo(): ?string |
120
|
|
|
{ |
121
|
3 |
|
return $this->townTo; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string|null |
126
|
|
|
*/ |
127
|
3 |
|
public function getZone(): ?string |
128
|
|
|
{ |
129
|
3 |
|
return $this->zone; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return int|null |
134
|
|
|
*/ |
135
|
2 |
|
public function getPrice(): ?int |
136
|
|
|
{ |
137
|
2 |
|
return $this->price; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string|null |
142
|
|
|
*/ |
143
|
2 |
|
public function getDeliveryPeriod(): ?string |
144
|
|
|
{ |
145
|
2 |
|
return $this->deliveryPeriod; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return string|null |
150
|
|
|
*/ |
151
|
2 |
|
public function getMsg(): ?string |
152
|
|
|
{ |
153
|
2 |
|
return $this->msg; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return int|null |
158
|
|
|
*/ |
159
|
1 |
|
public function getError(): ?int |
160
|
|
|
{ |
161
|
1 |
|
return $this->error; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return string|null |
166
|
|
|
*/ |
167
|
1 |
|
public function getErrorMsg(): ?string |
168
|
|
|
{ |
169
|
1 |
|
return $this->errorMsg; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|