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
90 protected $storeMode;
91
96 protected $unitType;
97
102 protected $name;
103
108 protected $contactEmail;
109
114 protected $custom;
115
120 protected $addresses;
121
127
133
139
145
150 protected $associateMode;
151
156 protected $associates;
157
163
168 protected $parentUnit;
169
174 protected $topLevelUnit;
175
181
182
186 public function __construct(
187 ?string $id = null,
188 ?int $version = null,
189 ?DateTimeImmutable $createdAt = null,
190 ?DateTimeImmutable $lastModifiedAt = null,
192 ?CreatedBy $createdBy = null,
193 ?string $key = null,
194 ?string $status = null,
196 ?string $storeMode = null,
197 ?string $name = null,
198 ?string $contactEmail = null,
199 ?CustomFields $custom = null,
201 ?array $shippingAddressIds = null,
202 ?string $defaultShippingAddressId = null,
203 ?array $billingAddressIds = null,
204 ?string $defaultBillingAddressId = null,
205 ?string $associateMode = null,
210 ?string $approvalRuleMode = null,
211 ?string $unitType = null
212 ) {
213 $this->id = $id;
214 $this->version = $version;
215 $this->createdAt = $createdAt;
216 $this->lastModifiedAt = $lastModifiedAt;
217 $this->lastModifiedBy = $lastModifiedBy;
218 $this->createdBy = $createdBy;
219 $this->key = $key;
220 $this->status = $status;
221 $this->stores = $stores;
222 $this->storeMode = $storeMode;
223 $this->name = $name;
224 $this->contactEmail = $contactEmail;
225 $this->custom = $custom;
226 $this->addresses = $addresses;
227 $this->shippingAddressIds = $shippingAddressIds;
228 $this->defaultShippingAddressId = $defaultShippingAddressId;
229 $this->billingAddressIds = $billingAddressIds;
230 $this->defaultBillingAddressId = $defaultBillingAddressId;
231 $this->associateMode = $associateMode;
232 $this->associates = $associates;
233 $this->inheritedAssociates = $inheritedAssociates;
234 $this->parentUnit = $parentUnit;
235 $this->topLevelUnit = $topLevelUnit;
236 $this->approvalRuleMode = $approvalRuleMode;
237 $this->unitType = $unitType ?? self::DISCRIMINATOR_VALUE;
238 }
239
246 public function getId()
247 {
248 if (is_null($this->id)) {
250 $data = $this->raw(self::FIELD_ID);
251 if (is_null($data)) {
252 return null;
253 }
254 $this->id = (string) $data;
255 }
256
257 return $this->id;
258 }
259
266 public function getVersion()
267 {
268 if (is_null($this->version)) {
270 $data = $this->raw(self::FIELD_VERSION);
271 if (is_null($data)) {
272 return null;
273 }
274 $this->version = (int) $data;
275 }
276
277 return $this->version;
278 }
279
286 public function getCreatedAt()
287 {
288 if (is_null($this->createdAt)) {
290 $data = $this->raw(self::FIELD_CREATED_AT);
291 if (is_null($data)) {
292 return null;
293 }
294 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
295 if (false === $data) {
296 return null;
297 }
298 $this->createdAt = $data;
299 }
300
301 return $this->createdAt;
302 }
303
310 public function getLastModifiedAt()
311 {
312 if (is_null($this->lastModifiedAt)) {
314 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
315 if (is_null($data)) {
316 return null;
317 }
318 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
319 if (false === $data) {
320 return null;
321 }
322 $this->lastModifiedAt = $data;
323 }
324
326 }
327
334 public function getLastModifiedBy()
335 {
336 if (is_null($this->lastModifiedBy)) {
338 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
339 if (is_null($data)) {
340 return null;
341 }
342
343 $this->lastModifiedBy = LastModifiedByModel::of($data);
344 }
345
347 }
348
355 public function getCreatedBy()
356 {
357 if (is_null($this->createdBy)) {
359 $data = $this->raw(self::FIELD_CREATED_BY);
360 if (is_null($data)) {
361 return null;
362 }
363
364 $this->createdBy = CreatedByModel::of($data);
365 }
366
367 return $this->createdBy;
368 }
369
376 public function getKey()
377 {
378 if (is_null($this->key)) {
380 $data = $this->raw(self::FIELD_KEY);
381 if (is_null($data)) {
382 return null;
383 }
384 $this->key = (string) $data;
385 }
386
387 return $this->key;
388 }
389
396 public function getStatus()
397 {
398 if (is_null($this->status)) {
400 $data = $this->raw(self::FIELD_STATUS);
401 if (is_null($data)) {
402 return null;
403 }
404 $this->status = (string) $data;
405 }
406
407 return $this->status;
408 }
409
418 public function getStores()
419 {
420 if (is_null($this->stores)) {
422 $data = $this->raw(self::FIELD_STORES);
423 if (is_null($data)) {
424 return null;
425 }
426 $this->stores = StoreKeyReferenceCollection::fromArray($data);
427 }
428
429 return $this->stores;
430 }
431
438 public function getStoreMode()
439 {
440 if (is_null($this->storeMode)) {
442 $data = $this->raw(self::FIELD_STORE_MODE);
443 if (is_null($data)) {
444 return null;
445 }
446 $this->storeMode = (string) $data;
447 }
448
449 return $this->storeMode;
450 }
451
458 public function getUnitType()
459 {
460 if (is_null($this->unitType)) {
462 $data = $this->raw(self::FIELD_UNIT_TYPE);
463 if (is_null($data)) {
464 return null;
465 }
466 $this->unitType = (string) $data;
467 }
468
469 return $this->unitType;
470 }
471
478 public function getName()
479 {
480 if (is_null($this->name)) {
482 $data = $this->raw(self::FIELD_NAME);
483 if (is_null($data)) {
484 return null;
485 }
486 $this->name = (string) $data;
487 }
488
489 return $this->name;
490 }
491
498 public function getContactEmail()
499 {
500 if (is_null($this->contactEmail)) {
502 $data = $this->raw(self::FIELD_CONTACT_EMAIL);
503 if (is_null($data)) {
504 return null;
505 }
506 $this->contactEmail = (string) $data;
507 }
508
509 return $this->contactEmail;
510 }
511
518 public function getCustom()
519 {
520 if (is_null($this->custom)) {
522 $data = $this->raw(self::FIELD_CUSTOM);
523 if (is_null($data)) {
524 return null;
525 }
526
527 $this->custom = CustomFieldsModel::of($data);
528 }
529
530 return $this->custom;
531 }
532
539 public function getAddresses()
540 {
541 if (is_null($this->addresses)) {
543 $data = $this->raw(self::FIELD_ADDRESSES);
544 if (is_null($data)) {
545 return null;
546 }
547 $this->addresses = AddressCollection::fromArray($data);
548 }
549
550 return $this->addresses;
551 }
552
559 public function getShippingAddressIds()
560 {
561 if (is_null($this->shippingAddressIds)) {
563 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
564 if (is_null($data)) {
565 return null;
566 }
567 $this->shippingAddressIds = $data;
568 }
569
571 }
572
580 {
581 if (is_null($this->defaultShippingAddressId)) {
583 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
584 if (is_null($data)) {
585 return null;
586 }
587 $this->defaultShippingAddressId = (string) $data;
588 }
589
591 }
592
599 public function getBillingAddressIds()
600 {
601 if (is_null($this->billingAddressIds)) {
603 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
604 if (is_null($data)) {
605 return null;
606 }
607 $this->billingAddressIds = $data;
608 }
609
611 }
612
620 {
621 if (is_null($this->defaultBillingAddressId)) {
623 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
624 if (is_null($data)) {
625 return null;
626 }
627 $this->defaultBillingAddressId = (string) $data;
628 }
629
631 }
632
639 public function getAssociateMode()
640 {
641 if (is_null($this->associateMode)) {
643 $data = $this->raw(self::FIELD_ASSOCIATE_MODE);
644 if (is_null($data)) {
645 return null;
646 }
647 $this->associateMode = (string) $data;
648 }
649
651 }
652
659 public function getAssociates()
660 {
661 if (is_null($this->associates)) {
663 $data = $this->raw(self::FIELD_ASSOCIATES);
664 if (is_null($data)) {
665 return null;
666 }
667 $this->associates = AssociateCollection::fromArray($data);
668 }
669
670 return $this->associates;
671 }
672
679 public function getInheritedAssociates()
680 {
681 if (is_null($this->inheritedAssociates)) {
683 $data = $this->raw(self::FIELD_INHERITED_ASSOCIATES);
684 if (is_null($data)) {
685 return null;
686 }
687 $this->inheritedAssociates = InheritedAssociateCollection::fromArray($data);
688 }
689
691 }
692
699 public function getParentUnit()
700 {
701 if (is_null($this->parentUnit)) {
703 $data = $this->raw(self::FIELD_PARENT_UNIT);
704 if (is_null($data)) {
705 return null;
706 }
707
708 $this->parentUnit = BusinessUnitKeyReferenceModel::of($data);
709 }
710
711 return $this->parentUnit;
712 }
713
720 public function getTopLevelUnit()
721 {
722 if (is_null($this->topLevelUnit)) {
724 $data = $this->raw(self::FIELD_TOP_LEVEL_UNIT);
725 if (is_null($data)) {
726 return null;
727 }
728
729 $this->topLevelUnit = BusinessUnitKeyReferenceModel::of($data);
730 }
731
732 return $this->topLevelUnit;
733 }
734
741 public function getApprovalRuleMode()
742 {
743 if (is_null($this->approvalRuleMode)) {
745 $data = $this->raw(self::FIELD_APPROVAL_RULE_MODE);
746 if (is_null($data)) {
747 return null;
748 }
749 $this->approvalRuleMode = (string) $data;
750 }
751
753 }
754
755
759 public function setId(?string $id): void
760 {
761 $this->id = $id;
762 }
763
767 public function setVersion(?int $version): void
768 {
769 $this->version = $version;
770 }
771
775 public function setCreatedAt(?DateTimeImmutable $createdAt): void
776 {
777 $this->createdAt = $createdAt;
778 }
779
783 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
784 {
785 $this->lastModifiedAt = $lastModifiedAt;
786 }
787
792 {
793 $this->lastModifiedBy = $lastModifiedBy;
794 }
795
799 public function setCreatedBy(?CreatedBy $createdBy): void
800 {
801 $this->createdBy = $createdBy;
802 }
803
807 public function setKey(?string $key): void
808 {
809 $this->key = $key;
810 }
811
815 public function setStatus(?string $status): void
816 {
817 $this->status = $status;
818 }
819
824 {
825 $this->stores = $stores;
826 }
827
831 public function setStoreMode(?string $storeMode): void
832 {
833 $this->storeMode = $storeMode;
834 }
835
839 public function setName(?string $name): void
840 {
841 $this->name = $name;
842 }
843
847 public function setContactEmail(?string $contactEmail): void
848 {
849 $this->contactEmail = $contactEmail;
850 }
851
855 public function setCustom(?CustomFields $custom): void
856 {
857 $this->custom = $custom;
858 }
859
864 {
865 $this->addresses = $addresses;
866 }
867
871 public function setShippingAddressIds(?array $shippingAddressIds): void
872 {
873 $this->shippingAddressIds = $shippingAddressIds;
874 }
875
880 {
881 $this->defaultShippingAddressId = $defaultShippingAddressId;
882 }
883
887 public function setBillingAddressIds(?array $billingAddressIds): void
888 {
889 $this->billingAddressIds = $billingAddressIds;
890 }
891
896 {
897 $this->defaultBillingAddressId = $defaultBillingAddressId;
898 }
899
903 public function setAssociateMode(?string $associateMode): void
904 {
905 $this->associateMode = $associateMode;
906 }
907
912 {
913 $this->associates = $associates;
914 }
915
920 {
921 $this->inheritedAssociates = $inheritedAssociates;
922 }
923
928 {
929 $this->parentUnit = $parentUnit;
930 }
931
936 {
937 $this->topLevelUnit = $topLevelUnit;
938 }
939
943 public function setApprovalRuleMode(?string $approvalRuleMode): void
944 {
945 $this->approvalRuleMode = $approvalRuleMode;
946 }
947
948
949 #[\ReturnTypeWillChange]
950 public function jsonSerialize()
951 {
952 $data = $this->toArray();
953 if (isset($data[BusinessUnit::FIELD_CREATED_AT]) && $data[BusinessUnit::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
954 $data[BusinessUnit::FIELD_CREATED_AT] = $data[BusinessUnit::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
955 }
956
957 if (isset($data[BusinessUnit::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
958 $data[BusinessUnit::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnit::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
959 }
960 return (object) $data;
961 }
962}
setStores(?StoreKeyReferenceCollection $stores)
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, ?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)
setAssociates(?AssociateCollection $associates)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setInheritedAssociates(?InheritedAssociateCollection $inheritedAssociates)
setParentUnit(?BusinessUnitKeyReference $parentUnit)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
static fromArray(array $data)