Test Failed
Pull Request — develop (#620)
by Barbara
25:46
created

setItemShippingAddressCustomField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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\Carts\Command\CartAddCustomLineItemAction;
8
use Commercetools\Core\Request\Carts\Command\CartAddDiscountCodeAction;
9
use Commercetools\Core\Request\Carts\Command\CartAddItemShippingAddressAction;
10
use Commercetools\Core\Request\Carts\Command\CartAddLineItemAction;
11
use Commercetools\Core\Request\Carts\Command\CartAddPaymentAction;
12
use Commercetools\Core\Request\Carts\Command\CartAddShoppingListAction;
13
use Commercetools\Core\Request\Carts\Command\CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction;
14
use Commercetools\Core\Request\Carts\Command\CartApplyDeltaToLineItemShippingDetailsTargetsAction;
15
use Commercetools\Core\Request\Carts\Command\CartChangeCustomLineItemMoneyAction;
16
use Commercetools\Core\Request\Carts\Command\CartChangeCustomLineItemQuantityAction;
17
use Commercetools\Core\Request\Carts\Command\CartChangeLineItemQuantityAction;
18
use Commercetools\Core\Request\Carts\Command\CartChangeTaxCalculationModeAction;
19
use Commercetools\Core\Request\Carts\Command\CartChangeTaxModeAction;
20
use Commercetools\Core\Request\Carts\Command\CartChangeTaxRoundingModeAction;
21
use Commercetools\Core\Request\Carts\Command\CartRecalculateAction;
22
use Commercetools\Core\Request\Carts\Command\CartRemoveCustomLineItemAction;
23
use Commercetools\Core\Request\Carts\Command\CartRemoveDiscountCodeAction;
24
use Commercetools\Core\Request\Carts\Command\CartRemoveItemShippingAddressAction;
25
use Commercetools\Core\Request\Carts\Command\CartRemoveLineItemAction;
26
use Commercetools\Core\Request\Carts\Command\CartRemovePaymentAction;
27
use Commercetools\Core\Request\Carts\Command\CartSetAnonymousIdAction;
28
use Commercetools\Core\Request\Carts\Command\CartSetBillingAddressAction;
29
use Commercetools\Core\Request\Carts\Command\CartSetBillingAddressCustomFieldAction;
30
use Commercetools\Core\Request\Carts\Command\CartSetBillingAddressCustomTypeAction;
31
use Commercetools\Core\Request\Carts\Command\CartSetCartTotalTaxAction;
32
use Commercetools\Core\Request\Carts\Command\CartSetCountryAction;
33
use Commercetools\Core\Request\Carts\Command\CartSetCustomFieldAction;
34
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemCustomFieldAction;
35
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemCustomTypeAction;
36
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemShippingDetailsAction;
37
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemTaxAmountAction;
38
use Commercetools\Core\Request\Carts\Command\CartSetCustomLineItemTaxRateAction;
39
use Commercetools\Core\Request\Carts\Command\CartSetCustomShippingMethodAction;
40
use Commercetools\Core\Request\Carts\Command\CartSetCustomTypeAction;
41
use Commercetools\Core\Request\Carts\Command\CartSetCustomerEmailAction;
42
use Commercetools\Core\Request\Carts\Command\CartSetCustomerGroupAction;
43
use Commercetools\Core\Request\Carts\Command\CartSetCustomerIdAction;
44
use Commercetools\Core\Request\Carts\Command\CartSetDeleteDaysAfterLastModificationAction;
45
use Commercetools\Core\Request\Carts\Command\CartSetItemShippingAddressCustomFieldAction;
46
use Commercetools\Core\Request\Carts\Command\CartSetItemShippingAddressCustomTypeAction;
47
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomFieldAction;
48
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomTypeAction;
49
use Commercetools\Core\Request\Carts\Command\CartSetLineItemPriceAction;
50
use Commercetools\Core\Request\Carts\Command\CartSetLineItemShippingDetailsAction;
51
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTaxAmountAction;
52
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTaxRateAction;
53
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTotalPriceAction;
54
use Commercetools\Core\Request\Carts\Command\CartSetLocaleAction;
55
use Commercetools\Core\Request\Carts\Command\CartSetShippingAddressAction;
56
use Commercetools\Core\Request\Carts\Command\CartSetShippingAddressCustomFieldAction;
57
use Commercetools\Core\Request\Carts\Command\CartSetShippingAddressCustomTypeAction;
58
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodAction;
59
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodTaxAmountAction;
60
use Commercetools\Core\Request\Carts\Command\CartSetShippingMethodTaxRateAction;
61
use Commercetools\Core\Request\Carts\Command\CartSetShippingRateInputAction;
62
use Commercetools\Core\Request\Carts\Command\CartUpdateItemShippingAddressAction;
63
64
class CartsActionBuilder
65
{
66
    private $actions = [];
67 1
68
    /**
69 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-customlineitem
70 1
     * @param CartAddCustomLineItemAction|callable $action
71
     * @return $this
72
     */
73
    public function addCustomLineItem($action = null)
74
    {
75
        $this->addAction($this->resolveAction(CartAddCustomLineItemAction::class, $action));
76
        return $this;
77
    }
78 1
79
    /**
80 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-discountcode
81 1
     * @param CartAddDiscountCodeAction|callable $action
82
     * @return $this
83
     */
84
    public function addDiscountCode($action = null)
85
    {
86
        $this->addAction($this->resolveAction(CartAddDiscountCodeAction::class, $action));
87
        return $this;
88
    }
89 1
90
    /**
91 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-itemshippingaddress
92 1
     * @param CartAddItemShippingAddressAction|callable $action
93
     * @return $this
94
     */
95
    public function addItemShippingAddress($action = null)
96
    {
97
        $this->addAction($this->resolveAction(CartAddItemShippingAddressAction::class, $action));
98
        return $this;
99
    }
100 1
101
    /**
102 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-lineitem
103 1
     * @param CartAddLineItemAction|callable $action
104
     * @return $this
105
     */
106
    public function addLineItem($action = null)
107
    {
108
        $this->addAction($this->resolveAction(CartAddLineItemAction::class, $action));
109
        return $this;
110
    }
111 1
112
    /**
113 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-payment
114 1
     * @param CartAddPaymentAction|callable $action
115
     * @return $this
116
     */
117
    public function addPayment($action = null)
118
    {
119
        $this->addAction($this->resolveAction(CartAddPaymentAction::class, $action));
120
        return $this;
121
    }
122 1
123
    /**
124 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#add-shoppinglist
125 1
     * @param CartAddShoppingListAction|callable $action
126
     * @return $this
127
     */
128
    public function addShoppingList($action = null)
129
    {
130
        $this->addAction($this->resolveAction(CartAddShoppingListAction::class, $action));
131
        return $this;
132
    }
133 1
134
    /**
135
     * @link https://docs.commercetools.com/http-api-projects-carts.html#apply-deltatocustomlineitemshippingdetailstargets
136 1
     * @param CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction|callable $action
137 1
     * @return $this
138
     */
139
    public function applyDeltaToCustomLineItemShippingDetailsTargets($action = null)
140
    {
141
        // phpcs:ignore
142
        $this->addAction($this->resolveAction(CartApplyDeltaToCustomLineItemShippingDetailsTargetsAction::class, $action));
143
        return $this;
144
    }
145 1
146
    /**
147 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#apply-deltatolineitemshippingdetailstargets
148 1
     * @param CartApplyDeltaToLineItemShippingDetailsTargetsAction|callable $action
149
     * @return $this
150
     */
151
    public function applyDeltaToLineItemShippingDetailsTargets($action = null)
152
    {
153
        $this->addAction($this->resolveAction(CartApplyDeltaToLineItemShippingDetailsTargetsAction::class, $action));
154
        return $this;
155
    }
156 1
157
    /**
158 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-customlineitem-money
159 1
     * @param CartChangeCustomLineItemMoneyAction|callable $action
160
     * @return $this
161
     */
162
    public function changeCustomLineItemMoney($action = null)
163
    {
164
        $this->addAction($this->resolveAction(CartChangeCustomLineItemMoneyAction::class, $action));
165
        return $this;
166
    }
167 1
168
    /**
169 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-customlineitem-quantity
170 1
     * @param CartChangeCustomLineItemQuantityAction|callable $action
171
     * @return $this
172
     */
173
    public function changeCustomLineItemQuantity($action = null)
174
    {
175
        $this->addAction($this->resolveAction(CartChangeCustomLineItemQuantityAction::class, $action));
176
        return $this;
177
    }
178 1
179
    /**
180 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-lineitem-quantity
181 1
     * @param CartChangeLineItemQuantityAction|callable $action
182
     * @return $this
183
     */
184
    public function changeLineItemQuantity($action = null)
185
    {
186
        $this->addAction($this->resolveAction(CartChangeLineItemQuantityAction::class, $action));
187
        return $this;
188
    }
189 1
190
    /**
191 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-tax-calculationmode
192 1
     * @param CartChangeTaxCalculationModeAction|callable $action
193
     * @return $this
194
     */
195
    public function changeTaxCalculationMode($action = null)
196
    {
197
        $this->addAction($this->resolveAction(CartChangeTaxCalculationModeAction::class, $action));
198
        return $this;
199
    }
200 1
201
    /**
202 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-taxmode
203 1
     * @param CartChangeTaxModeAction|callable $action
204
     * @return $this
205
     */
206
    public function changeTaxMode($action = null)
207
    {
208
        $this->addAction($this->resolveAction(CartChangeTaxModeAction::class, $action));
209
        return $this;
210
    }
211 1
212
    /**
213 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#change-tax-roundingmode
214 1
     * @param CartChangeTaxRoundingModeAction|callable $action
215
     * @return $this
216
     */
217
    public function changeTaxRoundingMode($action = null)
218
    {
219
        $this->addAction($this->resolveAction(CartChangeTaxRoundingModeAction::class, $action));
220
        return $this;
221
    }
222 1
223
    /**
224 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#recalculate
225 1
     * @param CartRecalculateAction|callable $action
226
     * @return $this
227
     */
228
    public function recalculate($action = null)
229
    {
230
        $this->addAction($this->resolveAction(CartRecalculateAction::class, $action));
231
        return $this;
232
    }
233 1
234
    /**
235 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#remove-customlineitem
236 1
     * @param CartRemoveCustomLineItemAction|callable $action
237
     * @return $this
238
     */
239
    public function removeCustomLineItem($action = null)
240
    {
241
        $this->addAction($this->resolveAction(CartRemoveCustomLineItemAction::class, $action));
242
        return $this;
243
    }
244 1
245
    /**
246 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#remove-discountcode
247 1
     * @param CartRemoveDiscountCodeAction|callable $action
248
     * @return $this
249
     */
250
    public function removeDiscountCode($action = null)
251
    {
252
        $this->addAction($this->resolveAction(CartRemoveDiscountCodeAction::class, $action));
253
        return $this;
254
    }
255 1
256
    /**
257 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#remove-itemshippingaddress
258 1
     * @param CartRemoveItemShippingAddressAction|callable $action
259
     * @return $this
260
     */
261
    public function removeItemShippingAddress($action = null)
262
    {
263
        $this->addAction($this->resolveAction(CartRemoveItemShippingAddressAction::class, $action));
264
        return $this;
265
    }
266 1
267
    /**
268 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#remove-lineitem
269 1
     * @param CartRemoveLineItemAction|callable $action
270
     * @return $this
271
     */
272
    public function removeLineItem($action = null)
273
    {
274
        $this->addAction($this->resolveAction(CartRemoveLineItemAction::class, $action));
275
        return $this;
276
    }
277 1
278
    /**
279 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#remove-payment
280 1
     * @param CartRemovePaymentAction|callable $action
281
     * @return $this
282
     */
283
    public function removePayment($action = null)
284
    {
285
        $this->addAction($this->resolveAction(CartRemovePaymentAction::class, $action));
286
        return $this;
287
    }
288 1
289
    /**
290 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-anonymous-id
291 1
     * @param CartSetAnonymousIdAction|callable $action
292
     * @return $this
293
     */
294
    public function setAnonymousId($action = null)
295
    {
296
        $this->addAction($this->resolveAction(CartSetAnonymousIdAction::class, $action));
297
        return $this;
298
    }
299 1
300
    /**
301 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-billing-address
302 1
     * @param CartSetBillingAddressAction|callable $action
303
     * @return $this
304
     */
305
    public function setBillingAddress($action = null)
306
    {
307
        $this->addAction($this->resolveAction(CartSetBillingAddressAction::class, $action));
308
        return $this;
309
    }
310 1
311
    /**
312 1
     *
313 1
     * @param CartSetBillingAddressCustomFieldAction|callable $action
314
     * @return $this
315
     */
316
    public function setBillingAddressCustomField($action = null)
317
    {
318
        $this->addAction($this->resolveAction(CartSetBillingAddressCustomFieldAction::class, $action));
319
        return $this;
320
    }
321 1
322
    /**
323 1
     *
324 1
     * @param CartSetBillingAddressCustomTypeAction|callable $action
325
     * @return $this
326
     */
327
    public function setBillingAddressCustomType($action = null)
328
    {
329
        $this->addAction($this->resolveAction(CartSetBillingAddressCustomTypeAction::class, $action));
330
        return $this;
331
    }
332 1
333
    /**
334 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-cart-total-tax
335 1
     * @param CartSetCartTotalTaxAction|callable $action
336
     * @return $this
337
     */
338
    public function setCartTotalTax($action = null)
339
    {
340
        $this->addAction($this->resolveAction(CartSetCartTotalTaxAction::class, $action));
341
        return $this;
342
    }
343 1
344
    /**
345 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-country
346 1
     * @param CartSetCountryAction|callable $action
347
     * @return $this
348
     */
349
    public function setCountry($action = null)
350
    {
351
        $this->addAction($this->resolveAction(CartSetCountryAction::class, $action));
352
        return $this;
353
    }
354 1
355
    /**
356 1
     *
357 1
     * @param CartSetCustomFieldAction|callable $action
358
     * @return $this
359
     */
360
    public function setCustomField($action = null)
361
    {
362
        $this->addAction($this->resolveAction(CartSetCustomFieldAction::class, $action));
363
        return $this;
364
    }
365 1
366
    /**
367 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitem-customfield
368 1
     * @param CartSetCustomLineItemCustomFieldAction|callable $action
369
     * @return $this
370
     */
371
    public function setCustomLineItemCustomField($action = null)
372
    {
373
        $this->addAction($this->resolveAction(CartSetCustomLineItemCustomFieldAction::class, $action));
374
        return $this;
375
    }
376 1
377
    /**
378 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitem-custom-type
379 1
     * @param CartSetCustomLineItemCustomTypeAction|callable $action
380
     * @return $this
381
     */
382
    public function setCustomLineItemCustomType($action = null)
383
    {
384
        $this->addAction($this->resolveAction(CartSetCustomLineItemCustomTypeAction::class, $action));
385
        return $this;
386
    }
387 1
388
    /**
389 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitemshippingdetails
390 1
     * @param CartSetCustomLineItemShippingDetailsAction|callable $action
391
     * @return $this
392
     */
393
    public function setCustomLineItemShippingDetails($action = null)
394
    {
395
        $this->addAction($this->resolveAction(CartSetCustomLineItemShippingDetailsAction::class, $action));
396
        return $this;
397
    }
398 1
399
    /**
400 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitem-taxamount
401 1
     * @param CartSetCustomLineItemTaxAmountAction|callable $action
402
     * @return $this
403
     */
404
    public function setCustomLineItemTaxAmount($action = null)
405
    {
406
        $this->addAction($this->resolveAction(CartSetCustomLineItemTaxAmountAction::class, $action));
407
        return $this;
408
    }
409 1
410
    /**
411 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitem-taxrate
412 1
     * @param CartSetCustomLineItemTaxRateAction|callable $action
413
     * @return $this
414
     */
415
    public function setCustomLineItemTaxRate($action = null)
416
    {
417
        $this->addAction($this->resolveAction(CartSetCustomLineItemTaxRateAction::class, $action));
418
        return $this;
419
    }
420 1
421
    /**
422 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-custom-shippingmethod
423 1
     * @param CartSetCustomShippingMethodAction|callable $action
424
     * @return $this
425
     */
426
    public function setCustomShippingMethod($action = null)
427
    {
428
        $this->addAction($this->resolveAction(CartSetCustomShippingMethodAction::class, $action));
429
        return $this;
430
    }
431 1
432
    /**
433 1
     *
434 1
     * @param CartSetCustomTypeAction|callable $action
435
     * @return $this
436
     */
437
    public function setCustomType($action = null)
438
    {
439
        $this->addAction($this->resolveAction(CartSetCustomTypeAction::class, $action));
440
        return $this;
441
    }
442 1
443
    /**
444 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customer-email
445 1
     * @param CartSetCustomerEmailAction|callable $action
446
     * @return $this
447
     */
448
    public function setCustomerEmail($action = null)
449
    {
450
        $this->addAction($this->resolveAction(CartSetCustomerEmailAction::class, $action));
451
        return $this;
452
    }
453 1
454
    /**
455 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customer-group
456 1
     * @param CartSetCustomerGroupAction|callable $action
457
     * @return $this
458
     */
459
    public function setCustomerGroup($action = null)
460
    {
461
        $this->addAction($this->resolveAction(CartSetCustomerGroupAction::class, $action));
462
        return $this;
463
    }
464 1
465
    /**
466 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customer-id
467 1
     * @param CartSetCustomerIdAction|callable $action
468
     * @return $this
469
     */
470
    public function setCustomerId($action = null)
471
    {
472
        $this->addAction($this->resolveAction(CartSetCustomerIdAction::class, $action));
473
        return $this;
474
    }
475 1
476
    /**
477 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-deletedaysafterlastmodification-beta
478 1
     * @param CartSetDeleteDaysAfterLastModificationAction|callable $action
479
     * @return $this
480
     */
481
    public function setDeleteDaysAfterLastModification($action = null)
482
    {
483
        $this->addAction($this->resolveAction(CartSetDeleteDaysAfterLastModificationAction::class, $action));
484
        return $this;
485
    }
486 1
487
    /**
488 1
     *
489 1
     * @param CartSetItemShippingAddressCustomFieldAction|callable $action
490
     * @return $this
491
     */
492
    public function setItemShippingAddressCustomField($action = null)
493
    {
494
        $this->addAction($this->resolveAction(CartSetItemShippingAddressCustomFieldAction::class, $action));
495
        return $this;
496
    }
497 1
498
    /**
499 1
     *
500 1
     * @param CartSetItemShippingAddressCustomTypeAction|callable $action
501
     * @return $this
502
     */
503
    public function setItemShippingAddressCustomType($action = null)
504
    {
505
        $this->addAction($this->resolveAction(CartSetItemShippingAddressCustomTypeAction::class, $action));
506
        return $this;
507
    }
508 1
509
    /**
510 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-customfield
511 1
     * @param CartSetLineItemCustomFieldAction|callable $action
512
     * @return $this
513
     */
514
    public function setLineItemCustomField($action = null)
515
    {
516
        $this->addAction($this->resolveAction(CartSetLineItemCustomFieldAction::class, $action));
517
        return $this;
518
    }
519 1
520
    /**
521 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-customlineitem-custom-type
522 1
     * @param CartSetLineItemCustomTypeAction|callable $action
523
     * @return $this
524
     */
525
    public function setLineItemCustomType($action = null)
526
    {
527
        $this->addAction($this->resolveAction(CartSetLineItemCustomTypeAction::class, $action));
528
        return $this;
529
    }
530 1
531
    /**
532 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-totalprice
533 1
     * @param CartSetLineItemPriceAction|callable $action
534
     * @return $this
535
     */
536
    public function setLineItemPrice($action = null)
537
    {
538
        $this->addAction($this->resolveAction(CartSetLineItemPriceAction::class, $action));
539
        return $this;
540
    }
541 1
542
    /**
543 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-totalprice
544 1
     * @param CartSetLineItemShippingDetailsAction|callable $action
545
     * @return $this
546
     */
547
    public function setLineItemShippingDetails($action = null)
548
    {
549
        $this->addAction($this->resolveAction(CartSetLineItemShippingDetailsAction::class, $action));
550
        return $this;
551
    }
552 1
553
    /**
554 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-taxamount
555 1
     * @param CartSetLineItemTaxAmountAction|callable $action
556
     * @return $this
557
     */
558
    public function setLineItemTaxAmount($action = null)
559
    {
560
        $this->addAction($this->resolveAction(CartSetLineItemTaxAmountAction::class, $action));
561
        return $this;
562
    }
563 1
564
    /**
565 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-taxrate
566 1
     * @param CartSetLineItemTaxRateAction|callable $action
567
     * @return $this
568
     */
569
    public function setLineItemTaxRate($action = null)
570
    {
571
        $this->addAction($this->resolveAction(CartSetLineItemTaxRateAction::class, $action));
572
        return $this;
573
    }
574 1
575
    /**
576 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-totalprice
577 1
     * @param CartSetLineItemTotalPriceAction|callable $action
578
     * @return $this
579
     */
580
    public function setLineItemTotalPrice($action = null)
581
    {
582
        $this->addAction($this->resolveAction(CartSetLineItemTotalPriceAction::class, $action));
583
        return $this;
584
    }
585 1
586
    /**
587 1
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-locale
588 1
     * @param CartSetLocaleAction|callable $action
589
     * @return $this
590
     */
591
    public function setLocale($action = null)
592
    {
593
        $this->addAction($this->resolveAction(CartSetLocaleAction::class, $action));
594
        return $this;
595
    }
596
597 1
    /**
598
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-shipping-address
599 1
     * @param CartSetShippingAddressAction|callable $action
600 1
     * @return $this
601
     */
602
    public function setShippingAddress($action = null)
603
    {
604
        $this->addAction($this->resolveAction(CartSetShippingAddressAction::class, $action));
605
        return $this;
606
    }
607
608 1
    /**
609
     *
610 1
     * @param CartSetShippingAddressCustomFieldAction|callable $action
611 1
     * @return $this
612
     */
613
    public function setShippingAddressCustomField($action = null)
614
    {
615
        $this->addAction($this->resolveAction(CartSetShippingAddressCustomFieldAction::class, $action));
616
        return $this;
617
    }
618
619
    /**
620
     *
621
     * @param CartSetShippingAddressCustomTypeAction|callable $action
622
     * @return $this
623
     */
624
    public function setShippingAddressCustomType($action = null)
625
    {
626
        $this->addAction($this->resolveAction(CartSetShippingAddressCustomTypeAction::class, $action));
627
        return $this;
628 50
    }
629
630 50
    /**
631 50
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-shippingmethod
632 50
     * @param CartSetShippingMethodAction|callable $action
633 50
     * @return $this
634
     */
635 50
    public function setShippingMethod($action = null)
636 50
    {
637
        $this->addAction($this->resolveAction(CartSetShippingMethodAction::class, $action));
638
        return $this;
639
    }
640
641
    /**
642
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-shippingmethod-taxamount
643
     * @param CartSetShippingMethodTaxAmountAction|callable $action
644
     * @return $this
645
     */
646
    public function setShippingMethodTaxAmount($action = null)
647
    {
648 50
        $this->addAction($this->resolveAction(CartSetShippingMethodTaxAmountAction::class, $action));
649
        return $this;
650 50
    }
651
652
    /**
653 50
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-shippingmethod-taxrate
654
     * @param CartSetShippingMethodTaxRateAction|callable $action
655
     * @return $this
656
     */
657
    public function setShippingMethodTaxRate($action = null)
658
    {
659
        $this->addAction($this->resolveAction(CartSetShippingMethodTaxRateAction::class, $action));
660 50
        return $this;
661
    }
662 50
663 50
    /**
664
     * @link https://dev.commercetools.com/http-api-projects-carts.html#set-shippingrateinput
665
     * @link https://docs.commercetools.com/http-api-projects-carts.html#set-shippingrateinput
666
     * @param CartSetShippingRateInputAction|callable $action
667
     * @return $this
668
     */
669 50
    public function setShippingRateInput($action = null)
670
    {
671 50
        $this->addAction($this->resolveAction(CartSetShippingRateInputAction::class, $action));
672
        return $this;
673
    }
674
675
    /**
676
     * @link https://docs.commercetools.com/http-api-projects-carts.html#update-itemshippingaddress
677
     * @param CartUpdateItemShippingAddressAction|callable $action
678
     * @return $this
679
     */
680
    public function updateItemShippingAddress($action = null)
681
    {
682
        $this->addAction($this->resolveAction(CartUpdateItemShippingAddressAction::class, $action));
683
        return $this;
684
    }
685
686
    /**
687
     * @return CartsActionBuilder
688
     */
689
    public static function of()
690
    {
691
        return new self();
692
    }
693
694
    /**
695
     * @param $class
696
     * @param $action
697
     * @return AbstractAction
698
     * @throws InvalidArgumentException
699
     */
700
    private function resolveAction($class, $action = null)
701
    {
702
        if (is_null($action) || is_callable($action)) {
703
            $callback = $action;
704
            $emptyAction = $class::of();
705
            $action = $this->callback($emptyAction, $callback);
706
        }
707
        if ($action instanceof $class) {
708
            return $action;
709
        }
710
        throw new InvalidArgumentException(
711
            sprintf('Expected method to be called with or callable to return %s', $class)
712
        );
713
    }
714
715
    /**
716
     * @param $action
717
     * @param callable $callback
718
     * @return AbstractAction
719
     */
720
    private function callback($action, callable $callback = null)
721
    {
722
        if (!is_null($callback)) {
723
            $action = $callback($action);
724
        }
725
        return $action;
726
    }
727
728
    /**
729
     * @param AbstractAction $action
730
     * @return $this;
731
     */
732
    public function addAction(AbstractAction $action)
733
    {
734
        $this->actions[] = $action;
735
        return $this;
736
    }
737
738
    /**
739
     * @return array
740
     */
741
    public function getActions()
742
    {
743
        return $this->actions;
744
    }
745
746
747
    /**
748
     * @param array $actions
749
     * @return $this
750
     */
751
    public function setActions(array $actions)
752
    {
753
        $this->actions = $actions;
754
        return $this;
755
    }
756
}
757