commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DiscountCodeUpdateActionModel.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  'changeCartDiscounts' => DiscountCodeChangeCartDiscountsActionModel::class,
35  'changeGroups' => DiscountCodeChangeGroupsActionModel::class,
36  'changeIsActive' => DiscountCodeChangeIsActiveActionModel::class,
37  'setCartPredicate' => DiscountCodeSetCartPredicateActionModel::class,
38  'setCustomField' => DiscountCodeSetCustomFieldActionModel::class,
39  'setCustomType' => DiscountCodeSetCustomTypeActionModel::class,
40  'setDescription' => DiscountCodeSetDescriptionActionModel::class,
41  'setKey' => DiscountCodeSetKeyActionModel::class,
42  'setMaxApplications' => DiscountCodeSetMaxApplicationsActionModel::class,
43  'setMaxApplicationsPerCustomer' => DiscountCodeSetMaxApplicationsPerCustomerActionModel::class,
44  'setName' => DiscountCodeSetNameActionModel::class,
45  'setValidFrom' => DiscountCodeSetValidFromActionModel::class,
46  'setValidFromAndUntil' => DiscountCodeSetValidFromAndUntilActionModel::class,
47  'setValidUntil' => DiscountCodeSetValidUntilActionModel::class,
48  ];
49 
53  public function __construct(
54  ?string $action = null
55  ) {
56  $this->action = $action;
57  }
58 
63  public function getAction()
64  {
65  if (is_null($this->action)) {
67  $data = $this->raw(self::FIELD_ACTION);
68  if (is_null($data)) {
69  return null;
70  }
71  $this->action = (string) $data;
72  }
73 
74  return $this->action;
75  }
76 
77 
78 
79 
80 
85  public static function resolveDiscriminatorClass($value): string
86  {
88  if (is_object($value) && isset($value->$fieldName)) {
90  $discriminatorValue = $value->$fieldName;
91  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
92  return self::$discriminatorClasses[$discriminatorValue];
93  }
94  }
95  if (is_array($value) && isset($value[$fieldName])) {
97  $discriminatorValue = $value[$fieldName];
98  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
99  return self::$discriminatorClasses[$discriminatorValue];
100  }
101  }
102 
104  $type = DiscountCodeUpdateActionModel::class;
105  return $type;
106  }
107 }