commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
MyCartUpdateActionModel.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  'addDiscountCode' => MyCartAddDiscountCodeActionModel::class,
35  'addItemShippingAddress' => MyCartAddItemShippingAddressActionModel::class,
36  'addLineItem' => MyCartAddLineItemActionModel::class,
37  'addPayment' => MyCartAddPaymentActionModel::class,
38  'applyDeltaToLineItemShippingDetailsTargets' => MyCartApplyDeltaToLineItemShippingDetailsTargetsActionModel::class,
39  'changeLineItemQuantity' => MyCartChangeLineItemQuantityActionModel::class,
40  'changeLineItemsOrder' => MyCartChangeLineItemsOrderActionModel::class,
41  'changeTaxMode' => MyCartChangeTaxModeActionModel::class,
42  'recalculate' => MyCartRecalculateActionModel::class,
43  'removeDiscountCode' => MyCartRemoveDiscountCodeActionModel::class,
44  'removeItemShippingAddress' => MyCartRemoveItemShippingAddressActionModel::class,
45  'removeLineItem' => MyCartRemoveLineItemActionModel::class,
46  'removePayment' => MyCartRemovePaymentActionModel::class,
47  'setBillingAddress' => MyCartSetBillingAddressActionModel::class,
48  'setBusinessUnit' => MyCartSetBusinessUnitActionModel::class,
49  'setCountry' => MyCartSetCountryActionModel::class,
50  'setCustomField' => MyCartSetCustomFieldActionModel::class,
51  'setCustomType' => MyCartSetCustomTypeActionModel::class,
52  'setCustomerEmail' => MyCartSetCustomerEmailActionModel::class,
53  'setDeleteDaysAfterLastModification' => MyCartSetDeleteDaysAfterLastModificationActionModel::class,
54  'setLineItemCustomField' => MyCartSetLineItemCustomFieldActionModel::class,
55  'setLineItemCustomType' => MyCartSetLineItemCustomTypeActionModel::class,
56  'setLineItemDistributionChannel' => MyCartSetLineItemDistributionChannelActionModel::class,
57  'setLineItemShippingDetails' => MyCartSetLineItemShippingDetailsActionModel::class,
58  'setLineItemSupplyChannel' => MyCartSetLineItemSupplyChannelActionModel::class,
59  'setLocale' => MyCartSetLocaleActionModel::class,
60  'setShippingAddress' => MyCartSetShippingAddressActionModel::class,
61  'setShippingMethod' => MyCartSetShippingMethodActionModel::class,
62  'updateItemShippingAddress' => MyCartUpdateItemShippingAddressActionModel::class,
63  ];
64 
68  public function __construct(
69  ?string $action = null
70  ) {
71  $this->action = $action;
72  }
73 
78  public function getAction()
79  {
80  if (is_null($this->action)) {
82  $data = $this->raw(self::FIELD_ACTION);
83  if (is_null($data)) {
84  return null;
85  }
86  $this->action = (string) $data;
87  }
88 
89  return $this->action;
90  }
91 
92 
93 
94 
95 
100  public static function resolveDiscriminatorClass($value): string
101  {
103  if (is_object($value) && isset($value->$fieldName)) {
105  $discriminatorValue = $value->$fieldName;
106  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
107  return self::$discriminatorClasses[$discriminatorValue];
108  }
109  }
110  if (is_array($value) && isset($value[$fieldName])) {
112  $discriminatorValue = $value[$fieldName];
113  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
114  return self::$discriminatorClasses[$discriminatorValue];
115  }
116  }
117 
119  $type = MyCartUpdateActionModel::class;
120  return $type;
121  }
122 }