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
24use DateTimeImmutable;
25use stdClass;
26
30final class CompanyModel extends JsonObjectModel implements Company
31{
32 public const DISCRIMINATOR_VALUE = 'Company';
37 protected $id;
38
43 protected $version;
44
49 protected $createdAt;
50
55 protected $lastModifiedAt;
56
61 protected $lastModifiedBy;
62
67 protected $createdBy;
68
73 protected $key;
74
79 protected $status;
80
85 protected $stores;
86
92
97 protected $storeMode;
98
103 protected $unitType;
104
109 protected $name;
110
115 protected $contactEmail;
116
121 protected $custom;
122
128
133 protected $addresses;
134
140
146
152
158
163 protected $associateMode;
164
169 protected $associates;
170
176
181 protected $parentUnit;
182
187 protected $topLevelUnit;
188
194
195
199 public function __construct(
200 ?string $id = null,
201 ?int $version = null,
202 ?DateTimeImmutable $createdAt = null,
203 ?DateTimeImmutable $lastModifiedAt = null,
205 ?CreatedBy $createdBy = null,
206 ?string $key = null,
207 ?string $status = null,
210 ?string $storeMode = null,
211 ?string $name = null,
212 ?string $contactEmail = null,
213 ?CustomFields $custom = null,
216 ?array $shippingAddressIds = null,
217 ?string $defaultShippingAddressId = null,
218 ?array $billingAddressIds = null,
219 ?string $defaultBillingAddressId = null,
220 ?string $associateMode = null,
225 ?string $approvalRuleMode = null,
226 ?string $unitType = null
227 ) {
228 $this->id = $id;
229 $this->version = $version;
230 $this->createdAt = $createdAt;
231 $this->lastModifiedAt = $lastModifiedAt;
232 $this->lastModifiedBy = $lastModifiedBy;
233 $this->createdBy = $createdBy;
234 $this->key = $key;
235 $this->status = $status;
236 $this->stores = $stores;
237 $this->inheritedStores = $inheritedStores;
238 $this->storeMode = $storeMode;
239 $this->name = $name;
240 $this->contactEmail = $contactEmail;
241 $this->custom = $custom;
242 $this->customerGroupAssignments = $customerGroupAssignments;
243 $this->addresses = $addresses;
244 $this->shippingAddressIds = $shippingAddressIds;
245 $this->defaultShippingAddressId = $defaultShippingAddressId;
246 $this->billingAddressIds = $billingAddressIds;
247 $this->defaultBillingAddressId = $defaultBillingAddressId;
248 $this->associateMode = $associateMode;
249 $this->associates = $associates;
250 $this->inheritedAssociates = $inheritedAssociates;
251 $this->parentUnit = $parentUnit;
252 $this->topLevelUnit = $topLevelUnit;
253 $this->approvalRuleMode = $approvalRuleMode;
254 $this->unitType = $unitType ?? self::DISCRIMINATOR_VALUE;
255 }
256
263 public function getId()
264 {
265 if (is_null($this->id)) {
267 $data = $this->raw(self::FIELD_ID);
268 if (is_null($data)) {
269 return null;
270 }
271 $this->id = (string) $data;
272 }
273
274 return $this->id;
275 }
276
283 public function getVersion()
284 {
285 if (is_null($this->version)) {
287 $data = $this->raw(self::FIELD_VERSION);
288 if (is_null($data)) {
289 return null;
290 }
291 $this->version = (int) $data;
292 }
293
294 return $this->version;
295 }
296
303 public function getCreatedAt()
304 {
305 if (is_null($this->createdAt)) {
307 $data = $this->raw(self::FIELD_CREATED_AT);
308 if (is_null($data)) {
309 return null;
310 }
311 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
312 if (false === $data) {
313 return null;
314 }
315 $this->createdAt = $data;
316 }
317
318 return $this->createdAt;
319 }
320
327 public function getLastModifiedAt()
328 {
329 if (is_null($this->lastModifiedAt)) {
331 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
332 if (is_null($data)) {
333 return null;
334 }
335 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
336 if (false === $data) {
337 return null;
338 }
339 $this->lastModifiedAt = $data;
340 }
341
343 }
344
351 public function getLastModifiedBy()
352 {
353 if (is_null($this->lastModifiedBy)) {
355 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
356 if (is_null($data)) {
357 return null;
358 }
359
360 $this->lastModifiedBy = LastModifiedByModel::of($data);
361 }
362
364 }
365
372 public function getCreatedBy()
373 {
374 if (is_null($this->createdBy)) {
376 $data = $this->raw(self::FIELD_CREATED_BY);
377 if (is_null($data)) {
378 return null;
379 }
380
381 $this->createdBy = CreatedByModel::of($data);
382 }
383
384 return $this->createdBy;
385 }
386
393 public function getKey()
394 {
395 if (is_null($this->key)) {
397 $data = $this->raw(self::FIELD_KEY);
398 if (is_null($data)) {
399 return null;
400 }
401 $this->key = (string) $data;
402 }
403
404 return $this->key;
405 }
406
413 public function getStatus()
414 {
415 if (is_null($this->status)) {
417 $data = $this->raw(self::FIELD_STATUS);
418 if (is_null($data)) {
419 return null;
420 }
421 $this->status = (string) $data;
422 }
423
424 return $this->status;
425 }
426
435 public function getStores()
436 {
437 if (is_null($this->stores)) {
439 $data = $this->raw(self::FIELD_STORES);
440 if (is_null($data)) {
441 return null;
442 }
443 $this->stores = StoreKeyReferenceCollection::fromArray($data);
444 }
445
446 return $this->stores;
447 }
448
455 public function getInheritedStores()
456 {
457 if (is_null($this->inheritedStores)) {
459 $data = $this->raw(self::FIELD_INHERITED_STORES);
460 if (is_null($data)) {
461 return null;
462 }
463 $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data);
464 }
465
467 }
468
475 public function getStoreMode()
476 {
477 if (is_null($this->storeMode)) {
479 $data = $this->raw(self::FIELD_STORE_MODE);
480 if (is_null($data)) {
481 return null;
482 }
483 $this->storeMode = (string) $data;
484 }
485
486 return $this->storeMode;
487 }
488
495 public function getUnitType()
496 {
497 if (is_null($this->unitType)) {
499 $data = $this->raw(self::FIELD_UNIT_TYPE);
500 if (is_null($data)) {
501 return null;
502 }
503 $this->unitType = (string) $data;
504 }
505
506 return $this->unitType;
507 }
508
515 public function getName()
516 {
517 if (is_null($this->name)) {
519 $data = $this->raw(self::FIELD_NAME);
520 if (is_null($data)) {
521 return null;
522 }
523 $this->name = (string) $data;
524 }
525
526 return $this->name;
527 }
528
535 public function getContactEmail()
536 {
537 if (is_null($this->contactEmail)) {
539 $data = $this->raw(self::FIELD_CONTACT_EMAIL);
540 if (is_null($data)) {
541 return null;
542 }
543 $this->contactEmail = (string) $data;
544 }
545
546 return $this->contactEmail;
547 }
548
555 public function getCustom()
556 {
557 if (is_null($this->custom)) {
559 $data = $this->raw(self::FIELD_CUSTOM);
560 if (is_null($data)) {
561 return null;
562 }
563
564 $this->custom = CustomFieldsModel::of($data);
565 }
566
567 return $this->custom;
568 }
569
578 {
579 if (is_null($this->customerGroupAssignments)) {
581 $data = $this->raw(self::FIELD_CUSTOMER_GROUP_ASSIGNMENTS);
582 if (is_null($data)) {
583 return null;
584 }
585 $this->customerGroupAssignments = CustomerGroupAssignmentCollection::fromArray($data);
586 }
587
589 }
590
597 public function getAddresses()
598 {
599 if (is_null($this->addresses)) {
601 $data = $this->raw(self::FIELD_ADDRESSES);
602 if (is_null($data)) {
603 return null;
604 }
605 $this->addresses = AddressCollection::fromArray($data);
606 }
607
608 return $this->addresses;
609 }
610
617 public function getShippingAddressIds()
618 {
619 if (is_null($this->shippingAddressIds)) {
621 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
622 if (is_null($data)) {
623 return null;
624 }
625 $this->shippingAddressIds = $data;
626 }
627
629 }
630
638 {
639 if (is_null($this->defaultShippingAddressId)) {
641 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
642 if (is_null($data)) {
643 return null;
644 }
645 $this->defaultShippingAddressId = (string) $data;
646 }
647
649 }
650
657 public function getBillingAddressIds()
658 {
659 if (is_null($this->billingAddressIds)) {
661 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
662 if (is_null($data)) {
663 return null;
664 }
665 $this->billingAddressIds = $data;
666 }
667
669 }
670
678 {
679 if (is_null($this->defaultBillingAddressId)) {
681 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
682 if (is_null($data)) {
683 return null;
684 }
685 $this->defaultBillingAddressId = (string) $data;
686 }
687
689 }
690
697 public function getAssociateMode()
698 {
699 if (is_null($this->associateMode)) {
701 $data = $this->raw(self::FIELD_ASSOCIATE_MODE);
702 if (is_null($data)) {
703 return null;
704 }
705 $this->associateMode = (string) $data;
706 }
707
709 }
710
717 public function getAssociates()
718 {
719 if (is_null($this->associates)) {
721 $data = $this->raw(self::FIELD_ASSOCIATES);
722 if (is_null($data)) {
723 return null;
724 }
725 $this->associates = AssociateCollection::fromArray($data);
726 }
727
728 return $this->associates;
729 }
730
737 public function getInheritedAssociates()
738 {
739 if (is_null($this->inheritedAssociates)) {
741 $data = $this->raw(self::FIELD_INHERITED_ASSOCIATES);
742 if (is_null($data)) {
743 return null;
744 }
745 $this->inheritedAssociates = InheritedAssociateCollection::fromArray($data);
746 }
747
749 }
750
757 public function getParentUnit()
758 {
759 if (is_null($this->parentUnit)) {
761 $data = $this->raw(self::FIELD_PARENT_UNIT);
762 if (is_null($data)) {
763 return null;
764 }
765
766 $this->parentUnit = BusinessUnitKeyReferenceModel::of($data);
767 }
768
769 return $this->parentUnit;
770 }
771
778 public function getTopLevelUnit()
779 {
780 if (is_null($this->topLevelUnit)) {
782 $data = $this->raw(self::FIELD_TOP_LEVEL_UNIT);
783 if (is_null($data)) {
784 return null;
785 }
786
787 $this->topLevelUnit = BusinessUnitKeyReferenceModel::of($data);
788 }
789
790 return $this->topLevelUnit;
791 }
792
799 public function getApprovalRuleMode()
800 {
801 if (is_null($this->approvalRuleMode)) {
803 $data = $this->raw(self::FIELD_APPROVAL_RULE_MODE);
804 if (is_null($data)) {
805 return null;
806 }
807 $this->approvalRuleMode = (string) $data;
808 }
809
811 }
812
813
817 public function setId(?string $id): void
818 {
819 $this->id = $id;
820 }
821
825 public function setVersion(?int $version): void
826 {
827 $this->version = $version;
828 }
829
833 public function setCreatedAt(?DateTimeImmutable $createdAt): void
834 {
835 $this->createdAt = $createdAt;
836 }
837
841 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
842 {
843 $this->lastModifiedAt = $lastModifiedAt;
844 }
845
850 {
851 $this->lastModifiedBy = $lastModifiedBy;
852 }
853
857 public function setCreatedBy(?CreatedBy $createdBy): void
858 {
859 $this->createdBy = $createdBy;
860 }
861
865 public function setKey(?string $key): void
866 {
867 $this->key = $key;
868 }
869
873 public function setStatus(?string $status): void
874 {
875 $this->status = $status;
876 }
877
882 {
883 $this->stores = $stores;
884 }
885
890 {
891 $this->inheritedStores = $inheritedStores;
892 }
893
897 public function setStoreMode(?string $storeMode): void
898 {
899 $this->storeMode = $storeMode;
900 }
901
905 public function setName(?string $name): void
906 {
907 $this->name = $name;
908 }
909
913 public function setContactEmail(?string $contactEmail): void
914 {
915 $this->contactEmail = $contactEmail;
916 }
917
921 public function setCustom(?CustomFields $custom): void
922 {
923 $this->custom = $custom;
924 }
925
930 {
931 $this->customerGroupAssignments = $customerGroupAssignments;
932 }
933
938 {
939 $this->addresses = $addresses;
940 }
941
945 public function setShippingAddressIds(?array $shippingAddressIds): void
946 {
947 $this->shippingAddressIds = $shippingAddressIds;
948 }
949
954 {
955 $this->defaultShippingAddressId = $defaultShippingAddressId;
956 }
957
961 public function setBillingAddressIds(?array $billingAddressIds): void
962 {
963 $this->billingAddressIds = $billingAddressIds;
964 }
965
970 {
971 $this->defaultBillingAddressId = $defaultBillingAddressId;
972 }
973
977 public function setAssociateMode(?string $associateMode): void
978 {
979 $this->associateMode = $associateMode;
980 }
981
986 {
987 $this->associates = $associates;
988 }
989
994 {
995 $this->inheritedAssociates = $inheritedAssociates;
996 }
997
1002 {
1003 $this->parentUnit = $parentUnit;
1004 }
1005
1010 {
1011 $this->topLevelUnit = $topLevelUnit;
1012 }
1013
1017 public function setApprovalRuleMode(?string $approvalRuleMode): void
1018 {
1019 $this->approvalRuleMode = $approvalRuleMode;
1020 }
1021
1022
1023 #[\ReturnTypeWillChange]
1024 public function jsonSerialize()
1025 {
1026 $data = $this->toArray();
1027 if (isset($data[BusinessUnit::FIELD_CREATED_AT]) && $data[BusinessUnit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1028 $data[BusinessUnit::FIELD_CREATED_AT] = $data[BusinessUnit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1029 }
1030
1031 if (isset($data[BusinessUnit::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1032 $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1033 }
1034 return (object) $data;
1035 }
1036}
setStores(?StoreKeyReferenceCollection $stores)
setCustomerGroupAssignments(?CustomerGroupAssignmentCollection $customerGroupAssignments)
setInheritedStores(?StoreKeyReferenceCollection $inheritedStores)
setDefaultBillingAddressId(?string $defaultBillingAddressId)
setTopLevelUnit(?BusinessUnitKeyReference $topLevelUnit)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
__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)
setAssociates(?AssociateCollection $associates)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setInheritedAssociates(?InheritedAssociateCollection $inheritedAssociates)
setParentUnit(?BusinessUnitKeyReference $parentUnit)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
static fromArray(array $data)