commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
All Classes Namespaces Functions Variables Pages
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
220
221
225 public function __construct(
226 ?string $id = null,
227 ?int $version = null,
228 ?DateTimeImmutable $createdAt = null,
229 ?DateTimeImmutable $lastModifiedAt = null,
230 ?string $key = null,
231 ?string $customerNumber = null,
232 ?string $externalId = null,
234 ?CreatedBy $createdBy = null,
235 ?string $email = null,
236 ?string $password = null,
237 ?string $firstName = null,
238 ?string $lastName = null,
239 ?string $middleName = null,
240 ?string $title = null,
241 ?DateTimeImmutable $dateOfBirth = null,
242 ?string $companyName = null,
243 ?string $vatId = null,
245 ?string $defaultShippingAddressId = null,
246 ?array $shippingAddressIds = null,
247 ?string $defaultBillingAddressId = null,
248 ?array $billingAddressIds = null,
249 ?bool $isEmailVerified = null,
251 ?CustomFields $custom = null,
252 ?string $locale = null,
253 ?string $salutation = null,
255 ?string $authenticationMode = null,
257 ) {
258 $this->id = $id;
259 $this->version = $version;
260 $this->createdAt = $createdAt;
261 $this->lastModifiedAt = $lastModifiedAt;
262 $this->key = $key;
263 $this->customerNumber = $customerNumber;
264 $this->externalId = $externalId;
265 $this->lastModifiedBy = $lastModifiedBy;
266 $this->createdBy = $createdBy;
267 $this->email = $email;
268 $this->password = $password;
269 $this->firstName = $firstName;
270 $this->lastName = $lastName;
271 $this->middleName = $middleName;
272 $this->title = $title;
273 $this->dateOfBirth = $dateOfBirth;
274 $this->companyName = $companyName;
275 $this->vatId = $vatId;
276 $this->addresses = $addresses;
277 $this->defaultShippingAddressId = $defaultShippingAddressId;
278 $this->shippingAddressIds = $shippingAddressIds;
279 $this->defaultBillingAddressId = $defaultBillingAddressId;
280 $this->billingAddressIds = $billingAddressIds;
281 $this->isEmailVerified = $isEmailVerified;
282 $this->customerGroup = $customerGroup;
283 $this->custom = $custom;
284 $this->locale = $locale;
285 $this->salutation = $salutation;
286 $this->stores = $stores;
287 $this->authenticationMode = $authenticationMode;
288 $this->customerGroupAssignments = $customerGroupAssignments;
289 }
290
297 public function getId()
298 {
299 if (is_null($this->id)) {
301 $data = $this->raw(self::FIELD_ID);
302 if (is_null($data)) {
303 return null;
304 }
305 $this->id = (string) $data;
306 }
307
308 return $this->id;
309 }
310
317 public function getVersion()
318 {
319 if (is_null($this->version)) {
321 $data = $this->raw(self::FIELD_VERSION);
322 if (is_null($data)) {
323 return null;
324 }
325 $this->version = (int) $data;
326 }
327
328 return $this->version;
329 }
330
337 public function getCreatedAt()
338 {
339 if (is_null($this->createdAt)) {
341 $data = $this->raw(self::FIELD_CREATED_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->createdAt = $data;
350 }
351
352 return $this->createdAt;
353 }
354
361 public function getLastModifiedAt()
362 {
363 if (is_null($this->lastModifiedAt)) {
365 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
366 if (is_null($data)) {
367 return null;
368 }
369 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
370 if (false === $data) {
371 return null;
372 }
373 $this->lastModifiedAt = $data;
374 }
375
377 }
378
385 public function getKey()
386 {
387 if (is_null($this->key)) {
389 $data = $this->raw(self::FIELD_KEY);
390 if (is_null($data)) {
391 return null;
392 }
393 $this->key = (string) $data;
394 }
395
396 return $this->key;
397 }
398
406 public function getCustomerNumber()
407 {
408 if (is_null($this->customerNumber)) {
410 $data = $this->raw(self::FIELD_CUSTOMER_NUMBER);
411 if (is_null($data)) {
412 return null;
413 }
414 $this->customerNumber = (string) $data;
415 }
416
418 }
419
426 public function getExternalId()
427 {
428 if (is_null($this->externalId)) {
430 $data = $this->raw(self::FIELD_EXTERNAL_ID);
431 if (is_null($data)) {
432 return null;
433 }
434 $this->externalId = (string) $data;
435 }
436
437 return $this->externalId;
438 }
439
446 public function getLastModifiedBy()
447 {
448 if (is_null($this->lastModifiedBy)) {
450 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
451 if (is_null($data)) {
452 return null;
453 }
454
455 $this->lastModifiedBy = LastModifiedByModel::of($data);
456 }
457
459 }
460
467 public function getCreatedBy()
468 {
469 if (is_null($this->createdBy)) {
471 $data = $this->raw(self::FIELD_CREATED_BY);
472 if (is_null($data)) {
473 return null;
474 }
475
476 $this->createdBy = CreatedByModel::of($data);
477 }
478
479 return $this->createdBy;
480 }
481
489 public function getEmail()
490 {
491 if (is_null($this->email)) {
493 $data = $this->raw(self::FIELD_EMAIL);
494 if (is_null($data)) {
495 return null;
496 }
497 $this->email = (string) $data;
498 }
499
500 return $this->email;
501 }
502
509 public function getPassword()
510 {
511 if (is_null($this->password)) {
513 $data = $this->raw(self::FIELD_PASSWORD);
514 if (is_null($data)) {
515 return null;
516 }
517 $this->password = (string) $data;
518 }
519
520 return $this->password;
521 }
522
529 public function getFirstName()
530 {
531 if (is_null($this->firstName)) {
533 $data = $this->raw(self::FIELD_FIRST_NAME);
534 if (is_null($data)) {
535 return null;
536 }
537 $this->firstName = (string) $data;
538 }
539
540 return $this->firstName;
541 }
542
549 public function getLastName()
550 {
551 if (is_null($this->lastName)) {
553 $data = $this->raw(self::FIELD_LAST_NAME);
554 if (is_null($data)) {
555 return null;
556 }
557 $this->lastName = (string) $data;
558 }
559
560 return $this->lastName;
561 }
562
569 public function getMiddleName()
570 {
571 if (is_null($this->middleName)) {
573 $data = $this->raw(self::FIELD_MIDDLE_NAME);
574 if (is_null($data)) {
575 return null;
576 }
577 $this->middleName = (string) $data;
578 }
579
580 return $this->middleName;
581 }
582
589 public function getTitle()
590 {
591 if (is_null($this->title)) {
593 $data = $this->raw(self::FIELD_TITLE);
594 if (is_null($data)) {
595 return null;
596 }
597 $this->title = (string) $data;
598 }
599
600 return $this->title;
601 }
602
609 public function getDateOfBirth()
610 {
611 if (is_null($this->dateOfBirth)) {
613 $data = $this->raw(self::FIELD_DATE_OF_BIRTH);
614 if (is_null($data)) {
615 return null;
616 }
617 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATE_FORMAT, $data);
618 if (false === $data) {
619 return null;
620 }
621 $this->dateOfBirth = $data;
622 }
623
624 return $this->dateOfBirth;
625 }
626
633 public function getCompanyName()
634 {
635 if (is_null($this->companyName)) {
637 $data = $this->raw(self::FIELD_COMPANY_NAME);
638 if (is_null($data)) {
639 return null;
640 }
641 $this->companyName = (string) $data;
642 }
643
644 return $this->companyName;
645 }
646
653 public function getVatId()
654 {
655 if (is_null($this->vatId)) {
657 $data = $this->raw(self::FIELD_VAT_ID);
658 if (is_null($data)) {
659 return null;
660 }
661 $this->vatId = (string) $data;
662 }
663
664 return $this->vatId;
665 }
666
673 public function getAddresses()
674 {
675 if (is_null($this->addresses)) {
677 $data = $this->raw(self::FIELD_ADDRESSES);
678 if (is_null($data)) {
679 return null;
680 }
681 $this->addresses = AddressCollection::fromArray($data);
682 }
683
684 return $this->addresses;
685 }
686
694 {
695 if (is_null($this->defaultShippingAddressId)) {
697 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS_ID);
698 if (is_null($data)) {
699 return null;
700 }
701 $this->defaultShippingAddressId = (string) $data;
702 }
703
705 }
706
713 public function getShippingAddressIds()
714 {
715 if (is_null($this->shippingAddressIds)) {
717 $data = $this->raw(self::FIELD_SHIPPING_ADDRESS_IDS);
718 if (is_null($data)) {
719 return null;
720 }
721 $this->shippingAddressIds = $data;
722 }
723
725 }
726
734 {
735 if (is_null($this->defaultBillingAddressId)) {
737 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS_ID);
738 if (is_null($data)) {
739 return null;
740 }
741 $this->defaultBillingAddressId = (string) $data;
742 }
743
745 }
746
753 public function getBillingAddressIds()
754 {
755 if (is_null($this->billingAddressIds)) {
757 $data = $this->raw(self::FIELD_BILLING_ADDRESS_IDS);
758 if (is_null($data)) {
759 return null;
760 }
761 $this->billingAddressIds = $data;
762 }
763
765 }
766
773 public function getIsEmailVerified()
774 {
775 if (is_null($this->isEmailVerified)) {
777 $data = $this->raw(self::FIELD_IS_EMAIL_VERIFIED);
778 if (is_null($data)) {
779 return null;
780 }
781 $this->isEmailVerified = (bool) $data;
782 }
783
785 }
786
793 public function getCustomerGroup()
794 {
795 if (is_null($this->customerGroup)) {
797 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
798 if (is_null($data)) {
799 return null;
800 }
801
802 $this->customerGroup = CustomerGroupReferenceModel::of($data);
803 }
804
806 }
807
814 public function getCustom()
815 {
816 if (is_null($this->custom)) {
818 $data = $this->raw(self::FIELD_CUSTOM);
819 if (is_null($data)) {
820 return null;
821 }
822
823 $this->custom = CustomFieldsModel::of($data);
824 }
825
826 return $this->custom;
827 }
828
835 public function getLocale()
836 {
837 if (is_null($this->locale)) {
839 $data = $this->raw(self::FIELD_LOCALE);
840 if (is_null($data)) {
841 return null;
842 }
843 $this->locale = (string) $data;
844 }
845
846 return $this->locale;
847 }
848
855 public function getSalutation()
856 {
857 if (is_null($this->salutation)) {
859 $data = $this->raw(self::FIELD_SALUTATION);
860 if (is_null($data)) {
861 return null;
862 }
863 $this->salutation = (string) $data;
864 }
865
866 return $this->salutation;
867 }
868
879 public function getStores()
880 {
881 if (is_null($this->stores)) {
883 $data = $this->raw(self::FIELD_STORES);
884 if (is_null($data)) {
885 return null;
886 }
887 $this->stores = StoreKeyReferenceCollection::fromArray($data);
888 }
889
890 return $this->stores;
891 }
892
899 public function getAuthenticationMode()
900 {
901 if (is_null($this->authenticationMode)) {
903 $data = $this->raw(self::FIELD_AUTHENTICATION_MODE);
904 if (is_null($data)) {
905 return null;
906 }
907 $this->authenticationMode = (string) $data;
908 }
909
911 }
912
920 {
921 if (is_null($this->customerGroupAssignments)) {
923 $data = $this->raw(self::FIELD_CUSTOMER_GROUP_ASSIGNMENTS);
924 if (is_null($data)) {
925 return null;
926 }
927 $this->customerGroupAssignments = CustomerGroupAssignmentCollection::fromArray($data);
928 }
929
931 }
932
933
937 public function setId(?string $id): void
938 {
939 $this->id = $id;
940 }
941
945 public function setVersion(?int $version): void
946 {
947 $this->version = $version;
948 }
949
953 public function setCreatedAt(?DateTimeImmutable $createdAt): void
954 {
955 $this->createdAt = $createdAt;
956 }
957
961 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
962 {
963 $this->lastModifiedAt = $lastModifiedAt;
964 }
965
969 public function setKey(?string $key): void
970 {
971 $this->key = $key;
972 }
973
977 public function setCustomerNumber(?string $customerNumber): void
978 {
979 $this->customerNumber = $customerNumber;
980 }
981
985 public function setExternalId(?string $externalId): void
986 {
987 $this->externalId = $externalId;
988 }
989
994 {
995 $this->lastModifiedBy = $lastModifiedBy;
996 }
997
1001 public function setCreatedBy(?CreatedBy $createdBy): void
1002 {
1003 $this->createdBy = $createdBy;
1004 }
1005
1009 public function setEmail(?string $email): void
1010 {
1011 $this->email = $email;
1012 }
1013
1017 public function setPassword(?string $password): void
1018 {
1019 $this->password = $password;
1020 }
1021
1025 public function setFirstName(?string $firstName): void
1026 {
1027 $this->firstName = $firstName;
1028 }
1029
1033 public function setLastName(?string $lastName): void
1034 {
1035 $this->lastName = $lastName;
1036 }
1037
1041 public function setMiddleName(?string $middleName): void
1042 {
1043 $this->middleName = $middleName;
1044 }
1045
1049 public function setTitle(?string $title): void
1050 {
1051 $this->title = $title;
1052 }
1053
1057 public function setDateOfBirth(?DateTimeImmutable $dateOfBirth): void
1058 {
1059 $this->dateOfBirth = $dateOfBirth;
1060 }
1061
1065 public function setCompanyName(?string $companyName): void
1066 {
1067 $this->companyName = $companyName;
1068 }
1069
1073 public function setVatId(?string $vatId): void
1074 {
1075 $this->vatId = $vatId;
1076 }
1077
1082 {
1083 $this->addresses = $addresses;
1084 }
1085
1090 {
1091 $this->defaultShippingAddressId = $defaultShippingAddressId;
1092 }
1093
1097 public function setShippingAddressIds(?array $shippingAddressIds): void
1098 {
1099 $this->shippingAddressIds = $shippingAddressIds;
1100 }
1101
1106 {
1107 $this->defaultBillingAddressId = $defaultBillingAddressId;
1108 }
1109
1113 public function setBillingAddressIds(?array $billingAddressIds): void
1114 {
1115 $this->billingAddressIds = $billingAddressIds;
1116 }
1117
1121 public function setIsEmailVerified(?bool $isEmailVerified): void
1122 {
1123 $this->isEmailVerified = $isEmailVerified;
1124 }
1125
1130 {
1131 $this->customerGroup = $customerGroup;
1132 }
1133
1137 public function setCustom(?CustomFields $custom): void
1138 {
1139 $this->custom = $custom;
1140 }
1141
1145 public function setLocale(?string $locale): void
1146 {
1147 $this->locale = $locale;
1148 }
1149
1153 public function setSalutation(?string $salutation): void
1154 {
1155 $this->salutation = $salutation;
1156 }
1157
1162 {
1163 $this->stores = $stores;
1164 }
1165
1169 public function setAuthenticationMode(?string $authenticationMode): void
1170 {
1171 $this->authenticationMode = $authenticationMode;
1172 }
1173
1178 {
1179 $this->customerGroupAssignments = $customerGroupAssignments;
1180 }
1181
1182
1183 #[\ReturnTypeWillChange]
1184 public function jsonSerialize()
1185 {
1186 $data = $this->toArray();
1187 if (isset($data[Customer::FIELD_CREATED_AT]) && $data[Customer::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1188 $data[Customer::FIELD_CREATED_AT] = $data[Customer::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1189 }
1190
1191 if (isset($data[Customer::FIELD_LAST_MODIFIED_AT]) && $data[Customer::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1192 $data[Customer::FIELD_LAST_MODIFIED_AT] = $data[Customer::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1193 }
1194
1195 if (isset($data[Customer::FIELD_DATE_OF_BIRTH]) && $data[Customer::FIELD_DATE_OF_BIRTH] instanceof \DateTimeImmutable) {
1196 $data[Customer::FIELD_DATE_OF_BIRTH] = $data[Customer::FIELD_DATE_OF_BIRTH]->format('Y-m-d');
1197 }
1198 return (object) $data;
1199 }
1200}
setCustomerGroup(?CustomerGroupReference $customerGroup)
setCustomerGroupAssignments(?CustomerGroupAssignmentCollection $customerGroupAssignments)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setCreatedAt(?DateTimeImmutable $createdAt)
setStores(?StoreKeyReferenceCollection $stores)
__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, ?CustomerGroupAssignmentCollection $customerGroupAssignments=null)
setDateOfBirth(?DateTimeImmutable $dateOfBirth)
setDefaultBillingAddressId(?string $defaultBillingAddressId)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setAuthenticationMode(?string $authenticationMode)
static fromArray(array $data)