commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CustomerUpdateActionModel.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  'addAddress' => CustomerAddAddressActionModel::class,
35  'addBillingAddressId' => CustomerAddBillingAddressIdActionModel::class,
36  'addShippingAddressId' => CustomerAddShippingAddressIdActionModel::class,
37  'addStore' => CustomerAddStoreActionModel::class,
38  'changeAddress' => CustomerChangeAddressActionModel::class,
39  'changeEmail' => CustomerChangeEmailActionModel::class,
40  'removeAddress' => CustomerRemoveAddressActionModel::class,
41  'removeBillingAddressId' => CustomerRemoveBillingAddressIdActionModel::class,
42  'removeShippingAddressId' => CustomerRemoveShippingAddressIdActionModel::class,
43  'removeStore' => CustomerRemoveStoreActionModel::class,
44  'setAddressCustomField' => CustomerSetAddressCustomFieldActionModel::class,
45  'setAddressCustomType' => CustomerSetAddressCustomTypeActionModel::class,
46  'setAuthenticationMode' => CustomerSetAuthenticationModeActionModel::class,
47  'setCompanyName' => CustomerSetCompanyNameActionModel::class,
48  'setCustomField' => CustomerSetCustomFieldActionModel::class,
49  'setCustomType' => CustomerSetCustomTypeActionModel::class,
50  'setCustomerGroup' => CustomerSetCustomerGroupActionModel::class,
51  'setCustomerNumber' => CustomerSetCustomerNumberActionModel::class,
52  'setDateOfBirth' => CustomerSetDateOfBirthActionModel::class,
53  'setDefaultBillingAddress' => CustomerSetDefaultBillingAddressActionModel::class,
54  'setDefaultShippingAddress' => CustomerSetDefaultShippingAddressActionModel::class,
55  'setExternalId' => CustomerSetExternalIdActionModel::class,
56  'setFirstName' => CustomerSetFirstNameActionModel::class,
57  'setKey' => CustomerSetKeyActionModel::class,
58  'setLastName' => CustomerSetLastNameActionModel::class,
59  'setLocale' => CustomerSetLocaleActionModel::class,
60  'setMiddleName' => CustomerSetMiddleNameActionModel::class,
61  'setSalutation' => CustomerSetSalutationActionModel::class,
62  'setStores' => CustomerSetStoresActionModel::class,
63  'setTitle' => CustomerSetTitleActionModel::class,
64  'setVatId' => CustomerSetVatIdActionModel::class,
65  ];
66 
70  public function __construct(
71  ?string $action = null
72  ) {
73  $this->action = $action;
74  }
75 
80  public function getAction()
81  {
82  if (is_null($this->action)) {
84  $data = $this->raw(self::FIELD_ACTION);
85  if (is_null($data)) {
86  return null;
87  }
88  $this->action = (string) $data;
89  }
90 
91  return $this->action;
92  }
93 
94 
95 
96 
97 
102  public static function resolveDiscriminatorClass($value): string
103  {
105  if (is_object($value) && isset($value->$fieldName)) {
107  $discriminatorValue = $value->$fieldName;
108  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
109  return self::$discriminatorClasses[$discriminatorValue];
110  }
111  }
112  if (is_array($value) && isset($value[$fieldName])) {
114  $discriminatorValue = $value[$fieldName];
115  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
116  return self::$discriminatorClasses[$discriminatorValue];
117  }
118  }
119 
121  $type = CustomerUpdateActionModel::class;
122  return $type;
123  }
124 }