commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CartUpdateActionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $action;
28 
33  private static $discriminatorClasses = [
34  'addCustomLineItem' => CartAddCustomLineItemActionModel::class,
35  'addCustomShippingMethod' => CartAddCustomShippingMethodActionModel::class,
36  'addDiscountCode' => CartAddDiscountCodeActionModel::class,
37  'addItemShippingAddress' => CartAddItemShippingAddressActionModel::class,
38  'addLineItem' => CartAddLineItemActionModel::class,
39  'addPayment' => CartAddPaymentActionModel::class,
40  'addShippingMethod' => CartAddShippingMethodActionModel::class,
41  'addShoppingList' => CartAddShoppingListActionModel::class,
42  'applyDeltaToCustomLineItemShippingDetailsTargets' => CartApplyDeltaToCustomLineItemShippingDetailsTargetsActionModel::class,
43  'applyDeltaToLineItemShippingDetailsTargets' => CartApplyDeltaToLineItemShippingDetailsTargetsActionModel::class,
44  'changeCustomLineItemMoney' => CartChangeCustomLineItemMoneyActionModel::class,
45  'changeCustomLineItemPriceMode' => CartChangeCustomLineItemPriceModeActionModel::class,
46  'changeCustomLineItemQuantity' => CartChangeCustomLineItemQuantityActionModel::class,
47  'changeLineItemQuantity' => CartChangeLineItemQuantityActionModel::class,
48  'changeLineItemsOrder' => CartChangeLineItemsOrderActionModel::class,
49  'changeTaxCalculationMode' => CartChangeTaxCalculationModeActionModel::class,
50  'changeTaxMode' => CartChangeTaxModeActionModel::class,
51  'changeTaxRoundingMode' => CartChangeTaxRoundingModeActionModel::class,
52  'freezeCart' => CartFreezeCartActionModel::class,
53  'recalculate' => CartRecalculateActionModel::class,
54  'removeCustomLineItem' => CartRemoveCustomLineItemActionModel::class,
55  'removeDiscountCode' => CartRemoveDiscountCodeActionModel::class,
56  'removeItemShippingAddress' => CartRemoveItemShippingAddressActionModel::class,
57  'removeLineItem' => CartRemoveLineItemActionModel::class,
58  'removePayment' => CartRemovePaymentActionModel::class,
59  'removeShippingMethod' => CartRemoveShippingMethodActionModel::class,
60  'setAnonymousId' => CartSetAnonymousIdActionModel::class,
61  'setBillingAddress' => CartSetBillingAddressActionModel::class,
62  'setBillingAddressCustomField' => CartSetBillingAddressCustomFieldActionModel::class,
63  'setBillingAddressCustomType' => CartSetBillingAddressCustomTypeActionModel::class,
64  'setBusinessUnit' => CartSetBusinessUnitActionModel::class,
65  'setCartTotalTax' => CartSetCartTotalTaxActionModel::class,
66  'setCountry' => CartSetCountryActionModel::class,
67  'setCustomField' => CartSetCustomFieldActionModel::class,
68  'setCustomLineItemCustomField' => CartSetCustomLineItemCustomFieldActionModel::class,
69  'setCustomLineItemCustomType' => CartSetCustomLineItemCustomTypeActionModel::class,
70  'setCustomLineItemShippingDetails' => CartSetCustomLineItemShippingDetailsActionModel::class,
71  'setCustomLineItemTaxAmount' => CartSetCustomLineItemTaxAmountActionModel::class,
72  'setCustomLineItemTaxRate' => CartSetCustomLineItemTaxRateActionModel::class,
73  'setCustomShippingMethod' => CartSetCustomShippingMethodActionModel::class,
74  'setCustomType' => CartSetCustomTypeActionModel::class,
75  'setCustomerEmail' => CartSetCustomerEmailActionModel::class,
76  'setCustomerGroup' => CartSetCustomerGroupActionModel::class,
77  'setCustomerId' => CartSetCustomerIdActionModel::class,
78  'setDeleteDaysAfterLastModification' => CartSetDeleteDaysAfterLastModificationActionModel::class,
79  'setDirectDiscounts' => CartSetDirectDiscountsActionModel::class,
80  'setItemShippingAddressCustomField' => CartSetItemShippingAddressCustomFieldActionModel::class,
81  'setItemShippingAddressCustomType' => CartSetItemShippingAddressCustomTypeActionModel::class,
82  'setKey' => CartSetKeyActionModel::class,
83  'setLineItemCustomField' => CartSetLineItemCustomFieldActionModel::class,
84  'setLineItemCustomType' => CartSetLineItemCustomTypeActionModel::class,
85  'setLineItemDistributionChannel' => CartSetLineItemDistributionChannelActionModel::class,
86  'setLineItemInventoryMode' => CartSetLineItemInventoryModeActionModel::class,
87  'setLineItemPrice' => CartSetLineItemPriceActionModel::class,
88  'setLineItemShippingDetails' => CartSetLineItemShippingDetailsActionModel::class,
89  'setLineItemSupplyChannel' => CartSetLineItemSupplyChannelActionModel::class,
90  'setLineItemTaxAmount' => CartSetLineItemTaxAmountActionModel::class,
91  'setLineItemTaxRate' => CartSetLineItemTaxRateActionModel::class,
92  'setLineItemTotalPrice' => CartSetLineItemTotalPriceActionModel::class,
93  'setLocale' => CartSetLocaleActionModel::class,
94  'setShippingAddress' => CartSetShippingAddressActionModel::class,
95  'setShippingAddressCustomField' => CartSetShippingAddressCustomFieldActionModel::class,
96  'setShippingAddressCustomType' => CartSetShippingAddressCustomTypeActionModel::class,
97  'setShippingCustomField' => CartSetShippingCustomFieldActionModel::class,
98  'setShippingCustomType' => CartSetShippingCustomTypeActionModel::class,
99  'setShippingMethod' => CartSetShippingMethodActionModel::class,
100  'setShippingMethodTaxAmount' => CartSetShippingMethodTaxAmountActionModel::class,
101  'setShippingMethodTaxRate' => CartSetShippingMethodTaxRateActionModel::class,
102  'setShippingRateInput' => CartSetShippingRateInputActionModel::class,
103  'unfreezeCart' => CartUnfreezeCartActionModel::class,
104  'updateItemShippingAddress' => CartUpdateItemShippingAddressActionModel::class,
105  ];
106 
110  public function __construct(
111  ?string $action = null
112  ) {
113  $this->action = $action;
114  }
115 
120  public function getAction()
121  {
122  if (is_null($this->action)) {
124  $data = $this->raw(self::FIELD_ACTION);
125  if (is_null($data)) {
126  return null;
127  }
128  $this->action = (string) $data;
129  }
130 
131  return $this->action;
132  }
133 
134 
135 
136 
137 
142  public static function resolveDiscriminatorClass($value): string
143  {
145  if (is_object($value) && isset($value->$fieldName)) {
147  $discriminatorValue = $value->$fieldName;
148  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
149  return self::$discriminatorClasses[$discriminatorValue];
150  }
151  }
152  if (is_array($value) && isset($value[$fieldName])) {
154  $discriminatorValue = $value[$fieldName];
155  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
156  return self::$discriminatorClasses[$discriminatorValue];
157  }
158  }
159 
161  $type = CartUpdateActionModel::class;
162  return $type;
163  }
164 }