commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
MyCustomerUpdateActionModel.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' => MyCustomerAddAddressActionModel::class,
35  'addBillingAddressId' => MyCustomerAddBillingAddressIdActionModel::class,
36  'addShippingAddressId' => MyCustomerAddShippingAddressIdActionModel::class,
37  'changeAddress' => MyCustomerChangeAddressActionModel::class,
38  'changeEmail' => MyCustomerChangeEmailActionModel::class,
39  'removeAddress' => MyCustomerRemoveAddressActionModel::class,
40  'removeBillingAddressId' => MyCustomerRemoveBillingAddressIdActionModel::class,
41  'removeShippingAddressId' => MyCustomerRemoveShippingAddressIdActionModel::class,
42  'setCompanyName' => MyCustomerSetCompanyNameActionModel::class,
43  'setCustomField' => MyCustomerSetCustomFieldActionModel::class,
44  'setCustomType' => MyCustomerSetCustomTypeActionModel::class,
45  'setDateOfBirth' => MyCustomerSetDateOfBirthActionModel::class,
46  'setDefaultBillingAddress' => MyCustomerSetDefaultBillingAddressActionModel::class,
47  'setDefaultShippingAddress' => MyCustomerSetDefaultShippingAddressActionModel::class,
48  'setFirstName' => MyCustomerSetFirstNameActionModel::class,
49  'setLastName' => MyCustomerSetLastNameActionModel::class,
50  'setLocale' => MyCustomerSetLocaleActionModel::class,
51  'setMiddleName' => MyCustomerSetMiddleNameActionModel::class,
52  'setSalutation' => MyCustomerSetSalutationActionModel::class,
53  'setTitle' => MyCustomerSetTitleActionModel::class,
54  'setVatId' => MyCustomerSetVatIdActionModel::class,
55  ];
56 
60  public function __construct(
61  ?string $action = null
62  ) {
63  $this->action = $action;
64  }
65 
70  public function getAction()
71  {
72  if (is_null($this->action)) {
74  $data = $this->raw(self::FIELD_ACTION);
75  if (is_null($data)) {
76  return null;
77  }
78  $this->action = (string) $data;
79  }
80 
81  return $this->action;
82  }
83 
84 
85 
86 
87 
92  public static function resolveDiscriminatorClass($value): string
93  {
95  if (is_object($value) && isset($value->$fieldName)) {
97  $discriminatorValue = $value->$fieldName;
98  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
99  return self::$discriminatorClasses[$discriminatorValue];
100  }
101  }
102  if (is_array($value) && isset($value[$fieldName])) {
104  $discriminatorValue = $value[$fieldName];
105  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
106  return self::$discriminatorClasses[$discriminatorValue];
107  }
108  }
109 
111  $type = MyCustomerUpdateActionModel::class;
112  return $type;
113  }
114 }