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
26use DateTimeImmutable;
27use stdClass;
28
32final class BusinessUnitModel extends JsonObjectModel implements BusinessUnit
33{
34 public const DISCRIMINATOR_VALUE = '';
39 protected $id;
40
45 protected $version;
46
51 protected $createdAt;
52
57 protected $lastModifiedAt;
58
63 protected $lastModifiedBy;
64
69 protected $createdBy;
70
75 protected $key;
76
81 protected $status;
82
87 protected $stores;
88
94
99 protected $storeMode;
100
105 protected $unitType;
106
111 protected $name;
112
117 protected $contactEmail;
118
123 protected $custom;
124
130
135 protected $addresses;
136
142
148
154
160
165 protected $associateMode;
166
171 protected $associates;
172
178
183 protected $parentUnit;
184
189 protected $topLevelUnit;
190
196
201 private static $discriminatorClasses = [
202 'Company' => CompanyModel::class,
203 'Division' => DivisionModel::class,
204 ];
205
209 public function __construct(
210 ?string $id = null,
211 ?int $version = null,
212 ?DateTimeImmutable $createdAt = null,
213 ?DateTimeImmutable $lastModifiedAt = null,
215 ?CreatedBy $createdBy = null,
216 ?string $key = null,
217 ?string $status = null,
220 ?string $storeMode = null,
221 ?string $name = null,
222 ?string $contactEmail = null,
223 ?CustomFields $custom = null,
226 ?array $shippingAddressIds = null,
227 ?string $defaultShippingAddressId = null,
228 ?array $billingAddressIds = null,
229 ?string $defaultBillingAddressId = null,
230 ?string $associateMode = null,
235 ?string $approvalRuleMode = null,
236 ?string $unitType = null
237 ) {
238 $this->id = $id;
239 $this->version = $version;
240 $this->createdAt = $createdAt;
241 $this->lastModifiedAt = $lastModifiedAt;
242 $this->lastModifiedBy = $lastModifiedBy;
243 $this->createdBy = $createdBy;
244 $this->key = $key;
245 $this->status = $status;
246 $this->stores = $stores;
247 $this->inheritedStores = $inheritedStores;
248 $this->storeMode = $storeMode;
249 $this->name = $name;
250 $this->contactEmail = $contactEmail;
251 $this->custom = $custom;
252 $this->customerGroupAssignments = $customerGroupAssignments;
253 $this->addresses = $addresses;
254 $this->shippingAddressIds = $shippingAddressIds;
255 $this->defaultShippingAddressId = $defaultShippingAddressId;
256 $this->billingAddressIds = $billingAddressIds;
257 $this->defaultBillingAddressId = $defaultBillingAddressId;
258 $this->associateMode = $associateMode;
259 $this->associates = $associates;
260 $this->inheritedAssociates = $inheritedAssociates;
261 $this->parentUnit = $parentUnit;
262 $this->topLevelUnit = $topLevelUnit;
263 $this->approvalRuleMode = $approvalRuleMode;
264 $this->unitType = $unitType;
265 }
266
273 public function getId()
274 {
275 if (is_null($this->id)) {
277 $data = $this->raw(self::FIELD_ID);
278 if (is_null($data)) {
279 return null;
280 }
281 $this->id = (string) $data;
282 }
283
284 return $this->id;
285 }
286
293 public function getVersion()
294 {
295 if (is_null($this->version)) {
297 $data = $this->raw(self::FIELD_VERSION);
298 if (is_null($data)) {
299 return null;
300 }
301 $this->version = (int) $data;
302 }
303
304 return $this->version;
305 }
306
313 public function getCreatedAt()
314 {
315 if (is_null($this->createdAt)) {
317 $data = $this->raw(self::FIELD_CREATED_AT);
318 if (is_null($data)) {
319 return null;
320 }
321 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
322 if (false === $data) {
323 return null;
324 }
325 $this->createdAt = $data;
326 }
327
328 return $this->createdAt;
329 }
330
337 public function getLastModifiedAt()
338 {
339 if (is_null($this->lastModifiedAt)) {
341 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
342 if (is_null($data)) {
343 return null;
344 }
345 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
346 if (false === $data) {
347 return null;
348 }
349 $this->lastModifiedAt = $data;
350 }
351
353 }
354
361 public function getLastModifiedBy()
362 {
363 if (is_null($this->lastModifiedBy)) {
365 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
366 if (is_null($data)) {
367 return null;
368 }
369
370 $this->lastModifiedBy = LastModifiedByModel::of($data);
371 }
372
374 }
375
382 public function getCreatedBy()
383 {
384 if (is_null($this->createdBy)) {
386 $data = $this->raw(self::FIELD_CREATED_BY);
387 if (is_null($data)) {
388 return null;
389 }
390
391 $this->createdBy = CreatedByModel::of($data);
392 }
393
394 return $this->createdBy;
395 }
396
403 public function getKey()
404 {
405 if (is_null($this->key)) {
407 $data = $this->raw(self::FIELD_KEY);
408 if (is_null($data)) {
409 return null;
410 }
411 $this->key = (string) $data;
412 }
413
414 return $this->key;
415 }
416
423 public function getStatus()
424 {
425 if (is_null($this->status)) {
427 $data = $this->raw(self::FIELD_STATUS);
428 if (is_null($data)) {
429 return null;
430 }
431 $this->status = (string) $data;
432 }
433
434 return $this->status;
435 }
436
445 public function getStores()
446 {
447 if (is_null($this->stores)) {
449 $data = $this->raw(self::FIELD_STORES);
450 if (is_null($data)) {
451 return null;
452 }
453 $this->stores = StoreKeyReferenceCollection::fromArray($data);
454 }
455
456 return $this->stores;
457 }
458
465 public function getInheritedStores()
466 {
467 if (is_null($this->inheritedStores)) {
469 $data = $this->raw(self::FIELD_INHERITED_STORES);
470 if (is_null($data)) {
471 return null;
472 }
473 $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data);
474 }
475
477 }
478
485 public function getStoreMode()
486 {
487 if (is_null($this->storeMode)) {
489 $data = $this->raw(self::FIELD_STORE_MODE);
490 if (is_null($data)) {
491 return null;
492 }
493 $this->storeMode = (string) $data;
494 }
495
496 return $this->storeMode;
497 }
498
505 public function getUnitType()
506 {
507 if (is_null($this->unitType)) {
509 $data = $this->raw(self::FIELD_UNIT_TYPE);
510 if (is_null($data)) {
511 return null;
512 }
513 $this->unitType = (string) $data;
514 }
515
516 return $this->unitType;
517 }
518
525 public function getName()
526 {
527 if (is_null($this->name)) {
529 $data = $this->raw(self::FIELD_NAME);
530 if (is_null($data)) {
531 return null;
532 }
533 $this->name = (string) $data;
534 }
535
536 return $this->name;
537 }
538
545 public function getContactEmail()
546 {
547 if (is_null($this->contactEmail)) {
549 $data = $this->raw(self::FIELD_CONTACT_EMAIL);
550 if (is_null($data)) {
551 return null;
552 }
553 $this->contactEmail = (string) $data;
554 }
555
556 return $this->contactEmail;
557 }
558
565 public function getCustom()
566 {
567 if (is_null($this->custom)) {
569 $data = $this->raw(self::FIELD_CUSTOM);
570 if (is_null($data)) {
571 return null;
572 }
573
574 $this->custom = CustomFieldsModel::of($data);
575 }
576
577 return $this->custom;
578 }
579
588 {
589 if (is_null($this->customerGroupAssignments)) {
591 $data = $this->raw(self::FIELD_CUSTOMER_GROUP_ASSIGNMENTS);
592 if (is_null($data)) {
593 return null;
594 }
595 $this->customerGroupAssignments = CustomerGroupAssignmentCollection::fromArray($data);
596 }
597
599 }
600
607 public function getAddresses()
608 {
609 if (is_null($this->addresses)) {
611 $data = $this->raw(self::FIELD_ADDRESSES);
612 if (is_null($data)) {
613 return null;
614 }
615 $this->addresses = AddressCollection::fromArray($data);
616 }
617
618 return $this->addresses;
619 }
620
627 public function getShippingAddressIds()
628 {
629 if (is_null($this->shippingAddressIds)) {
631 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
632 if (is_null($data)) {
633 return null;
634 }
635 $this->shippingAddressIds = $data;
636 }
637
639 }
640
648 {
649 if (is_null($this->defaultShippingAddressId)) {
651 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
652 if (is_null($data)) {
653 return null;
654 }
655 $this->defaultShippingAddressId = (string) $data;
656 }
657
659 }
660
667 public function getBillingAddressIds()
668 {
669 if (is_null($this->billingAddressIds)) {
671 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
672 if (is_null($data)) {
673 return null;
674 }
675 $this->billingAddressIds = $data;
676 }
677
679 }
680
688 {
689 if (is_null($this->defaultBillingAddressId)) {
691 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
692 if (is_null($data)) {
693 return null;
694 }
695 $this->defaultBillingAddressId = (string) $data;
696 }
697
699 }
700
707 public function getAssociateMode()
708 {
709 if (is_null($this->associateMode)) {
711 $data = $this->raw(self::FIELD_ASSOCIATE_MODE);
712 if (is_null($data)) {
713 return null;
714 }
715 $this->associateMode = (string) $data;
716 }
717
719 }
720
727 public function getAssociates()
728 {
729 if (is_null($this->associates)) {
731 $data = $this->raw(self::FIELD_ASSOCIATES);
732 if (is_null($data)) {
733 return null;
734 }
735 $this->associates = AssociateCollection::fromArray($data);
736 }
737
738 return $this->associates;
739 }
740
747 public function getInheritedAssociates()
748 {
749 if (is_null($this->inheritedAssociates)) {
751 $data = $this->raw(self::FIELD_INHERITED_ASSOCIATES);
752 if (is_null($data)) {
753 return null;
754 }
755 $this->inheritedAssociates = InheritedAssociateCollection::fromArray($data);
756 }
757
759 }
760
767 public function getParentUnit()
768 {
769 if (is_null($this->parentUnit)) {
771 $data = $this->raw(self::FIELD_PARENT_UNIT);
772 if (is_null($data)) {
773 return null;
774 }
775
776 $this->parentUnit = BusinessUnitKeyReferenceModel::of($data);
777 }
778
779 return $this->parentUnit;
780 }
781
788 public function getTopLevelUnit()
789 {
790 if (is_null($this->topLevelUnit)) {
792 $data = $this->raw(self::FIELD_TOP_LEVEL_UNIT);
793 if (is_null($data)) {
794 return null;
795 }
796
797 $this->topLevelUnit = BusinessUnitKeyReferenceModel::of($data);
798 }
799
800 return $this->topLevelUnit;
801 }
802
810 public function getApprovalRuleMode()
811 {
812 if (is_null($this->approvalRuleMode)) {
814 $data = $this->raw(self::FIELD_APPROVAL_RULE_MODE);
815 if (is_null($data)) {
816 return null;
817 }
818 $this->approvalRuleMode = (string) $data;
819 }
820
822 }
823
824
828 public function setId(?string $id): void
829 {
830 $this->id = $id;
831 }
832
836 public function setVersion(?int $version): void
837 {
838 $this->version = $version;
839 }
840
844 public function setCreatedAt(?DateTimeImmutable $createdAt): void
845 {
846 $this->createdAt = $createdAt;
847 }
848
852 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
853 {
854 $this->lastModifiedAt = $lastModifiedAt;
855 }
856
861 {
862 $this->lastModifiedBy = $lastModifiedBy;
863 }
864
868 public function setCreatedBy(?CreatedBy $createdBy): void
869 {
870 $this->createdBy = $createdBy;
871 }
872
876 public function setKey(?string $key): void
877 {
878 $this->key = $key;
879 }
880
884 public function setStatus(?string $status): void
885 {
886 $this->status = $status;
887 }
888
893 {
894 $this->stores = $stores;
895 }
896
901 {
902 $this->inheritedStores = $inheritedStores;
903 }
904
908 public function setStoreMode(?string $storeMode): void
909 {
910 $this->storeMode = $storeMode;
911 }
912
916 public function setName(?string $name): void
917 {
918 $this->name = $name;
919 }
920
924 public function setContactEmail(?string $contactEmail): void
925 {
926 $this->contactEmail = $contactEmail;
927 }
928
932 public function setCustom(?CustomFields $custom): void
933 {
934 $this->custom = $custom;
935 }
936
941 {
942 $this->customerGroupAssignments = $customerGroupAssignments;
943 }
944
949 {
950 $this->addresses = $addresses;
951 }
952
956 public function setShippingAddressIds(?array $shippingAddressIds): void
957 {
958 $this->shippingAddressIds = $shippingAddressIds;
959 }
960
965 {
966 $this->defaultShippingAddressId = $defaultShippingAddressId;
967 }
968
972 public function setBillingAddressIds(?array $billingAddressIds): void
973 {
974 $this->billingAddressIds = $billingAddressIds;
975 }
976
981 {
982 $this->defaultBillingAddressId = $defaultBillingAddressId;
983 }
984
988 public function setAssociateMode(?string $associateMode): void
989 {
990 $this->associateMode = $associateMode;
991 }
992
997 {
998 $this->associates = $associates;
999 }
1000
1005 {
1006 $this->inheritedAssociates = $inheritedAssociates;
1007 }
1008
1013 {
1014 $this->parentUnit = $parentUnit;
1015 }
1016
1021 {
1022 $this->topLevelUnit = $topLevelUnit;
1023 }
1024
1028 public function setApprovalRuleMode(?string $approvalRuleMode): void
1029 {
1030 $this->approvalRuleMode = $approvalRuleMode;
1031 }
1032
1033
1034 #[\ReturnTypeWillChange]
1035 public function jsonSerialize()
1036 {
1037 $data = $this->toArray();
1038 if (isset($data[BusinessUnit::FIELD_CREATED_AT]) && $data[BusinessUnit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1039 $data[BusinessUnit::FIELD_CREATED_AT] = $data[BusinessUnit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1040 }
1041
1042 if (isset($data[BusinessUnit::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1043 $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1044 }
1045 return (object) $data;
1046 }
1047
1052 public static function resolveDiscriminatorClass($value): string
1053 {
1055 if (is_object($value) && isset($value->$fieldName)) {
1057 $discriminatorValue = $value->$fieldName;
1058 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
1059 return self::$discriminatorClasses[$discriminatorValue];
1060 }
1061 }
1062 if (is_array($value) && isset($value[$fieldName])) {
1064 $discriminatorValue = $value[$fieldName];
1065 if (isset(self::$discriminatorClasses[$discriminatorValue])) {
1066 return self::$discriminatorClasses[$discriminatorValue];
1067 }
1068 }
1069
1071 $type = BusinessUnitModel::class;
1072 return $type;
1073 }
1074}
setInheritedStores(?StoreKeyReferenceCollection $inheritedStores)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setCustomerGroupAssignments(?CustomerGroupAssignmentCollection $customerGroupAssignments)
setInheritedAssociates(?InheritedAssociateCollection $inheritedAssociates)
setTopLevelUnit(?BusinessUnitKeyReference $topLevelUnit)
__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, ?CustomerGroupAssignmentCollection $customerGroupAssignments=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)