Test Failed
Push — master ( 1e3420...0ee68c )
by Jens
52:59 queued 29:30
created

OrdersActionBuilder::setParcelCustomField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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\OrderSetBillingAddressCustomFieldAction;
23
use Commercetools\Core\Request\Orders\Command\OrderSetBillingAddressCustomTypeAction;
24
use Commercetools\Core\Request\Orders\Command\OrderSetCustomFieldAction;
25
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomFieldAction;
26
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemCustomTypeAction;
27
use Commercetools\Core\Request\Orders\Command\OrderSetCustomLineItemShippingDetailsAction;
28
use Commercetools\Core\Request\Orders\Command\OrderSetCustomTypeAction;
29
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerEmail;
30
use Commercetools\Core\Request\Orders\Command\OrderSetCustomerIdAction;
31
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressAction;
32
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressCustomFieldAction;
33
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryAddressCustomTypeAction;
34
use Commercetools\Core\Request\Orders\Command\OrderSetDeliveryItemsAction;
35
use Commercetools\Core\Request\Orders\Command\OrderSetItemShippingAddressCustomFieldAction;
36
use Commercetools\Core\Request\Orders\Command\OrderSetItemShippingAddressCustomTypeAction;
37
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomFieldAction;
38
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemCustomTypeAction;
39
use Commercetools\Core\Request\Orders\Command\OrderSetLineItemShippingDetailsAction;
40
use Commercetools\Core\Request\Orders\Command\OrderSetLocaleAction;
41
use Commercetools\Core\Request\Orders\Command\OrderSetOrderNumberAction;
42
use Commercetools\Core\Request\Orders\Command\OrderSetParcelCustomFieldAction;
43
use Commercetools\Core\Request\Orders\Command\OrderSetParcelCustomTypeAction;
44
use Commercetools\Core\Request\Orders\Command\OrderSetParcelItemsAction;
45
use Commercetools\Core\Request\Orders\Command\OrderSetParcelMeasurementsAction;
46
use Commercetools\Core\Request\Orders\Command\OrderSetParcelTrackingDataAction;
47
use Commercetools\Core\Request\Orders\Command\OrderSetReturnInfoAction;
48
use Commercetools\Core\Request\Orders\Command\OrderSetReturnItemCustomFieldAction;
49
use Commercetools\Core\Request\Orders\Command\OrderSetReturnItemCustomTypeAction;
50
use Commercetools\Core\Request\Orders\Command\OrderSetReturnPaymentStateAction;
51
use Commercetools\Core\Request\Orders\Command\OrderSetReturnShipmentStateAction;
52
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddress;
53
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddressCustomFieldAction;
54
use Commercetools\Core\Request\Orders\Command\OrderSetShippingAddressCustomTypeAction;
55
use Commercetools\Core\Request\Orders\Command\OrderSetStoreAction;
56
use Commercetools\Core\Request\Orders\Command\OrderTransitionCustomLineItemStateAction;
57
use Commercetools\Core\Request\Orders\Command\OrderTransitionLineItemStateAction;
58 1
use Commercetools\Core\Request\Orders\Command\OrderTransitionStateAction;
59
use Commercetools\Core\Request\Orders\Command\OrderUpdateItemShippingAddressAction;
60 1
use Commercetools\Core\Request\Orders\Command\OrderUpdateSyncInfoAction;
61 1
62
class OrdersActionBuilder
63
{
64
    private $actions = [];
65
66
    /**
67
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-delivery
68
     * @param OrderAddDeliveryAction|callable $action
69 1
     * @return $this
70
     */
71 1
    public function addDelivery($action = null)
72 1
    {
73
        $this->addAction($this->resolveAction(OrderAddDeliveryAction::class, $action));
74
        return $this;
75
    }
76
77
    /**
78
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-itemshippingaddress
79
     * @param OrderAddItemShippingAddressAction|callable $action
80 1
     * @return $this
81
     */
82 1
    public function addItemShippingAddress($action = null)
83 1
    {
84
        $this->addAction($this->resolveAction(OrderAddItemShippingAddressAction::class, $action));
85
        return $this;
86
    }
87
88
    /**
89
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-parcel
90
     * @param OrderAddParcelToDeliveryAction|callable $action
91 1
     * @return $this
92
     */
93 1
    public function addParcelToDelivery($action = null)
94 1
    {
95
        $this->addAction($this->resolveAction(OrderAddParcelToDeliveryAction::class, $action));
96
        return $this;
97
    }
98
99
    /**
100
     * @link https://docs.commercetools.com/http-api-projects-orders.html#add-payment
101
     * @param OrderAddPaymentAction|callable $action
102 1
     * @return $this
103
     */
104 1
    public function addPayment($action = null)
105 1
    {
106
        $this->addAction($this->resolveAction(OrderAddPaymentAction::class, $action));
107
        return $this;
108
    }
109
110
    /**
111
     * @link https://docs.commercetools.com/http-api-projects-orders.html#addreturninfo
112
     * @param OrderAddReturnInfoAction|callable $action
113 1
     * @return $this
114
     */
115 1
    public function addReturnInfo($action = null)
116 1
    {
117
        $this->addAction($this->resolveAction(OrderAddReturnInfoAction::class, $action));
118
        return $this;
119
    }
120
121
    /**
122
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-orderstate
123
     * @param OrderChangeOrderStateAction|callable $action
124 1
     * @return $this
125
     */
126 1
    public function changeOrderState($action = null)
127 1
    {
128
        $this->addAction($this->resolveAction(OrderChangeOrderStateAction::class, $action));
129
        return $this;
130
    }
131
132
    /**
133
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-paymentstate
134
     * @param OrderChangePaymentStateAction|callable $action
135 1
     * @return $this
136
     */
137 1
    public function changePaymentState($action = null)
138 1
    {
139
        $this->addAction($this->resolveAction(OrderChangePaymentStateAction::class, $action));
140
        return $this;
141
    }
142
143
    /**
144
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-shipmentstate
145
     * @param OrderChangeShipmentStateAction|callable $action
146 1
     * @return $this
147
     */
148 1
    public function changeShipmentState($action = null)
149 1
    {
150
        $this->addAction($this->resolveAction(OrderChangeShipmentStateAction::class, $action));
151
        return $this;
152
    }
153
154
    /**
155
     * @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-customlineitems
156
     * @param OrderImportCustomLineItemStateAction|callable $action
157 1
     * @return $this
158
     */
159 1
    public function importCustomLineItemState($action = null)
160 1
    {
161
        $this->addAction($this->resolveAction(OrderImportCustomLineItemStateAction::class, $action));
162
        return $this;
163
    }
164
165
    /**
166
     * @link https://docs.commercetools.com/http-api-projects-orders.html#import-state-for-lineitems
167
     * @param OrderImportLineItemStateAction|callable $action
168 1
     * @return $this
169
     */
170 1
    public function importLineItemState($action = null)
171 1
    {
172
        $this->addAction($this->resolveAction(OrderImportLineItemStateAction::class, $action));
173
        return $this;
174
    }
175
176
    /**
177
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-delivery
178
     * @param OrderRemoveDeliveryAction|callable $action
179 1
     * @return $this
180
     */
181 1
    public function removeDelivery($action = null)
182 1
    {
183
        $this->addAction($this->resolveAction(OrderRemoveDeliveryAction::class, $action));
184
        return $this;
185
    }
186
187
    /**
188
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-itemshippingaddress
189
     * @param OrderRemoveItemShippingAddressAction|callable $action
190 1
     * @return $this
191
     */
192 1
    public function removeItemShippingAddress($action = null)
193 1
    {
194
        $this->addAction($this->resolveAction(OrderRemoveItemShippingAddressAction::class, $action));
195
        return $this;
196
    }
197
198
    /**
199
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-parcel-from-delivery
200
     * @param OrderRemoveParcelFromDeliveryAction|callable $action
201 1
     * @return $this
202
     */
203 1
    public function removeParcelFromDelivery($action = null)
204 1
    {
205
        $this->addAction($this->resolveAction(OrderRemoveParcelFromDeliveryAction::class, $action));
206
        return $this;
207
    }
208
209
    /**
210
     * @link https://docs.commercetools.com/http-api-projects-orders.html#remove-payment
211
     * @param OrderRemovePaymentAction|callable $action
212 1
     * @return $this
213
     */
214 1
    public function removePayment($action = null)
215 1
    {
216
        $this->addAction($this->resolveAction(OrderRemovePaymentAction::class, $action));
217
        return $this;
218
    }
219
220
    /**
221
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-billing-address
222
     * @param OrderSetBillingAddress|callable $action
223 1
     * @return $this
224
     */
225 1
    public function setBillingAddress($action = null)
226 1
    {
227
        $this->addAction($this->resolveAction(OrderSetBillingAddress::class, $action));
228
        return $this;
229
    }
230
231
    /**
232
     *
233
     * @param OrderSetBillingAddressCustomFieldAction|callable $action
234 1
     * @return $this
235
     */
236 1
    public function setBillingAddressCustomField($action = null)
237 1
    {
238
        $this->addAction($this->resolveAction(OrderSetBillingAddressCustomFieldAction::class, $action));
239
        return $this;
240
    }
241
242
    /**
243
     *
244
     * @param OrderSetBillingAddressCustomTypeAction|callable $action
245 1
     * @return $this
246
     */
247 1
    public function setBillingAddressCustomType($action = null)
248 1
    {
249
        $this->addAction($this->resolveAction(OrderSetBillingAddressCustomTypeAction::class, $action));
250
        return $this;
251
    }
252
253
    /**
254
     *
255
     * @param OrderSetCustomFieldAction|callable $action
256 1
     * @return $this
257
     */
258 1
    public function setCustomField($action = null)
259 1
    {
260
        $this->addAction($this->resolveAction(OrderSetCustomFieldAction::class, $action));
261
        return $this;
262
    }
263
264
    /**
265
     *
266
     * @param OrderSetCustomLineItemCustomFieldAction|callable $action
267 1
     * @return $this
268
     */
269 1
    public function setCustomLineItemCustomField($action = null)
270 1
    {
271
        $this->addAction($this->resolveAction(OrderSetCustomLineItemCustomFieldAction::class, $action));
272
        return $this;
273
    }
274
275
    /**
276
     *
277
     * @param OrderSetCustomLineItemCustomTypeAction|callable $action
278 1
     * @return $this
279
     */
280 1
    public function setCustomLineItemCustomType($action = null)
281 1
    {
282
        $this->addAction($this->resolveAction(OrderSetCustomLineItemCustomTypeAction::class, $action));
283
        return $this;
284
    }
285
286
    /**
287
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customlineitemshippingdetails
288
     * @param OrderSetCustomLineItemShippingDetailsAction|callable $action
289 1
     * @return $this
290
     */
291 1
    public function setCustomLineItemShippingDetails($action = null)
292 1
    {
293
        $this->addAction($this->resolveAction(OrderSetCustomLineItemShippingDetailsAction::class, $action));
294
        return $this;
295
    }
296
297
    /**
298
     *
299
     * @param OrderSetCustomTypeAction|callable $action
300 1
     * @return $this
301
     */
302 1
    public function setCustomType($action = null)
303 1
    {
304
        $this->addAction($this->resolveAction(OrderSetCustomTypeAction::class, $action));
305
        return $this;
306
    }
307
308
    /**
309
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-email
310
     * @param OrderSetCustomerEmail|callable $action
311 1
     * @return $this
312
     */
313 1
    public function setCustomerEmail($action = null)
314 1
    {
315
        $this->addAction($this->resolveAction(OrderSetCustomerEmail::class, $action));
316
        return $this;
317
    }
318
319
    /**
320
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-id
321
     * @param OrderSetCustomerIdAction|callable $action
322 1
     * @return $this
323
     */
324 1
    public function setCustomerId($action = null)
325 1
    {
326
        $this->addAction($this->resolveAction(OrderSetCustomerIdAction::class, $action));
327
        return $this;
328
    }
329
330
    /**
331
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-address
332
     * @param OrderSetDeliveryAddressAction|callable $action
333 1
     * @return $this
334
     */
335 1
    public function setDeliveryAddress($action = null)
336 1
    {
337
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressAction::class, $action));
338
        return $this;
339
    }
340
341
    /**
342
     *
343
     * @param OrderSetDeliveryAddressCustomFieldAction|callable $action
344 1
     * @return $this
345
     */
346 1
    public function setDeliveryAddressCustomField($action = null)
347 1
    {
348
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressCustomFieldAction::class, $action));
349
        return $this;
350
    }
351
352
    /**
353
     *
354
     * @param OrderSetDeliveryAddressCustomTypeAction|callable $action
355 1
     * @return $this
356
     */
357 1
    public function setDeliveryAddressCustomType($action = null)
358 1
    {
359
        $this->addAction($this->resolveAction(OrderSetDeliveryAddressCustomTypeAction::class, $action));
360
        return $this;
361
    }
362
363
    /**
364
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-items
365
     * @param OrderSetDeliveryItemsAction|callable $action
366 1
     * @return $this
367
     */
368 1
    public function setDeliveryItems($action = null)
369 1
    {
370
        $this->addAction($this->resolveAction(OrderSetDeliveryItemsAction::class, $action));
371
        return $this;
372
    }
373
374
    /**
375
     *
376
     * @param OrderSetItemShippingAddressCustomFieldAction|callable $action
377 1
     * @return $this
378
     */
379 1
    public function setItemShippingAddressCustomField($action = null)
380 1
    {
381
        $this->addAction($this->resolveAction(OrderSetItemShippingAddressCustomFieldAction::class, $action));
382
        return $this;
383
    }
384
385
    /**
386
     *
387
     * @param OrderSetItemShippingAddressCustomTypeAction|callable $action
388 1
     * @return $this
389
     */
390 1
    public function setItemShippingAddressCustomType($action = null)
391 1
    {
392
        $this->addAction($this->resolveAction(OrderSetItemShippingAddressCustomTypeAction::class, $action));
393
        return $this;
394
    }
395
396
    /**
397
     *
398
     * @param OrderSetLineItemCustomFieldAction|callable $action
399 1
     * @return $this
400
     */
401 1
    public function setLineItemCustomField($action = null)
402 1
    {
403
        $this->addAction($this->resolveAction(OrderSetLineItemCustomFieldAction::class, $action));
404
        return $this;
405
    }
406
407
    /**
408
     *
409
     * @param OrderSetLineItemCustomTypeAction|callable $action
410 1
     * @return $this
411
     */
412 1
    public function setLineItemCustomType($action = null)
413 1
    {
414
        $this->addAction($this->resolveAction(OrderSetLineItemCustomTypeAction::class, $action));
415
        return $this;
416
    }
417
418
    /**
419
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-lineitemshippingdetails
420
     * @param OrderSetLineItemShippingDetailsAction|callable $action
421 1
     * @return $this
422
     */
423 1
    public function setLineItemShippingDetails($action = null)
424 1
    {
425
        $this->addAction($this->resolveAction(OrderSetLineItemShippingDetailsAction::class, $action));
426
        return $this;
427
    }
428
429
    /**
430
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-locale
431
     * @param OrderSetLocaleAction|callable $action
432 1
     * @return $this
433
     */
434 1
    public function setLocale($action = null)
435 1
    {
436
        $this->addAction($this->resolveAction(OrderSetLocaleAction::class, $action));
437
        return $this;
438
    }
439
440
    /**
441
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-order-number
442
     * @param OrderSetOrderNumberAction|callable $action
443 1
     * @return $this
444
     */
445 1
    public function setOrderNumber($action = null)
446 1
    {
447
        $this->addAction($this->resolveAction(OrderSetOrderNumberAction::class, $action));
448
        return $this;
449
    }
450
451
    /**
452
     *
453
     * @param OrderSetParcelCustomFieldAction|callable $action
454 1
     * @return $this
455
     */
456 1
    public function setParcelCustomField($action = null)
457 1
    {
458
        $this->addAction($this->resolveAction(OrderSetParcelCustomFieldAction::class, $action));
459
        return $this;
460
    }
461
462
    /**
463
     *
464
     * @param OrderSetParcelCustomTypeAction|callable $action
465 1
     * @return $this
466
     */
467 1
    public function setParcelCustomType($action = null)
468 1
    {
469
        $this->addAction($this->resolveAction(OrderSetParcelCustomTypeAction::class, $action));
470
        return $this;
471
    }
472
473
    /**
474
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-items
475
     * @param OrderSetParcelItemsAction|callable $action
476 1
     * @return $this
477
     */
478 1
    public function setParcelItems($action = null)
479 1
    {
480
        $this->addAction($this->resolveAction(OrderSetParcelItemsAction::class, $action));
481
        return $this;
482
    }
483
484
    /**
485
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-measurements
486
     * @param OrderSetParcelMeasurementsAction|callable $action
487 1
     * @return $this
488
     */
489 1
    public function setParcelMeasurements($action = null)
490 1
    {
491
        $this->addAction($this->resolveAction(OrderSetParcelMeasurementsAction::class, $action));
492
        return $this;
493
    }
494
495
    /**
496
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-parcel-tracking-data
497
     * @param OrderSetParcelTrackingDataAction|callable $action
498 1
     * @return $this
499
     */
500 1
    public function setParcelTrackingData($action = null)
501 1
    {
502
        $this->addAction($this->resolveAction(OrderSetParcelTrackingDataAction::class, $action));
503
        return $this;
504
    }
505
506
    /**
507
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-delivery-items
508
     * @param OrderSetReturnInfoAction|callable $action
509
     * @return $this
510
     */
511
    public function setReturnInfo($action = null)
512
    {
513
        $this->addAction($this->resolveAction(OrderSetReturnInfoAction::class, $action));
514
        return $this;
515
    }
516
517
    /**
518 41
     *
519
     * @param OrderSetReturnItemCustomFieldAction|callable $action
520 41
     * @return $this
521 41
     */
522 41
    public function setReturnItemCustomField($action = null)
523 41
    {
524
        $this->addAction($this->resolveAction(OrderSetReturnItemCustomFieldAction::class, $action));
525 41
        return $this;
526 41
    }
527
528
    /**
529
     *
530
     * @param OrderSetReturnItemCustomTypeAction|callable $action
531
     * @return $this
532
     */
533
    public function setReturnItemCustomType($action = null)
534
    {
535
        $this->addAction($this->resolveAction(OrderSetReturnItemCustomTypeAction::class, $action));
536
        return $this;
537
    }
538 41
539
    /**
540 41
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnpaymentstate
541
     * @param OrderSetReturnPaymentStateAction|callable $action
542
     * @return $this
543 41
     */
544
    public function setReturnPaymentState($action = null)
545
    {
546
        $this->addAction($this->resolveAction(OrderSetReturnPaymentStateAction::class, $action));
547
        return $this;
548
    }
549
550 41
    /**
551
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-returnshipmentstate
552 41
     * @param OrderSetReturnShipmentStateAction|callable $action
553 41
     * @return $this
554
     */
555
    public function setReturnShipmentState($action = null)
556
    {
557
        $this->addAction($this->resolveAction(OrderSetReturnShipmentStateAction::class, $action));
558
        return $this;
559 41
    }
560
561 41
    /**
562
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-shipping-address
563
     * @param OrderSetShippingAddress|callable $action
564
     * @return $this
565
     */
566
    public function setShippingAddress($action = null)
567
    {
568
        $this->addAction($this->resolveAction(OrderSetShippingAddress::class, $action));
569
        return $this;
570
    }
571
572
    /**
573
     *
574
     * @param OrderSetShippingAddressCustomFieldAction|callable $action
575
     * @return $this
576
     */
577
    public function setShippingAddressCustomField($action = null)
578
    {
579
        $this->addAction($this->resolveAction(OrderSetShippingAddressCustomFieldAction::class, $action));
580
        return $this;
581
    }
582
583
    /**
584
     *
585
     * @param OrderSetShippingAddressCustomTypeAction|callable $action
586
     * @return $this
587
     */
588
    public function setShippingAddressCustomType($action = null)
589
    {
590
        $this->addAction($this->resolveAction(OrderSetShippingAddressCustomTypeAction::class, $action));
591
        return $this;
592
    }
593
594
    /**
595
     * @link https://docs.commercetools.com/http-api-projects-orders.html#set-store-beta
596
     * @param OrderSetStoreAction|callable $action
597
     * @return $this
598
     */
599
    public function setStore($action = null)
600
    {
601
        $this->addAction($this->resolveAction(OrderSetStoreAction::class, $action));
602
        return $this;
603
    }
604
605
    /**
606
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-customlineitem-according-to-allowed-transitions
607
     * @param OrderTransitionCustomLineItemStateAction|callable $action
608
     * @return $this
609
     */
610
    public function transitionCustomLineItemState($action = null)
611
    {
612
        $this->addAction($this->resolveAction(OrderTransitionCustomLineItemStateAction::class, $action));
613
        return $this;
614
    }
615
616
    /**
617
     * @link https://docs.commercetools.com/http-api-projects-orders.html#change-the-state-of-lineitem-according-to-allowed-transitions
618
     * @param OrderTransitionLineItemStateAction|callable $action
619
     * @return $this
620
     */
621
    public function transitionLineItemState($action = null)
622
    {
623
        $this->addAction($this->resolveAction(OrderTransitionLineItemStateAction::class, $action));
624
        return $this;
625
    }
626
627
    /**
628
     * @link https://docs.commercetools.com/http-api-projects-orders.html#transition-state
629
     * @param OrderTransitionStateAction|callable $action
630
     * @return $this
631
     */
632
    public function transitionState($action = null)
633
    {
634
        $this->addAction($this->resolveAction(OrderTransitionStateAction::class, $action));
635
        return $this;
636
    }
637
638
    /**
639
     * @link https://docs.commercetools.com/http-api-projects-orders.html#update-itemshippingaddress
640
     * @param OrderUpdateItemShippingAddressAction|callable $action
641
     * @return $this
642
     */
643
    public function updateItemShippingAddress($action = null)
644
    {
645
        $this->addAction($this->resolveAction(OrderUpdateItemShippingAddressAction::class, $action));
646
        return $this;
647
    }
648
649
    /**
650
     * @link https://docs.commercetools.com/http-api-projects-orders.html#update-syncinfo
651
     * @param OrderUpdateSyncInfoAction|callable $action
652
     * @return $this
653
     */
654
    public function updateSyncInfo($action = null)
655
    {
656
        $this->addAction($this->resolveAction(OrderUpdateSyncInfoAction::class, $action));
657
        return $this;
658
    }
659
660
    /**
661
     * @return OrdersActionBuilder
662
     */
663
    public static function of()
664
    {
665
        return new self();
666
    }
667
668
    /**
669
     * @param $class
670
     * @param $action
671
     * @return AbstractAction
672
     * @throws InvalidArgumentException
673
     */
674
    private function resolveAction($class, $action = null)
675
    {
676
        if (is_null($action) || is_callable($action)) {
677
            $callback = $action;
678
            $emptyAction = $class::of();
679
            $action = $this->callback($emptyAction, $callback);
680
        }
681
        if ($action instanceof $class) {
682
            return $action;
683
        }
684
        throw new InvalidArgumentException(
685
            sprintf('Expected method to be called with or callable to return %s', $class)
686
        );
687
    }
688
689
    /**
690
     * @param $action
691
     * @param callable $callback
692
     * @return AbstractAction
693
     */
694
    private function callback($action, callable $callback = null)
695
    {
696
        if (!is_null($callback)) {
697
            $action = $callback($action);
698
        }
699
        return $action;
700
    }
701
702
    /**
703
     * @param AbstractAction $action
704
     * @return $this;
705
     */
706
    public function addAction(AbstractAction $action)
707
    {
708
        $this->actions[] = $action;
709
        return $this;
710
    }
711
712
    /**
713
     * @return array
714
     */
715
    public function getActions()
716
    {
717
        return $this->actions;
718
    }
719
720
721
    /**
722
     * @param array $actions
723
     * @return $this
724
     */
725
    public function setActions(array $actions)
726
    {
727
        $this->actions = $actions;
728
        return $this;
729
    }
730
}
731