|
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\Model\BankAccount; |
|
9
|
|
|
use VasilDakov\Speedy\Speedy; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class ShipmentPayment |
|
13
|
|
|
* |
|
14
|
|
|
* @Serializer\AccessType("public_method") |
|
15
|
|
|
* @author Valentin Valkanov <[email protected]> |
|
16
|
|
|
* @author Vasil Dakov <[email protected]> |
|
17
|
|
|
* @copyright |
|
18
|
|
|
* @version |
|
19
|
|
|
*/ |
|
20
|
|
|
class ShipmentPayment |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
* @Serializer\Type("string") |
|
25
|
|
|
*/ |
|
26
|
|
|
private string $courierServicePayer; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string|null |
|
30
|
|
|
* @Serializer\Type("string") |
|
31
|
|
|
*/ |
|
32
|
|
|
private ?string $declaredValuePayer = ''; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string|null |
|
36
|
|
|
* @Serializer\Type("string") |
|
37
|
|
|
*/ |
|
38
|
|
|
private ?string $packagePayer = ''; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var int|null |
|
42
|
|
|
* @Serializer\Type("integer") |
|
43
|
|
|
*/ |
|
44
|
|
|
private ?int $thirdPartyClientId = null; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var ShipmentDiscountCardId|null |
|
48
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Service\Shipment\ShipmentDiscountCardId") |
|
49
|
|
|
*/ |
|
50
|
|
|
private ?ShipmentDiscountCardId $discountCardId = null; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var BankAccount|null |
|
54
|
|
|
* @Serializer\Type("VasilDakov\Speedy\Model\BankAccount") |
|
55
|
|
|
*/ |
|
56
|
|
|
private ?BankAccount $senderBankAccount = null; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param string|null $courierServicePayer |
|
60
|
|
|
*/ |
|
61
|
2 |
|
public function __construct(string $courierServicePayer) |
|
62
|
|
|
{ |
|
63
|
2 |
|
$this->setCourierServicePayer($courierServicePayer); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string |
|
68
|
|
|
*/ |
|
69
|
5 |
|
public function setCourierServicePayer(string $courierServicePayer) |
|
70
|
|
|
{ |
|
71
|
5 |
|
$this->courierServicePayer = $courierServicePayer; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
3 |
|
public function getCourierServicePayer(): string |
|
78
|
|
|
{ |
|
79
|
3 |
|
return $this->courierServicePayer; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param string|null $declaredValuePayer |
|
84
|
|
|
* @return $this |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function setDeclaredValuePayer(?string $declaredValuePayer = null): self |
|
87
|
|
|
{ |
|
88
|
1 |
|
$this->declaredValuePayer = $declaredValuePayer; |
|
89
|
|
|
|
|
90
|
1 |
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return string|null |
|
95
|
|
|
*/ |
|
96
|
3 |
|
public function getDeclaredValuePayer(): ?string |
|
97
|
|
|
{ |
|
98
|
3 |
|
return $this->declaredValuePayer; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param string $packagePayer |
|
103
|
|
|
* @return $this |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function setPackagePayer(string $packagePayer): self |
|
106
|
|
|
{ |
|
107
|
1 |
|
$this->packagePayer = $packagePayer; |
|
108
|
|
|
|
|
109
|
1 |
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
/** |
|
112
|
|
|
* @return string|null |
|
113
|
|
|
*/ |
|
114
|
3 |
|
public function getPackagePayer(): ?string |
|
115
|
|
|
{ |
|
116
|
3 |
|
return $this->packagePayer; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param int|null $thirdPartyClientId |
|
121
|
|
|
* @return $this |
|
122
|
|
|
*/ |
|
123
|
1 |
|
public function setThirdPartyClientId(?int $thirdPartyClientId): self |
|
124
|
|
|
{ |
|
125
|
1 |
|
$this->thirdPartyClientId = $thirdPartyClientId; |
|
126
|
|
|
|
|
127
|
1 |
|
return $this; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return int|null |
|
132
|
|
|
*/ |
|
133
|
1 |
|
public function getThirdPartyClientId(): ?int |
|
134
|
|
|
{ |
|
135
|
1 |
|
return $this->thirdPartyClientId; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param ShipmentDiscountCardId|null $discountCardId |
|
140
|
|
|
* @return ShipmentPayment |
|
141
|
|
|
*/ |
|
142
|
1 |
|
public function setDiscountCardId(ShipmentDiscountCardId $discountCardId = null): self |
|
143
|
|
|
{ |
|
144
|
1 |
|
$this->discountCardId = $discountCardId; |
|
145
|
|
|
|
|
146
|
1 |
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return ShipmentDiscountCardId|null |
|
151
|
|
|
*/ |
|
152
|
1 |
|
public function getDiscountCardId(): ?ShipmentDiscountCardId |
|
153
|
|
|
{ |
|
154
|
1 |
|
return $this->discountCardId; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @param BankAccount|null $bankAccount |
|
159
|
|
|
* @return $this |
|
160
|
|
|
*/ |
|
161
|
1 |
|
public function setSenderBankAccount(BankAccount $bankAccount = null): self |
|
162
|
|
|
{ |
|
163
|
1 |
|
$this->senderBankAccount = $bankAccount; |
|
164
|
|
|
|
|
165
|
1 |
|
return $this; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* @return BankAccount|null |
|
170
|
|
|
*/ |
|
171
|
1 |
|
public function getSenderBankAccount(): ?BankAccount |
|
172
|
|
|
{ |
|
173
|
1 |
|
return $this->senderBankAccount; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @return array |
|
178
|
|
|
*/ |
|
179
|
3 |
|
public function toArray(): array |
|
180
|
|
|
{ |
|
181
|
3 |
|
$data = [ |
|
182
|
3 |
|
Speedy::COURIER_SERVICE_PAYER => $this->getCourierServicePayer() |
|
183
|
3 |
|
]; |
|
184
|
|
|
|
|
185
|
3 |
|
if (null !== $this->declaredValuePayer) { |
|
186
|
3 |
|
$data[Speedy::DECLARED_VALUE_PAYER] = $this->getDeclaredValuePayer(); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
3 |
|
if (null !== $this->packagePayer) { |
|
190
|
3 |
|
$data[Speedy::PACKAGE_PAYER] = $this->getPackagePayer(); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
3 |
|
if (null !== $this->thirdPartyClientId) { |
|
194
|
1 |
|
$data[Speedy::THIRD_PARTY_CLIENT_ID] = $this->getThirdPartyClientId(); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
3 |
|
if (null !== $this->discountCardId) { |
|
198
|
1 |
|
$data[Speedy::DISCOUNT_CARD_ID] = $this->getDiscountCardId(); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
3 |
|
if (null !== $this->senderBankAccount) { |
|
202
|
1 |
|
$data[Speedy::SENDER_BANK_ACCOUNT] = $this->getSenderBankAccount(); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
3 |
|
return $data; |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|