|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace VasilDakov\Speedy\Service\Shipment; |
|
6
|
|
|
|
|
7
|
|
|
use VasilDakov\Speedy\Speedy; |
|
8
|
|
|
use JMS\Serializer\Annotation as Serializer; |
|
9
|
|
|
use VasilDakov\Speedy\Traits\ToArray; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ShipmentSender |
|
13
|
|
|
* |
|
14
|
|
|
* @author Valentin Valkanov <[email protected]> |
|
15
|
|
|
* @author Vasil Dakov <[email protected]> |
|
16
|
|
|
* @copyright |
|
17
|
|
|
* @version |
|
18
|
|
|
* @Serializer\AccessType("public_method") |
|
19
|
|
|
*/ |
|
20
|
|
|
class ShipmentSender |
|
21
|
|
|
{ |
|
22
|
|
|
use ToArray; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var int|null |
|
26
|
|
|
* @Serializer\Type("integer") |
|
27
|
|
|
*/ |
|
28
|
|
|
private ?int $clientId = null; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var ShipmentPhoneNumber |
|
32
|
|
|
*/ |
|
33
|
|
|
private ShipmentPhoneNumber $phone1; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ?ShipmentPhoneNumber |
|
37
|
|
|
*/ |
|
38
|
|
|
private ?ShipmentPhoneNumber $phone2 = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var ?ShipmentPhoneNumber |
|
42
|
|
|
*/ |
|
43
|
|
|
private ?ShipmentPhoneNumber $phone3 = null; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string|null |
|
47
|
|
|
* @Serializer\Type("string") |
|
48
|
|
|
*/ |
|
49
|
|
|
private ?string $clientName = null; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var string|null |
|
53
|
|
|
* @Serializer\Type("string") |
|
54
|
|
|
*/ |
|
55
|
|
|
private ?string $contactName = null; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var string|null |
|
59
|
|
|
* @Serializer\Type("string") |
|
60
|
|
|
*/ |
|
61
|
|
|
private ?string $email = null; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var bool |
|
65
|
|
|
* @Serializer\Type("bool") |
|
66
|
|
|
*/ |
|
67
|
|
|
private bool $privatePerson = true; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var ?ShipmentAddress |
|
71
|
|
|
*/ |
|
72
|
|
|
private ?ShipmentAddress $address = null; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var int |
|
76
|
|
|
* @Serializer\Type("integer") |
|
77
|
|
|
*/ |
|
78
|
|
|
private ?int $dropoffOfficeId = null; |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
12 |
|
public function __construct( |
|
82
|
|
|
ShipmentPhoneNumber $phone1, |
|
83
|
|
|
string $email, |
|
84
|
|
|
string $clientName, |
|
85
|
|
|
int $dropoffOfficeId = null, |
|
86
|
|
|
) { |
|
87
|
12 |
|
$this->phone1 = $phone1; |
|
88
|
12 |
|
$this->email = $email; |
|
89
|
12 |
|
$this->clientName = $clientName; |
|
90
|
12 |
|
$this->dropoffOfficeId = $dropoffOfficeId; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return ShipmentPhoneNumber |
|
95
|
|
|
*/ |
|
96
|
1 |
|
public function getPhone1(): ShipmentPhoneNumber |
|
97
|
|
|
{ |
|
98
|
1 |
|
return $this->phone1; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param ShipmentPhoneNumber $phone1 |
|
103
|
|
|
*/ |
|
104
|
4 |
|
public function setPhone1(ShipmentPhoneNumber $phone1): void |
|
105
|
|
|
{ |
|
106
|
4 |
|
$this->phone1 = $phone1; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return ShipmentPhoneNumber |
|
111
|
|
|
*/ |
|
112
|
1 |
|
public function getPhone2(): ShipmentPhoneNumber |
|
113
|
|
|
{ |
|
114
|
1 |
|
return $this->phone2; |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param ShipmentPhoneNumber $phone2 |
|
119
|
|
|
*/ |
|
120
|
1 |
|
public function setPhone2(ShipmentPhoneNumber $phone2): void |
|
121
|
|
|
{ |
|
122
|
1 |
|
$this->phone2 = $phone2; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return ShipmentPhoneNumber |
|
127
|
|
|
*/ |
|
128
|
1 |
|
public function getPhone3(): ShipmentPhoneNumber |
|
129
|
|
|
{ |
|
130
|
1 |
|
return $this->phone3; |
|
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param ShipmentPhoneNumber $phone3 |
|
135
|
|
|
*/ |
|
136
|
1 |
|
public function setPhone3(ShipmentPhoneNumber $phone3): void |
|
137
|
|
|
{ |
|
138
|
1 |
|
$this->phone3 = $phone3; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return string|null |
|
143
|
|
|
*/ |
|
144
|
1 |
|
public function getClientName(): ?string |
|
145
|
|
|
{ |
|
146
|
1 |
|
return $this->clientName; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @param string $clientName |
|
151
|
|
|
*/ |
|
152
|
1 |
|
public function setClientName(string $clientName): void |
|
153
|
|
|
{ |
|
154
|
1 |
|
$this->clientName = $clientName; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return string |
|
159
|
|
|
*/ |
|
160
|
1 |
|
public function getContactName(): string |
|
161
|
|
|
{ |
|
162
|
1 |
|
return $this->contactName; |
|
|
|
|
|
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @param string $contactName |
|
167
|
|
|
*/ |
|
168
|
4 |
|
public function setContactName(string $contactName): void |
|
169
|
|
|
{ |
|
170
|
4 |
|
$this->contactName = $contactName; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return string |
|
175
|
|
|
*/ |
|
176
|
1 |
|
public function getEmail(): string |
|
177
|
|
|
{ |
|
178
|
1 |
|
return $this->email; |
|
|
|
|
|
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @param string $email |
|
183
|
|
|
*/ |
|
184
|
4 |
|
public function setEmail(string $email): void |
|
185
|
|
|
{ |
|
186
|
4 |
|
$this->email = $email; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @return bool |
|
191
|
|
|
*/ |
|
192
|
1 |
|
public function isPrivatePerson(): bool |
|
193
|
|
|
{ |
|
194
|
1 |
|
return $this->privatePerson; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @param bool $privatePerson |
|
199
|
|
|
*/ |
|
200
|
1 |
|
public function setPrivatePerson(bool $privatePerson): void |
|
201
|
|
|
{ |
|
202
|
1 |
|
$this->privatePerson = $privatePerson; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @return ShipmentAddress |
|
207
|
|
|
*/ |
|
208
|
1 |
|
public function getAddress(): ShipmentAddress |
|
209
|
|
|
{ |
|
210
|
1 |
|
return $this->address; |
|
|
|
|
|
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* @param ShipmentAddress $address |
|
215
|
|
|
*/ |
|
216
|
1 |
|
public function setAddress(ShipmentAddress $address): void |
|
217
|
|
|
{ |
|
218
|
1 |
|
$this->address = $address; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @return int |
|
223
|
|
|
*/ |
|
224
|
1 |
|
public function getDropoffOfficeId(): int |
|
225
|
|
|
{ |
|
226
|
1 |
|
return $this->dropoffOfficeId; |
|
|
|
|
|
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* @param int $dropoffOfficeId |
|
231
|
|
|
*/ |
|
232
|
1 |
|
public function setDropoffOfficeId(int $dropoffOfficeId): void |
|
233
|
|
|
{ |
|
234
|
1 |
|
$this->dropoffOfficeId = $dropoffOfficeId; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @param int|null $clientId |
|
239
|
|
|
*/ |
|
240
|
|
|
public function setClientId(?int $clientId): void |
|
241
|
|
|
{ |
|
242
|
|
|
$this->clientId = $clientId; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* @return int|null |
|
247
|
|
|
*/ |
|
248
|
|
|
public function getClientId(): ?int |
|
249
|
|
|
{ |
|
250
|
|
|
return $this->clientId; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
3 |
|
public function toArray(): array |
|
254
|
|
|
{ |
|
255
|
3 |
|
return [ |
|
256
|
3 |
|
Speedy::PHONE_1 => $this->phone1->toArray(), |
|
257
|
3 |
|
Speedy::CONTACT_NAME => $this->contactName, |
|
258
|
3 |
|
Speedy::EMAIL => $this->email, |
|
259
|
3 |
|
]; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
} |
|
263
|
|
|
|