commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CustomerModel.php
1<?php
2
3declare(strict_types=1);
10
27use DateTimeImmutable;
28use stdClass;
29
33final class CustomerModel extends JsonObjectModel implements Customer
34{
39 protected $id;
40
45 protected $version;
46
51 protected $createdAt;
52
57 protected $lastModifiedAt;
58
63 protected $key;
64
69 protected $customerNumber;
70
75 protected $externalId;
76
81 protected $lastModifiedBy;
82
87 protected $createdBy;
88
93 protected $email;
94
99 protected $password;
100
105 protected $firstName;
106
111 protected $lastName;
112
117 protected $middleName;
118
123 protected $title;
124
129 protected $dateOfBirth;
130
135 protected $companyName;
136
141 protected $vatId;
142
147 protected $addresses;
148
154
160
166
172
178
183 protected $customerGroup;
184
189 protected $custom;
190
195 protected $locale;
196
201 protected $salutation;
202
207 protected $stores;
208
214
215
219 public function __construct(
220 ?string $id = null,
221 ?int $version = null,
222 ?DateTimeImmutable $createdAt = null,
223 ?DateTimeImmutable $lastModifiedAt = null,
224 ?string $key = null,
225 ?string $customerNumber = null,
226 ?string $externalId = null,
228 ?CreatedBy $createdBy = null,
229 ?string $email = null,
230 ?string $password = null,
231 ?string $firstName = null,
232 ?string $lastName = null,
233 ?string $middleName = null,
234 ?string $title = null,
235 ?DateTimeImmutable $dateOfBirth = null,
236 ?string $companyName = null,
237 ?string $vatId = null,
239 ?string $defaultShippingAddressId = null,
240 ?array $shippingAddressIds = null,
241 ?string $defaultBillingAddressId = null,
242 ?array $billingAddressIds = null,
243 ?bool $isEmailVerified = null,
245 ?CustomFields $custom = null,
246 ?string $locale = null,
247 ?string $salutation = null,
249 ?string $authenticationMode = null
250 ) {
251 $this->id = $id;
252 $this->version = $version;
253 $this->createdAt = $createdAt;
254 $this->lastModifiedAt = $lastModifiedAt;
255 $this->key = $key;
256 $this->customerNumber = $customerNumber;
257 $this->externalId = $externalId;
258 $this->lastModifiedBy = $lastModifiedBy;
259 $this->createdBy = $createdBy;
260 $this->email = $email;
261 $this->password = $password;
262 $this->firstName = $firstName;
263 $this->lastName = $lastName;
264 $this->middleName = $middleName;
265 $this->title = $title;
266 $this->dateOfBirth = $dateOfBirth;
267 $this->companyName = $companyName;
268 $this->vatId = $vatId;
269 $this->addresses = $addresses;
270 $this->defaultShippingAddressId = $defaultShippingAddressId;
271 $this->shippingAddressIds = $shippingAddressIds;
272 $this->defaultBillingAddressId = $defaultBillingAddressId;
273 $this->billingAddressIds = $billingAddressIds;
274 $this->isEmailVerified = $isEmailVerified;
275 $this->customerGroup = $customerGroup;
276 $this->custom = $custom;
277 $this->locale = $locale;
278 $this->salutation = $salutation;
279 $this->stores = $stores;
280 $this->authenticationMode = $authenticationMode;
281 }
282
289 public function getId()
290 {
291 if (is_null($this->id)) {
293 $data = $this->raw(self::FIELD_ID);
294 if (is_null($data)) {
295 return null;
296 }
297 $this->id = (string) $data;
298 }
299
300 return $this->id;
301 }
302
309 public function getVersion()
310 {
311 if (is_null($this->version)) {
313 $data = $this->raw(self::FIELD_VERSION);
314 if (is_null($data)) {
315 return null;
316 }
317 $this->version = (int) $data;
318 }
319
320 return $this->version;
321 }
322
329 public function getCreatedAt()
330 {
331 if (is_null($this->createdAt)) {
333 $data = $this->raw(self::FIELD_CREATED_AT);
334 if (is_null($data)) {
335 return null;
336 }
337 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
338 if (false === $data) {
339 return null;
340 }
341 $this->createdAt = $data;
342 }
343
344 return $this->createdAt;
345 }
346
353 public function getLastModifiedAt()
354 {
355 if (is_null($this->lastModifiedAt)) {
357 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
358 if (is_null($data)) {
359 return null;
360 }
361 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
362 if (false === $data) {
363 return null;
364 }
365 $this->lastModifiedAt = $data;
366 }
367
369 }
370
377 public function getKey()
378 {
379 if (is_null($this->key)) {
381 $data = $this->raw(self::FIELD_KEY);
382 if (is_null($data)) {
383 return null;
384 }
385 $this->key = (string) $data;
386 }
387
388 return $this->key;
389 }
390
398 public function getCustomerNumber()
399 {
400 if (is_null($this->customerNumber)) {
402 $data = $this->raw(self::FIELD_CUSTOMER_NUMBER);
403 if (is_null($data)) {
404 return null;
405 }
406 $this->customerNumber = (string) $data;
407 }
408
410 }
411
418 public function getExternalId()
419 {
420 if (is_null($this->externalId)) {
422 $data = $this->raw(self::FIELD_EXTERNAL_ID);
423 if (is_null($data)) {
424 return null;
425 }
426 $this->externalId = (string) $data;
427 }
428
429 return $this->externalId;
430 }
431
438 public function getLastModifiedBy()
439 {
440 if (is_null($this->lastModifiedBy)) {
442 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
443 if (is_null($data)) {
444 return null;
445 }
446
447 $this->lastModifiedBy = LastModifiedByModel::of($data);
448 }
449
451 }
452
459 public function getCreatedBy()
460 {
461 if (is_null($this->createdBy)) {
463 $data = $this->raw(self::FIELD_CREATED_BY);
464 if (is_null($data)) {
465 return null;
466 }
467
468 $this->createdBy = CreatedByModel::of($data);
469 }
470
471 return $this->createdBy;
472 }
473
481 public function getEmail()
482 {
483 if (is_null($this->email)) {
485 $data = $this->raw(self::FIELD_EMAIL);
486 if (is_null($data)) {
487 return null;
488 }
489 $this->email = (string) $data;
490 }
491
492 return $this->email;
493 }
494
501 public function getPassword()
502 {
503 if (is_null($this->password)) {
505 $data = $this->raw(self::FIELD_PASSWORD);
506 if (is_null($data)) {
507 return null;
508 }
509 $this->password = (string) $data;
510 }
511
512 return $this->password;
513 }
514
521 public function getFirstName()
522 {
523 if (is_null($this->firstName)) {
525 $data = $this->raw(self::FIELD_FIRST_NAME);
526 if (is_null($data)) {
527 return null;
528 }
529 $this->firstName = (string) $data;
530 }
531
532 return $this->firstName;
533 }
534
541 public function getLastName()
542 {
543 if (is_null($this->lastName)) {
545 $data = $this->raw(self::FIELD_LAST_NAME);
546 if (is_null($data)) {
547 return null;
548 }
549 $this->lastName = (string) $data;
550 }
551
552 return $this->lastName;
553 }
554
561 public function getMiddleName()
562 {
563 if (is_null($this->middleName)) {
565 $data = $this->raw(self::FIELD_MIDDLE_NAME);
566 if (is_null($data)) {
567 return null;
568 }
569 $this->middleName = (string) $data;
570 }
571
572 return $this->middleName;
573 }
574
581 public function getTitle()
582 {
583 if (is_null($this->title)) {
585 $data = $this->raw(self::FIELD_TITLE);
586 if (is_null($data)) {
587 return null;
588 }
589 $this->title = (string) $data;
590 }
591
592 return $this->title;
593 }
594
601 public function getDateOfBirth()
602 {
603 if (is_null($this->dateOfBirth)) {
605 $data = $this->raw(self::FIELD_DATE_OF_BIRTH);
606 if (is_null($data)) {
607 return null;
608 }
609 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATE_FORMAT, $data);
610 if (false === $data) {
611 return null;
612 }
613 $this->dateOfBirth = $data;
614 }
615
616 return $this->dateOfBirth;
617 }
618
625 public function getCompanyName()
626 {
627 if (is_null($this->companyName)) {
629 $data = $this->raw(self::FIELD_COMPANY_NAME);
630 if (is_null($data)) {
631 return null;
632 }
633 $this->companyName = (string) $data;
634 }
635
636 return $this->companyName;
637 }
638
645 public function getVatId()
646 {
647 if (is_null($this->vatId)) {
649 $data = $this->raw(self::FIELD_VAT_ID);
650 if (is_null($data)) {
651 return null;
652 }
653 $this->vatId = (string) $data;
654 }
655
656 return $this->vatId;
657 }
658
665 public function getAddresses()
666 {
667 if (is_null($this->addresses)) {
669 $data = $this->raw(self::FIELD_ADDRESSES);
670 if (is_null($data)) {
671 return null;
672 }
673 $this->addresses = AddressCollection::fromArray($data);
674 }
675
676 return $this->addresses;
677 }
678
686 {
687 if (is_null($this->defaultShippingAddressId)) {
689 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
690 if (is_null($data)) {
691 return null;
692 }
693 $this->defaultShippingAddressId = (string) $data;
694 }
695
697 }
698
705 public function getShippingAddressIds()
706 {
707 if (is_null($this->shippingAddressIds)) {
709 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
710 if (is_null($data)) {
711 return null;
712 }
713 $this->shippingAddressIds = $data;
714 }
715
717 }
718
726 {
727 if (is_null($this->defaultBillingAddressId)) {
729 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
730 if (is_null($data)) {
731 return null;
732 }
733 $this->defaultBillingAddressId = (string) $data;
734 }
735
737 }
738
745 public function getBillingAddressIds()
746 {
747 if (is_null($this->billingAddressIds)) {
749 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
750 if (is_null($data)) {
751 return null;
752 }
753 $this->billingAddressIds = $data;
754 }
755
757 }
758
765 public function getIsEmailVerified()
766 {
767 if (is_null($this->isEmailVerified)) {
769 $data = $this->raw(self::FIELD_IS_EMAIL_VERIFIED);
770 if (is_null($data)) {
771 return null;
772 }
773 $this->isEmailVerified = (bool) $data;
774 }
775
777 }
778
785 public function getCustomerGroup()
786 {
787 if (is_null($this->customerGroup)) {
789 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
790 if (is_null($data)) {
791 return null;
792 }
793
794 $this->customerGroup = CustomerGroupReferenceModel::of($data);
795 }
796
798 }
799
806 public function getCustom()
807 {
808 if (is_null($this->custom)) {
810 $data = $this->raw(self::FIELD_CUSTOM);
811 if (is_null($data)) {
812 return null;
813 }
814
815 $this->custom = CustomFieldsModel::of($data);
816 }
817
818 return $this->custom;
819 }
820
827 public function getLocale()
828 {
829 if (is_null($this->locale)) {
831 $data = $this->raw(self::FIELD_LOCALE);
832 if (is_null($data)) {
833 return null;
834 }
835 $this->locale = (string) $data;
836 }
837
838 return $this->locale;
839 }
840
847 public function getSalutation()
848 {
849 if (is_null($this->salutation)) {
851 $data = $this->raw(self::FIELD_SALUTATION);
852 if (is_null($data)) {
853 return null;
854 }
855 $this->salutation = (string) $data;
856 }
857
858 return $this->salutation;
859 }
860
871 public function getStores()
872 {
873 if (is_null($this->stores)) {
875 $data = $this->raw(self::FIELD_STORES);
876 if (is_null($data)) {
877 return null;
878 }
879 $this->stores = StoreKeyReferenceCollection::fromArray($data);
880 }
881
882 return $this->stores;
883 }
884
891 public function getAuthenticationMode()
892 {
893 if (is_null($this->authenticationMode)) {
895 $data = $this->raw(self::FIELD_AUTHENTICATION_MODE);
896 if (is_null($data)) {
897 return null;
898 }
899 $this->authenticationMode = (string) $data;
900 }
901
903 }
904
905
909 public function setId(?string $id): void
910 {
911 $this->id = $id;
912 }
913
917 public function setVersion(?int $version): void
918 {
919 $this->version = $version;
920 }
921
925 public function setCreatedAt(?DateTimeImmutable $createdAt): void
926 {
927 $this->createdAt = $createdAt;
928 }
929
933 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
934 {
935 $this->lastModifiedAt = $lastModifiedAt;
936 }
937
941 public function setKey(?string $key): void
942 {
943 $this->key = $key;
944 }
945
949 public function setCustomerNumber(?string $customerNumber): void
950 {
951 $this->customerNumber = $customerNumber;
952 }
953
957 public function setExternalId(?string $externalId): void
958 {
959 $this->externalId = $externalId;
960 }
961
966 {
967 $this->lastModifiedBy = $lastModifiedBy;
968 }
969
973 public function setCreatedBy(?CreatedBy $createdBy): void
974 {
975 $this->createdBy = $createdBy;
976 }
977
981 public function setEmail(?string $email): void
982 {
983 $this->email = $email;
984 }
985
989 public function setPassword(?string $password): void
990 {
991 $this->password = $password;
992 }
993
997 public function setFirstName(?string $firstName): void
998 {
999 $this->firstName = $firstName;
1000 }
1001
1005 public function setLastName(?string $lastName): void
1006 {
1007 $this->lastName = $lastName;
1008 }
1009
1013 public function setMiddleName(?string $middleName): void
1014 {
1015 $this->middleName = $middleName;
1016 }
1017
1021 public function setTitle(?string $title): void
1022 {
1023 $this->title = $title;
1024 }
1025
1029 public function setDateOfBirth(?DateTimeImmutable $dateOfBirth): void
1030 {
1031 $this->dateOfBirth = $dateOfBirth;
1032 }
1033
1037 public function setCompanyName(?string $companyName): void
1038 {
1039 $this->companyName = $companyName;
1040 }
1041
1045 public function setVatId(?string $vatId): void
1046 {
1047 $this->vatId = $vatId;
1048 }
1049
1054 {
1055 $this->addresses = $addresses;
1056 }
1057
1062 {
1063 $this->defaultShippingAddressId = $defaultShippingAddressId;
1064 }
1065
1069 public function setShippingAddressIds(?array $shippingAddressIds): void
1070 {
1071 $this->shippingAddressIds = $shippingAddressIds;
1072 }
1073
1078 {
1079 $this->defaultBillingAddressId = $defaultBillingAddressId;
1080 }
1081
1085 public function setBillingAddressIds(?array $billingAddressIds): void
1086 {
1087 $this->billingAddressIds = $billingAddressIds;
1088 }
1089
1093 public function setIsEmailVerified(?bool $isEmailVerified): void
1094 {
1095 $this->isEmailVerified = $isEmailVerified;
1096 }
1097
1102 {
1103 $this->customerGroup = $customerGroup;
1104 }
1105
1109 public function setCustom(?CustomFields $custom): void
1110 {
1111 $this->custom = $custom;
1112 }
1113
1117 public function setLocale(?string $locale): void
1118 {
1119 $this->locale = $locale;
1120 }
1121
1125 public function setSalutation(?string $salutation): void
1126 {
1127 $this->salutation = $salutation;
1128 }
1129
1134 {
1135 $this->stores = $stores;
1136 }
1137
1141 public function setAuthenticationMode(?string $authenticationMode): void
1142 {
1143 $this->authenticationMode = $authenticationMode;
1144 }
1145
1146
1147 #[\ReturnTypeWillChange]
1148 public function jsonSerialize()
1149 {
1150 $data = $this->toArray();
1151 if (isset($data[Customer::FIELD_CREATED_AT]) && $data[Customer::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1152 $data[Customer::FIELD_CREATED_AT] = $data[Customer::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1153 }
1154
1155 if (isset($data[Customer::FIELD_LAST_MODIFIED_AT]) && $data[Customer::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1156 $data[Customer::FIELD_LAST_MODIFIED_AT] = $data[Customer::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1157 }
1158
1159 if (isset($data[Customer::FIELD_DATE_OF_BIRTH]) && $data[Customer::FIELD_DATE_OF_BIRTH] instanceof \DateTimeImmutable) {
1160 $data[Customer::FIELD_DATE_OF_BIRTH] = $data[Customer::FIELD_DATE_OF_BIRTH]->format('Y-m-d');
1161 }
1162 return (object) $data;
1163 }
1164}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?string $customerNumber=null, ?string $externalId=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $email=null, ?string $password=null, ?string $firstName=null, ?string $lastName=null, ?string $middleName=null, ?string $title=null, ?DateTimeImmutable $dateOfBirth=null, ?string $companyName=null, ?string $vatId=null, ?AddressCollection $addresses=null, ?string $defaultShippingAddressId=null, ?array $shippingAddressIds=null, ?string $defaultBillingAddressId=null, ?array $billingAddressIds=null, ?bool $isEmailVerified=null, ?CustomerGroupReference $customerGroup=null, ?CustomFields $custom=null, ?string $locale=null, ?string $salutation=null, ?StoreKeyReferenceCollection $stores=null, ?string $authenticationMode=null)
setCustomerGroup(?CustomerGroupReference $customerGroup)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setCreatedAt(?DateTimeImmutable $createdAt)
setStores(?StoreKeyReferenceCollection $stores)
setDateOfBirth(?DateTimeImmutable $dateOfBirth)
setDefaultBillingAddressId(?string $defaultBillingAddressId)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setAuthenticationMode(?string $authenticationMode)