commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CompanyModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
29final class CompanyModel extends JsonObjectModel implements Company
30{
31 public const DISCRIMINATOR_VALUE = 'Company';
36 protected $id;
37
42 protected $version;
43
48 protected $createdAt;
49
54 protected $lastModifiedAt;
55
60 protected $lastModifiedBy;
61
66 protected $createdBy;
67
72 protected $key;
73
78 protected $status;
79
84 protected $stores;
85
91
96 protected $storeMode;
97
102 protected $unitType;
103
108 protected $name;
109
114 protected $contactEmail;
115
120 protected $custom;
121
126 protected $addresses;
127
133
139
145
151
156 protected $associateMode;
157
162 protected $associates;
163
169
174 protected $parentUnit;
175
180 protected $topLevelUnit;
181
187
188
192 public function __construct(
193 ?string $id = null,
194 ?int $version = null,
195 ?DateTimeImmutable $createdAt = null,
196 ?DateTimeImmutable $lastModifiedAt = null,
198 ?CreatedBy $createdBy = null,
199 ?string $key = null,
200 ?string $status = null,
203 ?string $storeMode = null,
204 ?string $name = null,
205 ?string $contactEmail = null,
206 ?CustomFields $custom = null,
208 ?array $shippingAddressIds = null,
209 ?string $defaultShippingAddressId = null,
210 ?array $billingAddressIds = null,
211 ?string $defaultBillingAddressId = null,
212 ?string $associateMode = null,
217 ?string $approvalRuleMode = null,
218 ?string $unitType = null
219 ) {
220 $this->id = $id;
221 $this->version = $version;
222 $this->createdAt = $createdAt;
223 $this->lastModifiedAt = $lastModifiedAt;
224 $this->lastModifiedBy = $lastModifiedBy;
225 $this->createdBy = $createdBy;
226 $this->key = $key;
227 $this->status = $status;
228 $this->stores = $stores;
229 $this->inheritedStores = $inheritedStores;
230 $this->storeMode = $storeMode;
231 $this->name = $name;
232 $this->contactEmail = $contactEmail;
233 $this->custom = $custom;
234 $this->addresses = $addresses;
235 $this->shippingAddressIds = $shippingAddressIds;
236 $this->defaultShippingAddressId = $defaultShippingAddressId;
237 $this->billingAddressIds = $billingAddressIds;
238 $this->defaultBillingAddressId = $defaultBillingAddressId;
239 $this->associateMode = $associateMode;
240 $this->associates = $associates;
241 $this->inheritedAssociates = $inheritedAssociates;
242 $this->parentUnit = $parentUnit;
243 $this->topLevelUnit = $topLevelUnit;
244 $this->approvalRuleMode = $approvalRuleMode;
245 $this->unitType = $unitType ?? self::DISCRIMINATOR_VALUE;
246 }
247
254 public function getId()
255 {
256 if (is_null($this->id)) {
258 $data = $this->raw(self::FIELD_ID);
259 if (is_null($data)) {
260 return null;
261 }
262 $this->id = (string) $data;
263 }
264
265 return $this->id;
266 }
267
274 public function getVersion()
275 {
276 if (is_null($this->version)) {
278 $data = $this->raw(self::FIELD_VERSION);
279 if (is_null($data)) {
280 return null;
281 }
282 $this->version = (int) $data;
283 }
284
285 return $this->version;
286 }
287
294 public function getCreatedAt()
295 {
296 if (is_null($this->createdAt)) {
298 $data = $this->raw(self::FIELD_CREATED_AT);
299 if (is_null($data)) {
300 return null;
301 }
302 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
303 if (false === $data) {
304 return null;
305 }
306 $this->createdAt = $data;
307 }
308
309 return $this->createdAt;
310 }
311
318 public function getLastModifiedAt()
319 {
320 if (is_null($this->lastModifiedAt)) {
322 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
323 if (is_null($data)) {
324 return null;
325 }
326 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
327 if (false === $data) {
328 return null;
329 }
330 $this->lastModifiedAt = $data;
331 }
332
334 }
335
342 public function getLastModifiedBy()
343 {
344 if (is_null($this->lastModifiedBy)) {
346 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
347 if (is_null($data)) {
348 return null;
349 }
350
351 $this->lastModifiedBy = LastModifiedByModel::of($data);
352 }
353
355 }
356
363 public function getCreatedBy()
364 {
365 if (is_null($this->createdBy)) {
367 $data = $this->raw(self::FIELD_CREATED_BY);
368 if (is_null($data)) {
369 return null;
370 }
371
372 $this->createdBy = CreatedByModel::of($data);
373 }
374
375 return $this->createdBy;
376 }
377
384 public function getKey()
385 {
386 if (is_null($this->key)) {
388 $data = $this->raw(self::FIELD_KEY);
389 if (is_null($data)) {
390 return null;
391 }
392 $this->key = (string) $data;
393 }
394
395 return $this->key;
396 }
397
404 public function getStatus()
405 {
406 if (is_null($this->status)) {
408 $data = $this->raw(self::FIELD_STATUS);
409 if (is_null($data)) {
410 return null;
411 }
412 $this->status = (string) $data;
413 }
414
415 return $this->status;
416 }
417
426 public function getStores()
427 {
428 if (is_null($this->stores)) {
430 $data = $this->raw(self::FIELD_STORES);
431 if (is_null($data)) {
432 return null;
433 }
434 $this->stores = StoreKeyReferenceCollection::fromArray($data);
435 }
436
437 return $this->stores;
438 }
439
446 public function getInheritedStores()
447 {
448 if (is_null($this->inheritedStores)) {
450 $data = $this->raw(self::FIELD_INHERITED_STORES);
451 if (is_null($data)) {
452 return null;
453 }
454 $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data);
455 }
456
458 }
459
466 public function getStoreMode()
467 {
468 if (is_null($this->storeMode)) {
470 $data = $this->raw(self::FIELD_STORE_MODE);
471 if (is_null($data)) {
472 return null;
473 }
474 $this->storeMode = (string) $data;
475 }
476
477 return $this->storeMode;
478 }
479
486 public function getUnitType()
487 {
488 if (is_null($this->unitType)) {
490 $data = $this->raw(self::FIELD_UNIT_TYPE);
491 if (is_null($data)) {
492 return null;
493 }
494 $this->unitType = (string) $data;
495 }
496
497 return $this->unitType;
498 }
499
506 public function getName()
507 {
508 if (is_null($this->name)) {
510 $data = $this->raw(self::FIELD_NAME);
511 if (is_null($data)) {
512 return null;
513 }
514 $this->name = (string) $data;
515 }
516
517 return $this->name;
518 }
519
526 public function getContactEmail()
527 {
528 if (is_null($this->contactEmail)) {
530 $data = $this->raw(self::FIELD_CONTACT_EMAIL);
531 if (is_null($data)) {
532 return null;
533 }
534 $this->contactEmail = (string) $data;
535 }
536
537 return $this->contactEmail;
538 }
539
546 public function getCustom()
547 {
548 if (is_null($this->custom)) {
550 $data = $this->raw(self::FIELD_CUSTOM);
551 if (is_null($data)) {
552 return null;
553 }
554
555 $this->custom = CustomFieldsModel::of($data);
556 }
557
558 return $this->custom;
559 }
560
567 public function getAddresses()
568 {
569 if (is_null($this->addresses)) {
571 $data = $this->raw(self::FIELD_ADDRESSES);
572 if (is_null($data)) {
573 return null;
574 }
575 $this->addresses = AddressCollection::fromArray($data);
576 }
577
578 return $this->addresses;
579 }
580
587 public function getShippingAddressIds()
588 {
589 if (is_null($this->shippingAddressIds)) {
591 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
592 if (is_null($data)) {
593 return null;
594 }
595 $this->shippingAddressIds = $data;
596 }
597
599 }
600
608 {
609 if (is_null($this->defaultShippingAddressId)) {
611 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
612 if (is_null($data)) {
613 return null;
614 }
615 $this->defaultShippingAddressId = (string) $data;
616 }
617
619 }
620
627 public function getBillingAddressIds()
628 {
629 if (is_null($this->billingAddressIds)) {
631 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
632 if (is_null($data)) {
633 return null;
634 }
635 $this->billingAddressIds = $data;
636 }
637
639 }
640
648 {
649 if (is_null($this->defaultBillingAddressId)) {
651 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
652 if (is_null($data)) {
653 return null;
654 }
655 $this->defaultBillingAddressId = (string) $data;
656 }
657
659 }
660
667 public function getAssociateMode()
668 {
669 if (is_null($this->associateMode)) {
671 $data = $this->raw(self::FIELD_ASSOCIATE_MODE);
672 if (is_null($data)) {
673 return null;
674 }
675 $this->associateMode = (string) $data;
676 }
677
679 }
680
687 public function getAssociates()
688 {
689 if (is_null($this->associates)) {
691 $data = $this->raw(self::FIELD_ASSOCIATES);
692 if (is_null($data)) {
693 return null;
694 }
695 $this->associates = AssociateCollection::fromArray($data);
696 }
697
698 return $this->associates;
699 }
700
707 public function getInheritedAssociates()
708 {
709 if (is_null($this->inheritedAssociates)) {
711 $data = $this->raw(self::FIELD_INHERITED_ASSOCIATES);
712 if (is_null($data)) {
713 return null;
714 }
715 $this->inheritedAssociates = InheritedAssociateCollection::fromArray($data);
716 }
717
719 }
720
727 public function getParentUnit()
728 {
729 if (is_null($this->parentUnit)) {
731 $data = $this->raw(self::FIELD_PARENT_UNIT);
732 if (is_null($data)) {
733 return null;
734 }
735
736 $this->parentUnit = BusinessUnitKeyReferenceModel::of($data);
737 }
738
739 return $this->parentUnit;
740 }
741
748 public function getTopLevelUnit()
749 {
750 if (is_null($this->topLevelUnit)) {
752 $data = $this->raw(self::FIELD_TOP_LEVEL_UNIT);
753 if (is_null($data)) {
754 return null;
755 }
756
757 $this->topLevelUnit = BusinessUnitKeyReferenceModel::of($data);
758 }
759
760 return $this->topLevelUnit;
761 }
762
769 public function getApprovalRuleMode()
770 {
771 if (is_null($this->approvalRuleMode)) {
773 $data = $this->raw(self::FIELD_APPROVAL_RULE_MODE);
774 if (is_null($data)) {
775 return null;
776 }
777 $this->approvalRuleMode = (string) $data;
778 }
779
781 }
782
783
787 public function setId(?string $id): void
788 {
789 $this->id = $id;
790 }
791
795 public function setVersion(?int $version): void
796 {
797 $this->version = $version;
798 }
799
803 public function setCreatedAt(?DateTimeImmutable $createdAt): void
804 {
805 $this->createdAt = $createdAt;
806 }
807
811 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
812 {
813 $this->lastModifiedAt = $lastModifiedAt;
814 }
815
820 {
821 $this->lastModifiedBy = $lastModifiedBy;
822 }
823
827 public function setCreatedBy(?CreatedBy $createdBy): void
828 {
829 $this->createdBy = $createdBy;
830 }
831
835 public function setKey(?string $key): void
836 {
837 $this->key = $key;
838 }
839
843 public function setStatus(?string $status): void
844 {
845 $this->status = $status;
846 }
847
852 {
853 $this->stores = $stores;
854 }
855
860 {
861 $this->inheritedStores = $inheritedStores;
862 }
863
867 public function setStoreMode(?string $storeMode): void
868 {
869 $this->storeMode = $storeMode;
870 }
871
875 public function setName(?string $name): void
876 {
877 $this->name = $name;
878 }
879
883 public function setContactEmail(?string $contactEmail): void
884 {
885 $this->contactEmail = $contactEmail;
886 }
887
891 public function setCustom(?CustomFields $custom): void
892 {
893 $this->custom = $custom;
894 }
895
900 {
901 $this->addresses = $addresses;
902 }
903
907 public function setShippingAddressIds(?array $shippingAddressIds): void
908 {
909 $this->shippingAddressIds = $shippingAddressIds;
910 }
911
916 {
917 $this->defaultShippingAddressId = $defaultShippingAddressId;
918 }
919
923 public function setBillingAddressIds(?array $billingAddressIds): void
924 {
925 $this->billingAddressIds = $billingAddressIds;
926 }
927
932 {
933 $this->defaultBillingAddressId = $defaultBillingAddressId;
934 }
935
939 public function setAssociateMode(?string $associateMode): void
940 {
941 $this->associateMode = $associateMode;
942 }
943
948 {
949 $this->associates = $associates;
950 }
951
956 {
957 $this->inheritedAssociates = $inheritedAssociates;
958 }
959
964 {
965 $this->parentUnit = $parentUnit;
966 }
967
972 {
973 $this->topLevelUnit = $topLevelUnit;
974 }
975
979 public function setApprovalRuleMode(?string $approvalRuleMode): void
980 {
981 $this->approvalRuleMode = $approvalRuleMode;
982 }
983
984
985 #[\ReturnTypeWillChange]
986 public function jsonSerialize()
987 {
988 $data = $this->toArray();
989 if (isset($data[BusinessUnit::FIELD_CREATED_AT]) && $data[BusinessUnit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
990 $data[BusinessUnit::FIELD_CREATED_AT] = $data[BusinessUnit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
991 }
992
993 if (isset($data[BusinessUnit::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
994 $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
995 }
996 return (object) $data;
997 }
998}
__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)
setStores(?StoreKeyReferenceCollection $stores)
setInheritedStores(?StoreKeyReferenceCollection $inheritedStores)
setDefaultBillingAddressId(?string $defaultBillingAddressId)
setTopLevelUnit(?BusinessUnitKeyReference $topLevelUnit)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setAssociates(?AssociateCollection $associates)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setInheritedAssociates(?InheritedAssociateCollection $inheritedAssociates)
setParentUnit(?BusinessUnitKeyReference $parentUnit)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
static fromArray(array $data)