commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StandalonePriceUpdateActionModel.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  'addPriceTier' => StandalonePriceAddPriceTierActionModel::class,
35  'applyStagedChanges' => StandalonePriceApplyStagedChangesActionModel::class,
36  'changeActive' => StandalonePriceChangeActiveActionModel::class,
37  'changeValue' => StandalonePriceChangeValueActionModel::class,
38  'removePriceTier' => StandalonePriceRemovePriceTierActionModel::class,
39  'removeStagedChanges' => StandalonePriceRemoveStagedChangesActionModel::class,
40  'setCustomField' => StandalonePriceSetCustomFieldActionModel::class,
41  'setCustomType' => StandalonePriceSetCustomTypeActionModel::class,
42  'setDiscountedPrice' => StandalonePriceSetDiscountedPriceActionModel::class,
43  'setKey' => StandalonePriceSetKeyActionModel::class,
44  'setPriceTiers' => StandalonePriceSetPriceTiersActionModel::class,
45  'setValidFrom' => StandalonePriceSetValidFromActionModel::class,
46  'setValidFromAndUntil' => StandalonePriceSetValidFromAndUntilActionModel::class,
47  'setValidUntil' => StandalonePriceSetValidUntilActionModel::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 = StandalonePriceUpdateActionModel::class;
105  return $type;
106  }
107 }