|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace VasilDakov\Speedy\Service\Shipment; |
|
6
|
|
|
|
|
7
|
|
|
use JMS\Serializer\Annotation as Serializer; |
|
8
|
|
|
use VasilDakov\Speedy\Traits\ToArray; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class CreateShipmentRequest |
|
12
|
|
|
* |
|
13
|
|
|
* @author Valentin Valkanov <[email protected]> |
|
14
|
|
|
* @author Vasil Dakov <[email protected]> |
|
15
|
|
|
* @copyright 2009-2023 Neutrino.bg |
|
16
|
|
|
* @version 1.0 |
|
17
|
|
|
* @Serializer\AccessType("public_method") |
|
18
|
|
|
*/ |
|
19
|
|
|
class CreateShipmentRequest |
|
20
|
|
|
{ |
|
21
|
|
|
use ToArray; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var ShipmentSender |
|
25
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentSender") |
|
26
|
|
|
*/ |
|
27
|
|
|
private ShipmentSender $sender; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var ShipmentRecipient |
|
31
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentRecipient") |
|
32
|
|
|
*/ |
|
33
|
|
|
private ShipmentRecipient $recipient; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ShipmentService |
|
37
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentService") |
|
38
|
|
|
*/ |
|
39
|
|
|
private ShipmentService $service; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var ShipmentContent |
|
43
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentContent") |
|
44
|
|
|
*/ |
|
45
|
|
|
private ShipmentContent $content; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var ShipmentPayment |
|
49
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentPayment") |
|
50
|
|
|
*/ |
|
51
|
|
|
private ShipmentPayment $payment; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var string|null |
|
55
|
|
|
* @Serializer\Type("string") |
|
56
|
|
|
*/ |
|
57
|
|
|
private ?string $shipmentNote = null; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string|null |
|
61
|
|
|
* @Serializer\Type("string") |
|
62
|
|
|
*/ |
|
63
|
|
|
private ?string $ref1 = null; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var string|null |
|
67
|
|
|
* @Serializer\Type("string") |
|
68
|
|
|
*/ |
|
69
|
|
|
private ?string $ref2 = null; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @var string|null |
|
73
|
|
|
* @Serializer\Type("string") |
|
74
|
|
|
*/ |
|
75
|
|
|
private ?string $consolidationRef = null; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @var bool |
|
79
|
|
|
* @Serializer\Type("bool") |
|
80
|
|
|
*/ |
|
81
|
|
|
private bool $requireUnsuccessfulDeliveryStickerImage = false; |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param ShipmentSender $sender |
|
85
|
|
|
* @param ShipmentRecipient $recipient |
|
86
|
|
|
* @param ShipmentService $service |
|
87
|
|
|
* @param ShipmentContent $content |
|
88
|
|
|
* @param ShipmentPayment $payment |
|
89
|
|
|
* @param string $ref1 |
|
90
|
|
|
*/ |
|
91
|
12 |
|
public function __construct( |
|
92
|
|
|
ShipmentSender $sender, |
|
93
|
|
|
ShipmentRecipient $recipient, |
|
94
|
|
|
ShipmentService $service, |
|
95
|
|
|
ShipmentContent $content, |
|
96
|
|
|
ShipmentPayment $payment, |
|
97
|
|
|
string $ref1 |
|
98
|
|
|
) { |
|
99
|
12 |
|
$this->sender = $sender; |
|
100
|
12 |
|
$this->recipient = $recipient; |
|
101
|
12 |
|
$this->service = $service; |
|
102
|
12 |
|
$this->content = $content; |
|
103
|
12 |
|
$this->payment = $payment; |
|
104
|
12 |
|
$this->ref1 = $ref1; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return ShipmentRecipient |
|
109
|
|
|
*/ |
|
110
|
2 |
|
public function getRecipient(): ShipmentRecipient |
|
111
|
|
|
{ |
|
112
|
2 |
|
return $this->recipient; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @param ShipmentRecipient $recipient |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
3 |
|
public function setRecipient(ShipmentRecipient $recipient): void |
|
120
|
|
|
{ |
|
121
|
3 |
|
$this->recipient = $recipient; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return ShipmentService |
|
126
|
|
|
*/ |
|
127
|
2 |
|
public function getService(): ShipmentService |
|
128
|
|
|
{ |
|
129
|
2 |
|
return $this->service; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @param ShipmentService $service |
|
134
|
|
|
* @return void |
|
135
|
|
|
*/ |
|
136
|
3 |
|
public function setService(ShipmentService $service): void |
|
137
|
|
|
{ |
|
138
|
3 |
|
$this->service = $service; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return ShipmentContent |
|
143
|
|
|
*/ |
|
144
|
2 |
|
public function getContent(): ShipmentContent |
|
145
|
|
|
{ |
|
146
|
2 |
|
return $this->content; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @param ShipmentContent $content |
|
151
|
|
|
* @return void |
|
152
|
|
|
*/ |
|
153
|
3 |
|
public function setContent(ShipmentContent $content): void |
|
154
|
|
|
{ |
|
155
|
3 |
|
$this->content = $content; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @return ShipmentPayment |
|
160
|
|
|
*/ |
|
161
|
2 |
|
public function getPayment(): ShipmentPayment |
|
162
|
|
|
{ |
|
163
|
2 |
|
return $this->payment; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param ShipmentPayment $payment |
|
168
|
|
|
* @return void |
|
169
|
|
|
*/ |
|
170
|
3 |
|
public function setPayment(ShipmentPayment $payment): void |
|
171
|
|
|
{ |
|
172
|
3 |
|
$this->payment = $payment; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* @return ShipmentSender |
|
177
|
|
|
*/ |
|
178
|
1 |
|
public function getSender(): ShipmentSender |
|
179
|
|
|
{ |
|
180
|
1 |
|
return $this->sender; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @param ShipmentSender $sender |
|
185
|
|
|
*/ |
|
186
|
4 |
|
public function setSender(ShipmentSender $sender): void |
|
187
|
|
|
{ |
|
188
|
4 |
|
$this->sender = $sender; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* @return string|null |
|
193
|
|
|
*/ |
|
194
|
1 |
|
public function getShipmentNote(): ?string |
|
195
|
|
|
{ |
|
196
|
1 |
|
return $this->shipmentNote; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @param string $shipmentNote |
|
201
|
|
|
*/ |
|
202
|
4 |
|
public function setShipmentNote(string $shipmentNote): void |
|
203
|
|
|
{ |
|
204
|
4 |
|
$this->shipmentNote = $shipmentNote; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @return string|null |
|
209
|
|
|
*/ |
|
210
|
1 |
|
public function getRef1(): ?string |
|
211
|
|
|
{ |
|
212
|
1 |
|
return $this->ref1; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @param string $ref1 |
|
217
|
|
|
*/ |
|
218
|
4 |
|
public function setRef1(string $ref1): void |
|
219
|
|
|
{ |
|
220
|
4 |
|
$this->ref1 = $ref1; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @return string|null |
|
225
|
|
|
*/ |
|
226
|
1 |
|
public function getRef2(): ?string |
|
227
|
|
|
{ |
|
228
|
1 |
|
return $this->ref2; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @param string $ref2 |
|
233
|
|
|
*/ |
|
234
|
4 |
|
public function setRef2(string $ref2): void |
|
235
|
|
|
{ |
|
236
|
4 |
|
$this->ref2 = $ref2; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* @return string|null |
|
241
|
|
|
*/ |
|
242
|
1 |
|
public function getConsolidationRef(): ?string |
|
243
|
|
|
{ |
|
244
|
1 |
|
return $this->consolidationRef; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @param string $consolidationRef |
|
249
|
|
|
* @return void |
|
250
|
|
|
*/ |
|
251
|
1 |
|
public function setConsolidationRef(string $consolidationRef): void |
|
252
|
|
|
{ |
|
253
|
1 |
|
$this->consolidationRef = $consolidationRef; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* @return bool |
|
258
|
|
|
*/ |
|
259
|
1 |
|
public function getRequireUnsuccessfulDeliveryStickerImage(): bool |
|
260
|
|
|
{ |
|
261
|
1 |
|
return $this->requireUnsuccessfulDeliveryStickerImage; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* @param bool $requireUnsuccessfulDeliveryStickerImage |
|
266
|
|
|
*/ |
|
267
|
1 |
|
public function setRequireUnsuccessfulDeliveryStickerImage(bool $requireUnsuccessfulDeliveryStickerImage): void |
|
268
|
|
|
{ |
|
269
|
1 |
|
$this->requireUnsuccessfulDeliveryStickerImage = $requireUnsuccessfulDeliveryStickerImage; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* @return array |
|
274
|
|
|
*/ |
|
275
|
2 |
|
public function toArray(): array |
|
276
|
|
|
{ |
|
277
|
2 |
|
return [ |
|
278
|
2 |
|
"service" => $this->service->toArray(), // ok |
|
279
|
2 |
|
"content" => $this->content->toArray(), // ok |
|
280
|
2 |
|
"payment" => $this->payment->toArray(), // ok |
|
281
|
2 |
|
"sender" => $this->sender->toArray(), // ok |
|
282
|
|
|
/* "sender" => [ |
|
283
|
|
|
"phone1" => [ |
|
284
|
|
|
"number" => "0888323020" |
|
285
|
|
|
], |
|
286
|
|
|
"contactName" => "VASIL DAKOV", |
|
287
|
|
|
"email" => "[email protected]" |
|
288
|
|
|
], */ |
|
289
|
2 |
|
"recipient" => $this->recipient->toArray(), // ok |
|
290
|
2 |
|
"ref1" => $this->ref1 |
|
291
|
2 |
|
]; |
|
292
|
|
|
} |
|
293
|
|
|
} |
|
294
|
|
|
|