1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Commercetools\Core\Builder\Update; |
4
|
|
|
|
5
|
|
|
use Commercetools\Core\Error\InvalidArgumentException; |
6
|
|
|
use Commercetools\Core\Request\AbstractAction; |
7
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderAddDeliveryAction; |
8
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderAddItemShippingAddressAction; |
9
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderAddParcelToDeliveryAction; |
10
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderAddPaymentAction; |
11
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderAddReturnInfoAction; |
12
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderChangeOrderStateAction; |
13
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderChangePaymentStateAction; |
14
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderChangeShipmentStateAction; |
15
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderImportCustomLineItemStateAction; |
16
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderImportLineItemStateAction; |
17
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderRemoveDeliveryAction; |
18
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderRemoveItemShippingAddressAction; |
19
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderRemoveParcelFromDeliveryAction; |
20
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderRemovePaymentAction; |
21
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetBillingAddress; |
22
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomFieldAction; |
23
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomFieldAction; |
24
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomTypeAction; |
25
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemShippingDetailsAction; |
26
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomTypeAction; |
27
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerEmail; |
28
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerIdAction; |
29
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressAction; |
30
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryItemsAction; |
31
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomFieldAction; |
32
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomTypeAction; |
33
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemShippingDetailsAction; |
34
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetLocaleAction; |
35
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetOrderNumberAction; |
36
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetParcelItemsAction; |
37
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetParcelMeasurementsAction; |
38
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetParcelTrackingDataAction; |
39
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetReturnPaymentStateAction; |
40
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetReturnShipmentStateAction; |
41
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddress; |
42
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderSetStoreAction; |
43
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderTransitionCustomLineItemStateAction; |
44
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderTransitionLineItemStateAction; |
45
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderTransitionStateAction; |
46
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderUpdateItemShippingAddressAction; |
47
|
|
|
use Commercetools\Core\Request\Orders\Command\OrderUpdateSyncInfoAction; |
48
|
|
|
|
49
|
|
|
class OrdersActionBuilder |
50
|
|
|
{ |
51
|
|
|
private $actions = []; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#add-delivery |
55
|
|
|
* @param OrderAddDeliveryAction|callable $action |
56
|
|
|
* @return $this |
57
|
|
|
*/ |
58
|
1 |
|
public function addDelivery($action = null) |
59
|
|
|
{ |
60
|
1 |
|
$this->addAction($this->resolveAction(OrderAddDeliveryAction::class, $action)); |
61
|
1 |
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#add-itemshippingaddress |
66
|
|
|
* @param OrderAddItemShippingAddressAction|callable $action |
67
|
|
|
* @return $this |
68
|
|
|
*/ |
69
|
1 |
|
public function addItemShippingAddress($action = null) |
70
|
|
|
{ |
71
|
1 |
|
$this->addAction($this->resolveAction(OrderAddItemShippingAddressAction::class, $action)); |
72
|
1 |
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#add-parcel |
77
|
|
|
* @param OrderAddParcelToDeliveryAction|callable $action |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
1 |
|
public function addParcelToDelivery($action = null) |
81
|
|
|
{ |
82
|
1 |
|
$this->addAction($this->resolveAction(OrderAddParcelToDeliveryAction::class, $action)); |
83
|
1 |
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#add-payment |
88
|
|
|
* @param OrderAddPaymentAction|callable $action |
89
|
|
|
* @return $this |
90
|
|
|
*/ |
91
|
1 |
|
public function addPayment($action = null) |
92
|
|
|
{ |
93
|
1 |
|
$this->addAction($this->resolveAction(OrderAddPaymentAction::class, $action)); |
94
|
1 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#addreturninfo |
99
|
|
|
* @param OrderAddReturnInfoAction|callable $action |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
1 |
|
public function addReturnInfo($action = null) |
103
|
|
|
{ |
104
|
1 |
|
$this->addAction($this->resolveAction(OrderAddReturnInfoAction::class, $action)); |
105
|
1 |
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#change-orderstate |
110
|
|
|
* @param OrderChangeOrderStateAction|callable $action |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
1 |
|
public function changeOrderState($action = null) |
114
|
|
|
{ |
115
|
1 |
|
$this->addAction($this->resolveAction(OrderChangeOrderStateAction::class, $action)); |
116
|
1 |
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#change-paymentstate |
121
|
|
|
* @param OrderChangePaymentStateAction|callable $action |
122
|
|
|
* @return $this |
123
|
|
|
*/ |
124
|
1 |
|
public function changePaymentState($action = null) |
125
|
|
|
{ |
126
|
1 |
|
$this->addAction($this->resolveAction(OrderChangePaymentStateAction::class, $action)); |
127
|
1 |
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#change-shipmentstate |
132
|
|
|
* @param OrderChangeShipmentStateAction|callable $action |
133
|
|
|
* @return $this |
134
|
|
|
*/ |
135
|
1 |
|
public function changeShipmentState($action = null) |
136
|
|
|
{ |
137
|
1 |
|
$this->addAction($this->resolveAction(OrderChangeShipmentStateAction::class, $action)); |
138
|
1 |
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-customlineitems |
143
|
|
|
* @param OrderImportCustomLineItemStateAction|callable $action |
144
|
|
|
* @return $this |
145
|
|
|
*/ |
146
|
1 |
|
public function importCustomLineItemState($action = null) |
147
|
|
|
{ |
148
|
1 |
|
$this->addAction($this->resolveAction(OrderImportCustomLineItemStateAction::class, $action)); |
149
|
1 |
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-lineitems |
154
|
|
|
* @param OrderImportLineItemStateAction|callable $action |
155
|
|
|
* @return $this |
156
|
|
|
*/ |
157
|
1 |
|
public function importLineItemState($action = null) |
158
|
|
|
{ |
159
|
1 |
|
$this->addAction($this->resolveAction(OrderImportLineItemStateAction::class, $action)); |
160
|
1 |
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#remove-delivery |
165
|
|
|
* @param OrderRemoveDeliveryAction|callable $action |
166
|
|
|
* @return $this |
167
|
|
|
*/ |
168
|
1 |
|
public function removeDelivery($action = null) |
169
|
|
|
{ |
170
|
1 |
|
$this->addAction($this->resolveAction(OrderRemoveDeliveryAction::class, $action)); |
171
|
1 |
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#remove-itemshippingaddress |
176
|
|
|
* @param OrderRemoveItemShippingAddressAction|callable $action |
177
|
|
|
* @return $this |
178
|
|
|
*/ |
179
|
1 |
|
public function removeItemShippingAddress($action = null) |
180
|
|
|
{ |
181
|
1 |
|
$this->addAction($this->resolveAction(OrderRemoveItemShippingAddressAction::class, $action)); |
182
|
1 |
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#remove-parcel-from-delivery |
187
|
|
|
* @param OrderRemoveParcelFromDeliveryAction|callable $action |
188
|
|
|
* @return $this |
189
|
|
|
*/ |
190
|
1 |
|
public function removeParcelFromDelivery($action = null) |
191
|
|
|
{ |
192
|
1 |
|
$this->addAction($this->resolveAction(OrderRemoveParcelFromDeliveryAction::class, $action)); |
193
|
1 |
|
return $this; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#remove-payment |
198
|
|
|
* @param OrderRemovePaymentAction|callable $action |
199
|
|
|
* @return $this |
200
|
|
|
*/ |
201
|
1 |
|
public function removePayment($action = null) |
202
|
|
|
{ |
203
|
1 |
|
$this->addAction($this->resolveAction(OrderRemovePaymentAction::class, $action)); |
204
|
1 |
|
return $this; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-billing-address |
209
|
|
|
* @param OrderSetBillingAddress|callable $action |
210
|
|
|
* @return $this |
211
|
|
|
*/ |
212
|
1 |
|
public function setBillingAddress($action = null) |
213
|
|
|
{ |
214
|
1 |
|
$this->addAction($this->resolveAction(OrderSetBillingAddress::class, $action)); |
215
|
1 |
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* |
220
|
|
|
* @param OrderSetCustomFieldAction|callable $action |
221
|
|
|
* @return $this |
222
|
|
|
*/ |
223
|
1 |
|
public function setCustomField($action = null) |
224
|
|
|
{ |
225
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomFieldAction::class, $action)); |
226
|
1 |
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* |
231
|
|
|
* @param OrderSetCustomLineItemCustomFieldAction|callable $action |
232
|
|
|
* @return $this |
233
|
|
|
*/ |
234
|
1 |
|
public function setCustomLineItemCustomField($action = null) |
235
|
|
|
{ |
236
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomLineItemCustomFieldAction::class, $action)); |
237
|
1 |
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* |
242
|
|
|
* @param OrderSetCustomLineItemCustomTypeAction|callable $action |
243
|
|
|
* @return $this |
244
|
|
|
*/ |
245
|
1 |
|
public function setCustomLineItemCustomType($action = null) |
246
|
|
|
{ |
247
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomLineItemCustomTypeAction::class, $action)); |
248
|
1 |
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-customlineitemshippingdetails |
253
|
|
|
* @param OrderSetCustomLineItemShippingDetailsAction|callable $action |
254
|
|
|
* @return $this |
255
|
|
|
*/ |
256
|
1 |
|
public function setCustomLineItemShippingDetails($action = null) |
257
|
|
|
{ |
258
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomLineItemShippingDetailsAction::class, $action)); |
259
|
1 |
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* |
264
|
|
|
* @param OrderSetCustomTypeAction|callable $action |
265
|
|
|
* @return $this |
266
|
|
|
*/ |
267
|
1 |
|
public function setCustomType($action = null) |
268
|
|
|
{ |
269
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomTypeAction::class, $action)); |
270
|
1 |
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-email |
275
|
|
|
* @param OrderSetCustomerEmail|callable $action |
276
|
|
|
* @return $this |
277
|
|
|
*/ |
278
|
1 |
|
public function setCustomerEmail($action = null) |
279
|
|
|
{ |
280
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomerEmail::class, $action)); |
281
|
1 |
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-id |
286
|
|
|
* @param OrderSetCustomerIdAction|callable $action |
287
|
|
|
* @return $this |
288
|
|
|
*/ |
289
|
1 |
|
public function setCustomerId($action = null) |
290
|
|
|
{ |
291
|
1 |
|
$this->addAction($this->resolveAction(OrderSetCustomerIdAction::class, $action)); |
292
|
1 |
|
return $this; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-address |
297
|
|
|
* @param OrderSetDeliveryAddressAction|callable $action |
298
|
|
|
* @return $this |
299
|
|
|
*/ |
300
|
1 |
|
public function setDeliveryAddress($action = null) |
301
|
|
|
{ |
302
|
1 |
|
$this->addAction($this->resolveAction(OrderSetDeliveryAddressAction::class, $action)); |
303
|
1 |
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-items |
308
|
|
|
* @param OrderSetDeliveryItemsAction|callable $action |
309
|
|
|
* @return $this |
310
|
|
|
*/ |
311
|
1 |
|
public function setDeliveryItems($action = null) |
312
|
|
|
{ |
313
|
1 |
|
$this->addAction($this->resolveAction(OrderSetDeliveryItemsAction::class, $action)); |
314
|
1 |
|
return $this; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* |
319
|
|
|
* @param OrderSetLineItemCustomFieldAction|callable $action |
320
|
|
|
* @return $this |
321
|
|
|
*/ |
322
|
1 |
|
public function setLineItemCustomField($action = null) |
323
|
|
|
{ |
324
|
1 |
|
$this->addAction($this->resolveAction(OrderSetLineItemCustomFieldAction::class, $action)); |
325
|
1 |
|
return $this; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* |
330
|
|
|
* @param OrderSetLineItemCustomTypeAction|callable $action |
331
|
|
|
* @return $this |
332
|
|
|
*/ |
333
|
1 |
|
public function setLineItemCustomType($action = null) |
334
|
|
|
{ |
335
|
1 |
|
$this->addAction($this->resolveAction(OrderSetLineItemCustomTypeAction::class, $action)); |
336
|
1 |
|
return $this; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-lineitemshippingdetails |
341
|
|
|
* @param OrderSetLineItemShippingDetailsAction|callable $action |
342
|
|
|
* @return $this |
343
|
|
|
*/ |
344
|
1 |
|
public function setLineItemShippingDetails($action = null) |
345
|
|
|
{ |
346
|
1 |
|
$this->addAction($this->resolveAction(OrderSetLineItemShippingDetailsAction::class, $action)); |
347
|
1 |
|
return $this; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-locale |
352
|
|
|
* @param OrderSetLocaleAction|callable $action |
353
|
|
|
* @return $this |
354
|
|
|
*/ |
355
|
1 |
|
public function setLocale($action = null) |
356
|
|
|
{ |
357
|
1 |
|
$this->addAction($this->resolveAction(OrderSetLocaleAction::class, $action)); |
358
|
1 |
|
return $this; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-order-number |
363
|
|
|
* @param OrderSetOrderNumberAction|callable $action |
364
|
|
|
* @return $this |
365
|
|
|
*/ |
366
|
1 |
|
public function setOrderNumber($action = null) |
367
|
|
|
{ |
368
|
1 |
|
$this->addAction($this->resolveAction(OrderSetOrderNumberAction::class, $action)); |
369
|
1 |
|
return $this; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-items |
374
|
|
|
* @param OrderSetParcelItemsAction|callable $action |
375
|
|
|
* @return $this |
376
|
|
|
*/ |
377
|
1 |
|
public function setParcelItems($action = null) |
378
|
|
|
{ |
379
|
1 |
|
$this->addAction($this->resolveAction(OrderSetParcelItemsAction::class, $action)); |
380
|
1 |
|
return $this; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-measurements |
385
|
|
|
* @param OrderSetParcelMeasurementsAction|callable $action |
386
|
|
|
* @return $this |
387
|
|
|
*/ |
388
|
1 |
|
public function setParcelMeasurements($action = null) |
389
|
|
|
{ |
390
|
1 |
|
$this->addAction($this->resolveAction(OrderSetParcelMeasurementsAction::class, $action)); |
391
|
1 |
|
return $this; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-tracking-data |
396
|
|
|
* @param OrderSetParcelTrackingDataAction|callable $action |
397
|
|
|
* @return $this |
398
|
|
|
*/ |
399
|
1 |
|
public function setParcelTrackingData($action = null) |
400
|
|
|
{ |
401
|
1 |
|
$this->addAction($this->resolveAction(OrderSetParcelTrackingDataAction::class, $action)); |
402
|
1 |
|
return $this; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnpaymentstate |
407
|
|
|
* @param OrderSetReturnPaymentStateAction|callable $action |
408
|
|
|
* @return $this |
409
|
|
|
*/ |
410
|
1 |
|
public function setReturnPaymentState($action = null) |
411
|
|
|
{ |
412
|
1 |
|
$this->addAction($this->resolveAction(OrderSetReturnPaymentStateAction::class, $action)); |
413
|
1 |
|
return $this; |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnshipmentstate |
418
|
|
|
* @param OrderSetReturnShipmentStateAction|callable $action |
419
|
|
|
* @return $this |
420
|
|
|
*/ |
421
|
1 |
|
public function setReturnShipmentState($action = null) |
422
|
|
|
{ |
423
|
1 |
|
$this->addAction($this->resolveAction(OrderSetReturnShipmentStateAction::class, $action)); |
424
|
1 |
|
return $this; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-shipping-address |
429
|
|
|
* @param OrderSetShippingAddress|callable $action |
430
|
|
|
* @return $this |
431
|
|
|
*/ |
432
|
1 |
|
public function setShippingAddress($action = null) |
433
|
|
|
{ |
434
|
1 |
|
$this->addAction($this->resolveAction(OrderSetShippingAddress::class, $action)); |
435
|
1 |
|
return $this; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-store-beta |
440
|
|
|
* @param OrderSetStoreAction|callable $action |
441
|
|
|
* @return $this |
442
|
|
|
*/ |
443
|
1 |
|
public function setStore($action = null) |
444
|
|
|
{ |
445
|
1 |
|
$this->addAction($this->resolveAction(OrderSetStoreAction::class, $action)); |
446
|
1 |
|
return $this; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-customlineitem-according-to-allowed-transitions |
451
|
|
|
* @param OrderTransitionCustomLineItemStateAction|callable $action |
452
|
|
|
* @return $this |
453
|
|
|
*/ |
454
|
1 |
|
public function transitionCustomLineItemState($action = null) |
455
|
|
|
{ |
456
|
1 |
|
$this->addAction($this->resolveAction(OrderTransitionCustomLineItemStateAction::class, $action)); |
457
|
1 |
|
return $this; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-lineitem-according-to-allowed-transitions |
462
|
|
|
* @param OrderTransitionLineItemStateAction|callable $action |
463
|
|
|
* @return $this |
464
|
|
|
*/ |
465
|
1 |
|
public function transitionLineItemState($action = null) |
466
|
|
|
{ |
467
|
1 |
|
$this->addAction($this->resolveAction(OrderTransitionLineItemStateAction::class, $action)); |
468
|
1 |
|
return $this; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#transition-state |
473
|
|
|
* @param OrderTransitionStateAction|callable $action |
474
|
|
|
* @return $this |
475
|
|
|
*/ |
476
|
1 |
|
public function transitionState($action = null) |
477
|
|
|
{ |
478
|
1 |
|
$this->addAction($this->resolveAction(OrderTransitionStateAction::class, $action)); |
479
|
1 |
|
return $this; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
/** |
483
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#update-itemshippingaddress |
484
|
|
|
* @param OrderUpdateItemShippingAddressAction|callable $action |
485
|
|
|
* @return $this |
486
|
|
|
*/ |
487
|
1 |
|
public function updateItemShippingAddress($action = null) |
488
|
|
|
{ |
489
|
1 |
|
$this->addAction($this->resolveAction(OrderUpdateItemShippingAddressAction::class, $action)); |
490
|
1 |
|
return $this; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* @link https://docs.commercetools.com/http-api-projects-orders.html#update-syncinfo |
495
|
|
|
* @param OrderUpdateSyncInfoAction|callable $action |
496
|
|
|
* @return $this |
497
|
|
|
*/ |
498
|
1 |
|
public function updateSyncInfo($action = null) |
499
|
|
|
{ |
500
|
1 |
|
$this->addAction($this->resolveAction(OrderUpdateSyncInfoAction::class, $action)); |
501
|
1 |
|
return $this; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* @return OrdersActionBuilder |
506
|
|
|
*/ |
507
|
|
|
public static function of() |
508
|
|
|
{ |
509
|
|
|
return new self(); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* @param $class |
514
|
|
|
* @param $action |
515
|
|
|
* @return AbstractAction |
516
|
|
|
* @throws InvalidArgumentException |
517
|
|
|
*/ |
518
|
41 |
|
private function resolveAction($class, $action = null) |
519
|
|
|
{ |
520
|
41 |
|
if (is_null($action) || is_callable($action)) { |
521
|
41 |
|
$callback = $action; |
522
|
41 |
|
$emptyAction = $class::of(); |
523
|
41 |
|
$action = $this->callback($emptyAction, $callback); |
524
|
|
|
} |
525
|
41 |
|
if ($action instanceof $class) { |
526
|
41 |
|
return $action; |
527
|
|
|
} |
528
|
|
|
throw new InvalidArgumentException( |
529
|
|
|
sprintf('Expected method to be called with or callable to return %s', $class) |
530
|
|
|
); |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* @param $action |
535
|
|
|
* @param callable $callback |
536
|
|
|
* @return AbstractAction |
537
|
|
|
*/ |
538
|
41 |
|
private function callback($action, callable $callback = null) |
539
|
|
|
{ |
540
|
41 |
|
if (!is_null($callback)) { |
541
|
|
|
$action = $callback($action); |
542
|
|
|
} |
543
|
41 |
|
return $action; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* @param AbstractAction $action |
548
|
|
|
* @return $this; |
549
|
|
|
*/ |
550
|
41 |
|
public function addAction(AbstractAction $action) |
551
|
|
|
{ |
552
|
41 |
|
$this->actions[] = $action; |
553
|
41 |
|
return $this; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* @return array |
558
|
|
|
*/ |
559
|
41 |
|
public function getActions() |
560
|
|
|
{ |
561
|
41 |
|
return $this->actions; |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
|
565
|
|
|
/** |
566
|
|
|
* @param array $actions |
567
|
|
|
* @return $this |
568
|
|
|
*/ |
569
|
|
|
public function setActions(array $actions) |
570
|
|
|
{ |
571
|
|
|
$this->actions = $actions; |
572
|
|
|
return $this; |
573
|
|
|
} |
574
|
|
|
} |
575
|
|
|
|