commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
MyBusinessUnitDraftModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
24 {
25  public const DISCRIMINATOR_VALUE = '';
30  protected $key;
31 
36  protected $unitType;
37 
42  protected $name;
43 
48  protected $contactEmail;
49 
54  protected $custom;
55 
60  protected $addresses;
61 
66  protected $shippingAddresses;
67 
73 
78  protected $billingAddresses;
79 
85 
90  private static $discriminatorClasses = [
91  'Company' => MyCompanyDraftModel::class,
92  'Division' => MyDivisionDraftModel::class,
93  ];
94 
98  public function __construct(
99  ?string $key = null,
100  ?string $name = null,
101  ?string $contactEmail = null,
102  ?CustomFieldsDraft $custom = null,
104  ?array $shippingAddresses = null,
105  ?int $defaultShippingAddress = null,
106  ?array $billingAddresses = null,
107  ?int $defaultBillingAddress = null,
108  ?string $unitType = null
109  ) {
110  $this->key = $key;
111  $this->name = $name;
112  $this->contactEmail = $contactEmail;
113  $this->custom = $custom;
114  $this->addresses = $addresses;
115  $this->shippingAddresses = $shippingAddresses;
116  $this->defaultShippingAddress = $defaultShippingAddress;
117  $this->billingAddresses = $billingAddresses;
118  $this->defaultBillingAddress = $defaultBillingAddress;
119  $this->unitType = $unitType;
120  }
121 
128  public function getKey()
129  {
130  if (is_null($this->key)) {
132  $data = $this->raw(self::FIELD_KEY);
133  if (is_null($data)) {
134  return null;
135  }
136  $this->key = (string) $data;
137  }
138 
139  return $this->key;
140  }
141 
148  public function getUnitType()
149  {
150  if (is_null($this->unitType)) {
152  $data = $this->raw(self::FIELD_UNIT_TYPE);
153  if (is_null($data)) {
154  return null;
155  }
156  $this->unitType = (string) $data;
157  }
158 
159  return $this->unitType;
160  }
161 
168  public function getName()
169  {
170  if (is_null($this->name)) {
172  $data = $this->raw(self::FIELD_NAME);
173  if (is_null($data)) {
174  return null;
175  }
176  $this->name = (string) $data;
177  }
178 
179  return $this->name;
180  }
181 
188  public function getContactEmail()
189  {
190  if (is_null($this->contactEmail)) {
192  $data = $this->raw(self::FIELD_CONTACT_EMAIL);
193  if (is_null($data)) {
194  return null;
195  }
196  $this->contactEmail = (string) $data;
197  }
198 
199  return $this->contactEmail;
200  }
201 
208  public function getCustom()
209  {
210  if (is_null($this->custom)) {
212  $data = $this->raw(self::FIELD_CUSTOM);
213  if (is_null($data)) {
214  return null;
215  }
216 
217  $this->custom = CustomFieldsDraftModel::of($data);
218  }
219 
220  return $this->custom;
221  }
222 
229  public function getAddresses()
230  {
231  if (is_null($this->addresses)) {
233  $data = $this->raw(self::FIELD_ADDRESSES);
234  if (is_null($data)) {
235  return null;
236  }
237  $this->addresses = BaseAddressCollection::fromArray($data);
238  }
239 
240  return $this->addresses;
241  }
242 
250  public function getShippingAddresses()
251  {
252  if (is_null($this->shippingAddresses)) {
254  $data = $this->raw(self::FIELD_SHIPPING_ADDRESSES);
255  if (is_null($data)) {
256  return null;
257  }
258  $this->shippingAddresses = $data;
259  }
260 
262  }
263 
270  public function getDefaultShippingAddress()
271  {
272  if (is_null($this->defaultShippingAddress)) {
274  $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS);
275  if (is_null($data)) {
276  return null;
277  }
278  $this->defaultShippingAddress = (int) $data;
279  }
280 
282  }
283 
291  public function getBillingAddresses()
292  {
293  if (is_null($this->billingAddresses)) {
295  $data = $this->raw(self::FIELD_BILLING_ADDRESSES);
296  if (is_null($data)) {
297  return null;
298  }
299  $this->billingAddresses = $data;
300  }
301 
303  }
304 
311  public function getDefaultBillingAddress()
312  {
313  if (is_null($this->defaultBillingAddress)) {
315  $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS);
316  if (is_null($data)) {
317  return null;
318  }
319  $this->defaultBillingAddress = (int) $data;
320  }
321 
323  }
324 
325 
329  public function setKey(?string $key): void
330  {
331  $this->key = $key;
332  }
333 
337  public function setName(?string $name): void
338  {
339  $this->name = $name;
340  }
341 
345  public function setContactEmail(?string $contactEmail): void
346  {
347  $this->contactEmail = $contactEmail;
348  }
349 
353  public function setCustom(?CustomFieldsDraft $custom): void
354  {
355  $this->custom = $custom;
356  }
357 
362  {
363  $this->addresses = $addresses;
364  }
365 
369  public function setShippingAddresses(?array $shippingAddresses): void
370  {
371  $this->shippingAddresses = $shippingAddresses;
372  }
373 
378  {
379  $this->defaultShippingAddress = $defaultShippingAddress;
380  }
381 
385  public function setBillingAddresses(?array $billingAddresses): void
386  {
387  $this->billingAddresses = $billingAddresses;
388  }
389 
394  {
395  $this->defaultBillingAddress = $defaultBillingAddress;
396  }
397 
398 
399 
404  public static function resolveDiscriminatorClass($value): string
405  {
407  if (is_object($value) && isset($value->$fieldName)) {
409  $discriminatorValue = $value->$fieldName;
410  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
411  return self::$discriminatorClasses[$discriminatorValue];
412  }
413  }
414  if (is_array($value) && isset($value[$fieldName])) {
416  $discriminatorValue = $value[$fieldName];
417  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
418  return self::$discriminatorClasses[$discriminatorValue];
419  }
420  }
421 
423  $type = MyBusinessUnitDraftModel::class;
424  return $type;
425  }
426 }
__construct(?string $key=null, ?string $name=null, ?string $contactEmail=null, ?CustomFieldsDraft $custom=null, ?BaseAddressCollection $addresses=null, ?array $shippingAddresses=null, ?int $defaultShippingAddress=null, ?array $billingAddresses=null, ?int $defaultBillingAddress=null, ?string $unitType=null)