1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ups\Entity; |
4
|
|
|
|
5
|
|
|
use DOMDocument; |
6
|
|
|
use DOMElement; |
7
|
|
|
use Ups\NodeInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ShipmentServiceOptions |
11
|
|
|
* @package Ups\Entity |
12
|
|
|
*/ |
13
|
|
|
// @todo Refactor to private properties |
14
|
|
|
class ShipmentServiceOptions implements NodeInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var |
18
|
|
|
*/ |
19
|
|
|
public $SaturdayPickup; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var |
23
|
|
|
*/ |
24
|
|
|
public $SaturdayDelivery; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var |
28
|
|
|
*/ |
29
|
|
|
public $COD; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var CallTagARS |
33
|
|
|
*/ |
34
|
|
|
public $CallTagARS; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var |
38
|
|
|
*/ |
39
|
|
|
public $NegotiatedRatesIndicator; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var |
43
|
|
|
*/ |
44
|
|
|
public $DirectDeliveryOnlyIndicator; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var |
48
|
|
|
*/ |
49
|
|
|
public $DeliverToAddresseeOnlyIndicator; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var |
53
|
|
|
*/ |
54
|
|
|
private $internationalForms; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var array |
58
|
|
|
*/ |
59
|
|
|
private $notifications = []; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param null $response |
63
|
|
|
*/ |
64
|
1 |
|
public function __construct($response = null) |
65
|
|
|
{ |
66
|
1 |
|
$this->CallTagARS = new CallTagARS(); |
67
|
|
|
|
68
|
1 |
|
if (null != $response) { |
69
|
|
|
if (isset($response->SaturdayPickup)) { |
70
|
|
|
$this->SaturdayPickup = $response->SaturdayPickup; |
71
|
|
|
} |
72
|
|
|
if (isset($response->SaturdayDelivery)) { |
73
|
|
|
$this->SaturdayDelivery = $response->SaturdayDelivery; |
74
|
|
|
} |
75
|
|
|
if (isset($response->COD)) { |
76
|
|
|
$this->COD = $response->COD; |
77
|
|
|
} |
78
|
|
|
if (isset($response->CallTagARS)) { |
79
|
|
|
$this->CallTagARS = new CallTagARS($response->CallTagARS); |
80
|
|
|
} |
81
|
|
|
if (isset($response->NegotiatedRatesIndicator)) { |
82
|
|
|
$this->NegotiatedRatesIndicator = $response->NegotiatedRatesIndicator; |
83
|
|
|
} |
84
|
|
|
if (isset($response->DirectDeliveryOnlyIndicator)) { |
85
|
|
|
$this->DirectDeliveryOnlyIndicator = $response->DirectDeliveryOnlyIndicator; |
86
|
|
|
} |
87
|
|
|
if (isset($response->DeliverToAddresseeOnlyIndicator)) { |
88
|
|
|
$this->DeliverToAddresseeOnlyIndicator = $response->DeliverToAddresseeOnlyIndicator; |
89
|
|
|
} |
90
|
|
|
if (isset($response->InternationalForms)) { |
91
|
|
|
$this->setInternationalForms($response->InternationalForms); |
92
|
|
|
} |
93
|
|
|
} |
94
|
1 |
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param null|DOMDocument $document |
98
|
|
|
* |
99
|
|
|
* @return DOMElement |
100
|
|
|
*/ |
101
|
|
|
public function toNode(DOMDocument $document = null) |
102
|
|
|
{ |
103
|
|
|
if (null === $document) { |
104
|
|
|
$document = new DOMDocument(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
$node = $document->createElement('ShipmentServiceOptions'); |
108
|
|
|
|
109
|
|
|
if (isset($this->DirectDeliveryOnlyIndicator)) { |
110
|
|
|
$node->appendChild($document->createElement('DirectDeliveryOnlyIndicator')); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
if (isset($this->DeliverToAddresseeOnlyIndicator)) { |
114
|
|
|
$node->appendChild($document->createElement('DeliverToAddresseeOnlyIndicator')); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
if (isset($this->SaturdayPickup)) { |
118
|
|
|
$node->appendChild($document->createElement('SaturdayPickup')); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
if (isset($this->SaturdayDelivery)) { |
122
|
|
|
$node->appendChild($document->createElement('SaturdayDelivery')); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
if ($this->getCOD()) { |
126
|
|
|
$node->appendChild($this->getCOD()->toNode($document)); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
if (isset($this->internationalForms)) { |
130
|
|
|
$node->appendChild($this->internationalForms->toNode($document)); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
if (!empty($this->notifications)) { |
134
|
|
|
foreach ($this->notifications as $notification) { |
135
|
|
|
$node->appendChild($notification->toNode($document)); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return $node; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param InternationalForms $data |
144
|
|
|
*/ |
145
|
|
|
public function setInternationalForms(InternationalForms $data) |
146
|
|
|
{ |
147
|
|
|
$this->internationalForms = $data; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return mixed |
152
|
|
|
*/ |
153
|
|
|
public function getInternationalForms() |
154
|
|
|
{ |
155
|
|
|
return $this->internationalForms; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param Notification $notification |
160
|
|
|
*/ |
161
|
|
|
public function addNotification(Notification $notification) |
162
|
|
|
{ |
163
|
|
|
$this->notifications[] = $notification; |
164
|
|
|
|
165
|
|
|
if (count($this->notifications) > 3) { |
166
|
|
|
throw new \Exception('Maximum 3 notifications allowed'); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return array |
174
|
|
|
*/ |
175
|
|
|
public function getNotifications() |
176
|
|
|
{ |
177
|
|
|
return $this->notifications; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return mixed |
182
|
|
|
*/ |
183
|
|
|
public function getSaturdayPickup() |
184
|
|
|
{ |
185
|
|
|
return $this->SaturdayPickup; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param mixed $SaturdayPickup |
190
|
|
|
* @return ShipmentServiceOptions |
191
|
|
|
*/ |
192
|
|
|
public function setSaturdayPickup($SaturdayPickup) |
193
|
|
|
{ |
194
|
|
|
$this->SaturdayPickup = $SaturdayPickup; |
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return mixed |
200
|
|
|
*/ |
201
|
|
|
public function getSaturdayDelivery() |
202
|
|
|
{ |
203
|
|
|
return $this->SaturdayDelivery; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param mixed $SaturdayDelivery |
208
|
|
|
* @return ShipmentServiceOptions |
209
|
|
|
*/ |
210
|
|
|
public function setSaturdayDelivery($SaturdayDelivery) |
211
|
|
|
{ |
212
|
|
|
$this->SaturdayDelivery = $SaturdayDelivery; |
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return mixed |
218
|
|
|
*/ |
219
|
|
|
public function getCOD() |
220
|
|
|
{ |
221
|
|
|
return $this->COD; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param mixed $COD |
226
|
|
|
* @return ShipmentServiceOptions |
227
|
|
|
*/ |
228
|
|
|
public function setCOD($COD) |
229
|
|
|
{ |
230
|
|
|
$this->COD = $COD; |
231
|
|
|
return $this; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return CallTagARS |
237
|
|
|
*/ |
238
|
|
|
public function getCallTagARS() |
239
|
|
|
{ |
240
|
|
|
return $this->CallTagARS; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param CallTagARS $CallTagARS |
245
|
|
|
* @return ShipmentServiceOptions |
246
|
|
|
*/ |
247
|
|
|
public function setCallTagARS($CallTagARS) |
248
|
|
|
{ |
249
|
|
|
$this->CallTagARS = $CallTagARS; |
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @return boolean |
255
|
|
|
*/ |
256
|
|
|
public function isNegotiatedRatesIndicator() |
257
|
|
|
{ |
258
|
|
|
return $this->NegotiatedRatesIndicator; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @param boolean $NegotiatedRatesIndicator |
263
|
|
|
* @return ShipmentServiceOptions |
264
|
|
|
*/ |
265
|
|
|
public function setNegotiatedRatesIndicator($NegotiatedRatesIndicator) |
266
|
|
|
{ |
267
|
|
|
$this->NegotiatedRatesIndicator = $NegotiatedRatesIndicator; |
268
|
|
|
return $this; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* @return boolean |
273
|
|
|
*/ |
274
|
|
|
public function isDirectDeliveryOnlyIndicator() |
275
|
|
|
{ |
276
|
|
|
return $this->DirectDeliveryOnlyIndicator; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @param boolean $DirectDeliveryOnlyIndicator |
281
|
|
|
* @return ShipmentServiceOptions |
282
|
|
|
*/ |
283
|
|
|
public function setDirectDeliveryOnlyIndicator($DirectDeliveryOnlyIndicator) |
284
|
|
|
{ |
285
|
|
|
$this->DirectDeliveryOnlyIndicator = $DirectDeliveryOnlyIndicator; |
286
|
|
|
return $this; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
/** |
290
|
|
|
* @return mixed |
291
|
|
|
*/ |
292
|
|
|
public function getDeliverToAddresseeOnlyIndicator() |
293
|
|
|
{ |
294
|
|
|
return $this->DeliverToAddresseeOnlyIndicator; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @param mixed $DeliverToAddresseeOnlyIndicator |
299
|
|
|
* @return ShipmentServiceOptions |
300
|
|
|
*/ |
301
|
|
|
public function setDeliverToAddresseeOnlyIndicator($DeliverToAddresseeOnlyIndicator) |
302
|
|
|
{ |
303
|
|
|
$this->DeliverToAddresseeOnlyIndicator = $DeliverToAddresseeOnlyIndicator; |
304
|
|
|
return $this; |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|