commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
BusinessUnitUpdateActionModel.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' => BusinessUnitAddAddressActionModel::class,
35  'addAssociate' => BusinessUnitAddAssociateActionModel::class,
36  'addBillingAddressId' => BusinessUnitAddBillingAddressIdActionModel::class,
37  'addShippingAddressId' => BusinessUnitAddShippingAddressIdActionModel::class,
38  'addStore' => BusinessUnitAddStoreActionModel::class,
39  'changeAddress' => BusinessUnitChangeAddressActionModel::class,
40  'changeApprovalRuleMode' => BusinessUnitChangeApprovalRuleModeActionModel::class,
41  'changeAssociate' => BusinessUnitChangeAssociateActionModel::class,
42  'changeAssociateMode' => BusinessUnitChangeAssociateModeActionModel::class,
43  'changeName' => BusinessUnitChangeNameActionModel::class,
44  'changeParentUnit' => BusinessUnitChangeParentUnitActionModel::class,
45  'changeStatus' => BusinessUnitChangeStatusActionModel::class,
46  'removeAddress' => BusinessUnitRemoveAddressActionModel::class,
47  'removeAssociate' => BusinessUnitRemoveAssociateActionModel::class,
48  'removeBillingAddressId' => BusinessUnitRemoveBillingAddressIdActionModel::class,
49  'removeShippingAddressId' => BusinessUnitRemoveShippingAddressIdActionModel::class,
50  'removeStore' => BusinessUnitRemoveStoreActionModel::class,
51  'setAddressCustomField' => BusinessUnitSetAddressCustomFieldActionModel::class,
52  'setAddressCustomType' => BusinessUnitSetAddressCustomTypeActionModel::class,
53  'setAssociates' => BusinessUnitSetAssociatesActionModel::class,
54  'setContactEmail' => BusinessUnitSetContactEmailActionModel::class,
55  'setCustomField' => BusinessUnitSetCustomFieldActionModel::class,
56  'setCustomType' => BusinessUnitSetCustomTypeActionModel::class,
57  'setDefaultBillingAddress' => BusinessUnitSetDefaultBillingAddressActionModel::class,
58  'setDefaultShippingAddress' => BusinessUnitSetDefaultShippingAddressActionModel::class,
59  'setStoreMode' => BusinessUnitSetStoreModeActionModel::class,
60  'setStores' => BusinessUnitSetStoresActionModel::class,
61  ];
62 
66  public function __construct(
67  ?string $action = null
68  ) {
69  $this->action = $action;
70  }
71 
76  public function getAction()
77  {
78  if (is_null($this->action)) {
80  $data = $this->raw(self::FIELD_ACTION);
81  if (is_null($data)) {
82  return null;
83  }
84  $this->action = (string) $data;
85  }
86 
87  return $this->action;
88  }
89 
90 
91 
92 
93 
98  public static function resolveDiscriminatorClass($value): string
99  {
101  if (is_object($value) && isset($value->$fieldName)) {
103  $discriminatorValue = $value->$fieldName;
104  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
105  return self::$discriminatorClasses[$discriminatorValue];
106  }
107  }
108  if (is_array($value) && isset($value[$fieldName])) {
110  $discriminatorValue = $value[$fieldName];
111  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
112  return self::$discriminatorClasses[$discriminatorValue];
113  }
114  }
115 
117  $type = BusinessUnitUpdateActionModel::class;
118  return $type;
119  }
120 }