commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CartDiscountUpdateActionModel.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  'addStore' => CartDiscountAddStoreActionModel::class,
35  'changeCartPredicate' => CartDiscountChangeCartPredicateActionModel::class,
36  'changeIsActive' => CartDiscountChangeIsActiveActionModel::class,
37  'changeName' => CartDiscountChangeNameActionModel::class,
38  'changeRequiresDiscountCode' => CartDiscountChangeRequiresDiscountCodeActionModel::class,
39  'changeSortOrder' => CartDiscountChangeSortOrderActionModel::class,
40  'changeStackingMode' => CartDiscountChangeStackingModeActionModel::class,
41  'changeTarget' => CartDiscountChangeTargetActionModel::class,
42  'changeValue' => CartDiscountChangeValueActionModel::class,
43  'removeStore' => CartDiscountRemoveStoreActionModel::class,
44  'setCustomField' => CartDiscountSetCustomFieldActionModel::class,
45  'setCustomType' => CartDiscountSetCustomTypeActionModel::class,
46  'setDescription' => CartDiscountSetDescriptionActionModel::class,
47  'setKey' => CartDiscountSetKeyActionModel::class,
48  'setStores' => CartDiscountSetStoresActionModel::class,
49  'setValidFrom' => CartDiscountSetValidFromActionModel::class,
50  'setValidFromAndUntil' => CartDiscountSetValidFromAndUntilActionModel::class,
51  'setValidUntil' => CartDiscountSetValidUntilActionModel::class,
52  ];
53 
57  public function __construct(
58  ?string $action = null
59  ) {
60  $this->action = $action;
61  }
62 
67  public function getAction()
68  {
69  if (is_null($this->action)) {
71  $data = $this->raw(self::FIELD_ACTION);
72  if (is_null($data)) {
73  return null;
74  }
75  $this->action = (string) $data;
76  }
77 
78  return $this->action;
79  }
80 
81 
82 
83 
84 
89  public static function resolveDiscriminatorClass($value): string
90  {
92  if (is_object($value) && isset($value->$fieldName)) {
94  $discriminatorValue = $value->$fieldName;
95  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
96  return self::$discriminatorClasses[$discriminatorValue];
97  }
98  }
99  if (is_array($value) && isset($value[$fieldName])) {
101  $discriminatorValue = $value[$fieldName];
102  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
103  return self::$discriminatorClasses[$discriminatorValue];
104  }
105  }
106 
108  $type = CartDiscountUpdateActionModel::class;
109  return $type;
110  }
111 }