commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
BusinessUnitModel.php
1<?php
2
3declare(strict_types=1);
10
25use DateTimeImmutable;
26use stdClass;
27
31final class BusinessUnitModel extends JsonObjectModel implements BusinessUnit
32{
33 public const DISCRIMINATOR_VALUE = '';
38 protected $id;
39
44 protected $version;
45
50 protected $createdAt;
51
56 protected $lastModifiedAt;
57
62 protected $lastModifiedBy;
63
68 protected $createdBy;
69
74 protected $key;
75
80 protected $status;
81
86 protected $stores;
87
93
98 protected $storeMode;
99
104 protected $unitType;
105
110 protected $name;
111
116 protected $contactEmail;
117
122 protected $custom;
123
128 protected $addresses;
129
135
141
147
153
158 protected $associateMode;
159
164 protected $associates;
165
171
176 protected $parentUnit;
177
182 protected $topLevelUnit;
183
189
194 private static $discriminatorClasses = [
195 'Company' => CompanyModel::class,
196 'Division' => DivisionModel::class,
197 ];
198
202 public function __construct(
203 ?string $id = null,
204 ?int $version = null,
205 ?DateTimeImmutable $createdAt = null,
206 ?DateTimeImmutable $lastModifiedAt = null,
208 ?CreatedBy $createdBy = null,
209 ?string $key = null,
210 ?string $status = null,
213 ?string $storeMode = null,
214 ?string $name = null,
215 ?string $contactEmail = null,
216 ?CustomFields $custom = null,
218 ?array $shippingAddressIds = null,
219 ?string $defaultShippingAddressId = null,
220 ?array $billingAddressIds = null,
221 ?string $defaultBillingAddressId = null,
222 ?string $associateMode = null,
227 ?string $approvalRuleMode = null,
228 ?string $unitType = null
229 ) {
230 $this->id = $id;
231 $this->version = $version;
232 $this->createdAt = $createdAt;
233 $this->lastModifiedAt = $lastModifiedAt;
234 $this->lastModifiedBy = $lastModifiedBy;
235 $this->createdBy = $createdBy;
236 $this->key = $key;
237 $this->status = $status;
238 $this->stores = $stores;
239 $this->inheritedStores = $inheritedStores;
240 $this->storeMode = $storeMode;
241 $this->name = $name;
242 $this->contactEmail = $contactEmail;
243 $this->custom = $custom;
244 $this->addresses = $addresses;
245 $this->shippingAddressIds = $shippingAddressIds;
246 $this->defaultShippingAddressId = $defaultShippingAddressId;
247 $this->billingAddressIds = $billingAddressIds;
248 $this->defaultBillingAddressId = $defaultBillingAddressId;
249 $this->associateMode = $associateMode;
250 $this->associates = $associates;
251 $this->inheritedAssociates = $inheritedAssociates;
252 $this->parentUnit = $parentUnit;
253 $this->topLevelUnit = $topLevelUnit;
254 $this->approvalRuleMode = $approvalRuleMode;
255 $this->unitType = $unitType;
256 }
257
264 public function getId()
265 {
266 if (is_null($this->id)) {
268 $data = $this->raw(self::FIELD_ID);
269 if (is_null($data)) {
270 return null;
271 }
272 $this->id = (string) $data;
273 }
274
275 return $this->id;
276 }
277
284 public function getVersion()
285 {
286 if (is_null($this->version)) {
288 $data = $this->raw(self::FIELD_VERSION);
289 if (is_null($data)) {
290 return null;
291 }
292 $this->version = (int) $data;
293 }
294
295 return $this->version;
296 }
297
304 public function getCreatedAt()
305 {
306 if (is_null($this->createdAt)) {
308 $data = $this->raw(self::FIELD_CREATED_AT);
309 if (is_null($data)) {
310 return null;
311 }
312 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
313 if (false === $data) {
314 return null;
315 }
316 $this->createdAt = $data;
317 }
318
319 return $this->createdAt;
320 }
321
328 public function getLastModifiedAt()
329 {
330 if (is_null($this->lastModifiedAt)) {
332 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
333 if (is_null($data)) {
334 return null;
335 }
336 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
337 if (false === $data) {
338 return null;
339 }
340 $this->lastModifiedAt = $data;
341 }
342
344 }
345
352 public function getLastModifiedBy()
353 {
354 if (is_null($this->lastModifiedBy)) {
356 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
357 if (is_null($data)) {
358 return null;
359 }
360
361 $this->lastModifiedBy = LastModifiedByModel::of($data);
362 }
363
365 }
366
373 public function getCreatedBy()
374 {
375 if (is_null($this->createdBy)) {
377 $data = $this->raw(self::FIELD_CREATED_BY);
378 if (is_null($data)) {
379 return null;
380 }
381
382 $this->createdBy = CreatedByModel::of($data);
383 }
384
385 return $this->createdBy;
386 }
387
394 public function getKey()
395 {
396 if (is_null($this->key)) {
398 $data = $this->raw(self::FIELD_KEY);
399 if (is_null($data)) {
400 return null;
401 }
402 $this->key = (string) $data;
403 }
404
405 return $this->key;
406 }
407
414 public function getStatus()
415 {
416 if (is_null($this->status)) {
418 $data = $this->raw(self::FIELD_STATUS);
419 if (is_null($data)) {
420 return null;
421 }
422 $this->status = (string) $data;
423 }
424
425 return $this->status;
426 }
427
436 public function getStores()
437 {
438 if (is_null($this->stores)) {
440 $data = $this->raw(self::FIELD_STORES);
441 if (is_null($data)) {
442 return null;
443 }
444 $this->stores = StoreKeyReferenceCollection::fromArray($data);
445 }
446
447 return $this->stores;
448 }
449
456 public function getInheritedStores()
457 {
458 if (is_null($this->inheritedStores)) {
460 $data = $this->raw(self::FIELD_INHERITED_STORES);
461 if (is_null($data)) {
462 return null;
463 }
464 $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data);
465 }
466
468 }
469
476 public function getStoreMode()
477 {
478 if (is_null($this->storeMode)) {
480 $data = $this->raw(self::FIELD_STORE_MODE);
481 if (is_null($data)) {
482 return null;
483 }
484 $this->storeMode = (string) $data;
485 }
486
487 return $this->storeMode;
488 }
489
496 public function getUnitType()
497 {
498 if (is_null($this->unitType)) {
500 $data = $this->raw(self::FIELD_UNIT_TYPE);
501 if (is_null($data)) {
502 return null;
503 }
504 $this->unitType = (string) $data;
505 }
506
507 return $this->unitType;
508 }
509
516 public function getName()
517 {
518 if (is_null($this->name)) {
520 $data = $this->raw(self::FIELD_NAME);
521 if (is_null($data)) {
522 return null;
523 }
524 $this->name = (string) $data;
525 }
526
527 return $this->name;
528 }
529
536 public function getContactEmail()
537 {
538 if (is_null($this->contactEmail)) {
540 $data = $this->raw(self::FIELD_CONTACT_EMAIL);
541 if (is_null($data)) {
542 return null;
543 }
544 $this->contactEmail = (string) $data;
545 }
546
547 return $this->contactEmail;
548 }
549
556 public function getCustom()
557 {
558 if (is_null($this->custom)) {
560 $data = $this->raw(self::FIELD_CUSTOM);
561 if (is_null($data)) {
562 return null;
563 }
564
565 $this->custom = CustomFieldsModel::of($data);
566 }
567
568 return $this->custom;
569 }
570
577 public function getAddresses()
578 {
579 if (is_null($this->addresses)) {
581 $data = $this->raw(self::FIELD_ADDRESSES);
582 if (is_null($data)) {
583 return null;
584 }
585 $this->addresses = AddressCollection::fromArray($data);
586 }
587
588 return $this->addresses;
589 }
590
597 public function getShippingAddressIds()
598 {
599 if (is_null($this->shippingAddressIds)) {
601 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
602 if (is_null($data)) {
603 return null;
604 }
605 $this->shippingAddressIds = $data;
606 }
607
609 }
610
618 {
619 if (is_null($this->defaultShippingAddressId)) {
621 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
622 if (is_null($data)) {
623 return null;
624 }
625 $this->defaultShippingAddressId = (string) $data;
626 }
627
629 }
630
637 public function getBillingAddressIds()
638 {
639 if (is_null($this->billingAddressIds)) {
641 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
642 if (is_null($data)) {
643 return null;
644 }
645 $this->billingAddressIds = $data;
646 }
647
649 }
650
658 {
659 if (is_null($this->defaultBillingAddressId)) {
661 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
662 if (is_null($data)) {
663 return null;
664 }
665 $this->defaultBillingAddressId = (string) $data;
666 }
667
669 }
670
677 public function getAssociateMode()
678 {
679 if (is_null($this->associateMode)) {
681 $data = $this->raw(self::FIELD_ASSOCIATE_MODE);
682 if (is_null($data)) {
683 return null;
684 }
685 $this->associateMode = (string) $data;
686 }
687
689 }
690
697 public function getAssociates()
698 {
699 if (is_null($this->associates)) {
701 $data = $this->raw(self::FIELD_ASSOCIATES);
702 if (is_null($data)) {
703 return null;
704 }
705 $this->associates = AssociateCollection::fromArray($data);
706 }
707
708 return $this->associates;
709 }
710
717 public function getInheritedAssociates()
718 {
719 if (is_null($this->inheritedAssociates)) {
721 $data = $this->raw(self::FIELD_INHERITED_ASSOCIATES);
722 if (is_null($data)) {
723 return null;
724 }
725 $this->inheritedAssociates = InheritedAssociateCollection::fromArray($data);
726 }
727
729 }
730
737 public function getParentUnit()
738 {
739 if (is_null($this->parentUnit)) {
741 $data = $this->raw(self::FIELD_PARENT_UNIT);
742 if (is_null($data)) {
743 return null;
744 }
745
746 $this->parentUnit = BusinessUnitKeyReferenceModel::of($data);
747 }
748
749 return $this->parentUnit;
750 }
751
758 public function getTopLevelUnit()
759 {
760 if (is_null($this->topLevelUnit)) {
762 $data = $this->raw(self::FIELD_TOP_LEVEL_UNIT);
763 if (is_null($data)) {
764 return null;
765 }
766
767 $this->topLevelUnit = BusinessUnitKeyReferenceModel::of($data);
768 }
769
770 return $this->topLevelUnit;
771 }
772
780 public function getApprovalRuleMode()
781 {
782 if (is_null($this->approvalRuleMode)) {
784 $data = $this->raw(self::FIELD_APPROVAL_RULE_MODE);
785 if (is_null($data)) {
786 return null;
787 }
788 $this->approvalRuleMode = (string) $data;
789 }
790
792 }
793
794
798 public function setId(?string $id): void
799 {
800 $this->id = $id;
801 }
802
806 public function setVersion(?int $version): void
807 {
808 $this->version = $version;
809 }
810
814 public function setCreatedAt(?DateTimeImmutable $createdAt): void
815 {
816 $this->createdAt = $createdAt;
817 }
818
822 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
823 {
824 $this->lastModifiedAt = $lastModifiedAt;
825 }
826
831 {
832 $this->lastModifiedBy = $lastModifiedBy;
833 }
834
838 public function setCreatedBy(?CreatedBy $createdBy): void
839 {
840 $this->createdBy = $createdBy;
841 }
842
846 public function setKey(?string $key): void
847 {
848 $this->key = $key;
849 }
850
854 public function setStatus(?string $status): void
855 {
856 $this->status = $status;
857 }
858
863 {
864 $this->stores = $stores;
865 }
866
871 {
872 $this->inheritedStores = $inheritedStores;
873 }
874
878 public function setStoreMode(?string $storeMode): void
879 {
880 $this->storeMode = $storeMode;
881 }
882
886 public function setName(?string $name): void
887 {
888 $this->name = $name;
889 }
890
894 public function setContactEmail(?string $contactEmail): void
895 {
896 $this->contactEmail = $contactEmail;
897 }
898
902 public function setCustom(?CustomFields $custom): void
903 {
904 $this->custom = $custom;
905 }
906
911 {
912 $this->addresses = $addresses;
913 }
914
918 public function setShippingAddressIds(?array $shippingAddressIds): void
919 {
920 $this->shippingAddressIds = $shippingAddressIds;
921 }
922
927 {
928 $this->defaultShippingAddressId = $defaultShippingAddressId;
929 }
930
934 public function setBillingAddressIds(?array $billingAddressIds): void
935 {
936 $this->billingAddressIds = $billingAddressIds;
937 }
938
943 {
944 $this->defaultBillingAddressId = $defaultBillingAddressId;
945 }
946
950 public function setAssociateMode(?string $associateMode): void
951 {
952 $this->associateMode = $associateMode;
953 }
954
959 {
960 $this->associates = $associates;
961 }
962
967 {
968 $this->inheritedAssociates = $inheritedAssociates;
969 }
970
975 {
976 $this->parentUnit = $parentUnit;
977 }
978
983 {
984 $this->topLevelUnit = $topLevelUnit;
985 }
986
990 public function setApprovalRuleMode(?string $approvalRuleMode): void
991 {
992 $this->approvalRuleMode = $approvalRuleMode;
993 }
994
995
996 #[\ReturnTypeWillChange]
997 public function jsonSerialize()
998 {
999 $data = $this->toArray();
1000 if (isset($data[BusinessUnit::FIELD_CREATED_AT]) && $data[BusinessUnit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1001 $data[BusinessUnit::FIELD_CREATED_AT] = $data[BusinessUnit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1002 }
1003
1004 if (isset($data[BusinessUnit::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1005 $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1006 }
1007 return (object) $data;
1008 }
1009
1014 public static function resolveDiscriminatorClass($value): string
1015 {
1017 if (is_object($value) && isset($value->$fieldName)) {
1019 $discriminatorValue = $value->$fieldName;
1020 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
1021 return self::$discriminatorClasses[$discriminatorValue];
1022 }
1023 }
1024 if (is_array($value) && isset($value[$fieldName])) {
1026 $discriminatorValue = $value[$fieldName];
1027 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
1028 return self::$discriminatorClasses[$discriminatorValue];
1029 }
1030 }
1031
1033 $type = BusinessUnitModel::class;
1034 return $type;
1035 }
1036}
setInheritedStores(?StoreKeyReferenceCollection $inheritedStores)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setInheritedAssociates(?InheritedAssociateCollection $inheritedAssociates)
setTopLevelUnit(?BusinessUnitKeyReference $topLevelUnit)
setParentUnit(?BusinessUnitKeyReference $parentUnit)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?string $status=null, ?StoreKeyReferenceCollection $stores=null, ?StoreKeyReferenceCollection $inheritedStores=null, ?string $storeMode=null, ?string $name=null, ?string $contactEmail=null, ?CustomFields $custom=null, ?AddressCollection $addresses=null, ?array $shippingAddressIds=null, ?string $defaultShippingAddressId=null, ?array $billingAddressIds=null, ?string $defaultBillingAddressId=null, ?string $associateMode=null, ?AssociateCollection $associates=null, ?InheritedAssociateCollection $inheritedAssociates=null, ?BusinessUnitKeyReference $parentUnit=null, ?BusinessUnitKeyReference $topLevelUnit=null, ?string $approvalRuleMode=null, ?string $unitType=null)
static fromArray(array $data)