commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
MyBusinessUnitUpdateActionModel.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' => MyBusinessUnitAddAddressActionModel::class,
35  'addBillingAddressId' => MyBusinessUnitAddBillingAddressIdActionModel::class,
36  'addShippingAddressId' => MyBusinessUnitAddShippingAddressIdActionModel::class,
37  'changeAddress' => MyBusinessUnitChangeAddressActionModel::class,
38  'changeAssociate' => MyBusinessUnitChangeAssociateActionModel::class,
39  'changeName' => MyBusinessUnitChangeNameActionModel::class,
40  'changeParentUnit' => MyBusinessUnitChangeParentUnitActionModel::class,
41  'removeAddress' => MyBusinessUnitRemoveAddressActionModel::class,
42  'removeAssociate' => MyBusinessUnitRemoveAssociateActionModel::class,
43  'removeBillingAddressId' => MyBusinessUnitRemoveBillingAddressIdActionModel::class,
44  'removeShippingAddressId' => MyBusinessUnitRemoveShippingAddressIdActionModel::class,
45  'setAddressCustomField' => MyBusinessUnitSetAddressCustomFieldActionModel::class,
46  'setAddressCustomType' => MyBusinessUnitSetAddressCustomTypeActionModel::class,
47  'setContactEmail' => MyBusinessUnitSetContactEmailActionModel::class,
48  'setCustomField' => MyBusinessUnitSetCustomFieldActionModel::class,
49  'setCustomType' => MyBusinessUnitSetCustomTypeActionModel::class,
50  'setDefaultBillingAddress' => MyBusinessUnitSetDefaultBillingAddressActionModel::class,
51  'setDefaultShippingAddress' => MyBusinessUnitSetDefaultShippingAddressActionModel::class,
52  ];
53 
57  public function __construct(
58  ?string $action = null
59  ) {
60  $this->action = $action;
61  }
62 
67  public function getAction()
68  {
69  if (is_null($this->action)) {
71  $data = $this->raw(self::FIELD_ACTION);
72  if (is_null($data)) {
73  return null;
74  }
75  $this->action = (string) $data;
76  }
77 
78  return $this->action;
79  }
80 
81 
82 
83 
84 
89  public static function resolveDiscriminatorClass($value): string
90  {
92  if (is_object($value) && isset($value->$fieldName)) {
94  $discriminatorValue = $value->$fieldName;
95  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
96  return self::$discriminatorClasses[$discriminatorValue];
97  }
98  }
99  if (is_array($value) && isset($value[$fieldName])) {
101  $discriminatorValue = $value[$fieldName];
102  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
103  return self::$discriminatorClasses[$discriminatorValue];
104  }
105  }
106 
108  $type = MyBusinessUnitUpdateActionModel::class;
109  return $type;
110  }
111 }