commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ShippingMethodUpdateActionModel.php
1<?php
2
3declare(strict_types=1);
10
15use stdClass;
16
21{
22 public const DISCRIMINATOR_VALUE = '';
27 protected $action;
28
33 private static $discriminatorClasses = [
34 'addShippingRate' => ShippingMethodAddShippingRateActionModel::class,
35 'addZone' => ShippingMethodAddZoneActionModel::class,
36 'changeActive' => ShippingMethodChangeActiveActionModel::class,
37 'changeIsDefault' => ShippingMethodChangeIsDefaultActionModel::class,
38 'changeName' => ShippingMethodChangeNameActionModel::class,
39 'changeTaxCategory' => ShippingMethodChangeTaxCategoryActionModel::class,
40 'removeShippingRate' => ShippingMethodRemoveShippingRateActionModel::class,
41 'removeZone' => ShippingMethodRemoveZoneActionModel::class,
42 'setCustomField' => ShippingMethodSetCustomFieldActionModel::class,
43 'setCustomType' => ShippingMethodSetCustomTypeActionModel::class,
44 'setDescription' => ShippingMethodSetDescriptionActionModel::class,
45 'setKey' => ShippingMethodSetKeyActionModel::class,
46 'setLocalizedDescription' => ShippingMethodSetLocalizedDescriptionActionModel::class,
47 'setLocalizedName' => ShippingMethodSetLocalizedNameActionModel::class,
48 'setPredicate' => ShippingMethodSetPredicateActionModel::class,
49 ];
50
54 public function __construct(
55 ?string $action = null
56 ) {
57 $this->action = $action;
58 }
59
64 public function getAction()
65 {
66 if (is_null($this->action)) {
68 $data = $this->raw(self::FIELD_ACTION);
69 if (is_null($data)) {
70 return null;
71 }
72 $this->action = (string) $data;
73 }
74
75 return $this->action;
76 }
77
78
79
80
81
86 public static function resolveDiscriminatorClass($value): string
87 {
89 if (is_object($value) && isset($value->$fieldName)) {
91 $discriminatorValue = $value->$fieldName;
92 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
93 return self::$discriminatorClasses[$discriminatorValue];
94 }
95 }
96 if (is_array($value) && isset($value[$fieldName])) {
98 $discriminatorValue = $value[$fieldName];
99 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
100 return self::$discriminatorClasses[$discriminatorValue];
101 }
102 }
103
105 $type = ShippingMethodUpdateActionModel::class;
106 return $type;
107 }
108}