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
190
195 protected $custom;
196
201 protected $locale;
202
207 protected $salutation;
208
213 protected $stores;
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,
252 ?CustomFields $custom = null,
253 ?string $locale = null,
254 ?string $salutation = null,
256 ?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->customerGroupAssignments = $customerGroupAssignments;
284 $this->custom = $custom;
285 $this->locale = $locale;
286 $this->salutation = $salutation;
287 $this->stores = $stores;
288 $this->authenticationMode = $authenticationMode;
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
816 {
817 if (is_null($this->customerGroupAssignments)) {
819 $data = $this->raw(self::FIELD_CUSTOMER_GROUP_ASSIGNMENTS);
820 if (is_null($data)) {
821 return null;
822 }
823 $this->customerGroupAssignments = CustomerGroupAssignmentCollection::fromArray($data);
824 }
825
827 }
828
835 public function getCustom()
836 {
837 if (is_null($this->custom)) {
839 $data = $this->raw(self::FIELD_CUSTOM);
840 if (is_null($data)) {
841 return null;
842 }
843
844 $this->custom = CustomFieldsModel::of($data);
845 }
846
847 return $this->custom;
848 }
849
856 public function getLocale()
857 {
858 if (is_null($this->locale)) {
860 $data = $this->raw(self::FIELD_LOCALE);
861 if (is_null($data)) {
862 return null;
863 }
864 $this->locale = (string) $data;
865 }
866
867 return $this->locale;
868 }
869
876 public function getSalutation()
877 {
878 if (is_null($this->salutation)) {
880 $data = $this->raw(self::FIELD_SALUTATION);
881 if (is_null($data)) {
882 return null;
883 }
884 $this->salutation = (string) $data;
885 }
886
887 return $this->salutation;
888 }
889
900 public function getStores()
901 {
902 if (is_null($this->stores)) {
904 $data = $this->raw(self::FIELD_STORES);
905 if (is_null($data)) {
906 return null;
907 }
908 $this->stores = StoreKeyReferenceCollection::fromArray($data);
909 }
910
911 return $this->stores;
912 }
913
920 public function getAuthenticationMode()
921 {
922 if (is_null($this->authenticationMode)) {
924 $data = $this->raw(self::FIELD_AUTHENTICATION_MODE);
925 if (is_null($data)) {
926 return null;
927 }
928 $this->authenticationMode = (string) $data;
929 }
930
932 }
933
934
938 public function setId(?string $id): void
939 {
940 $this->id = $id;
941 }
942
946 public function setVersion(?int $version): void
947 {
948 $this->version = $version;
949 }
950
954 public function setCreatedAt(?DateTimeImmutable $createdAt): void
955 {
956 $this->createdAt = $createdAt;
957 }
958
962 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
963 {
964 $this->lastModifiedAt = $lastModifiedAt;
965 }
966
970 public function setKey(?string $key): void
971 {
972 $this->key = $key;
973 }
974
978 public function setCustomerNumber(?string $customerNumber): void
979 {
980 $this->customerNumber = $customerNumber;
981 }
982
986 public function setExternalId(?string $externalId): void
987 {
988 $this->externalId = $externalId;
989 }
990
995 {
996 $this->lastModifiedBy = $lastModifiedBy;
997 }
998
1002 public function setCreatedBy(?CreatedBy $createdBy): void
1003 {
1004 $this->createdBy = $createdBy;
1005 }
1006
1010 public function setEmail(?string $email): void
1011 {
1012 $this->email = $email;
1013 }
1014
1018 public function setPassword(?string $password): void
1019 {
1020 $this->password = $password;
1021 }
1022
1026 public function setFirstName(?string $firstName): void
1027 {
1028 $this->firstName = $firstName;
1029 }
1030
1034 public function setLastName(?string $lastName): void
1035 {
1036 $this->lastName = $lastName;
1037 }
1038
1042 public function setMiddleName(?string $middleName): void
1043 {
1044 $this->middleName = $middleName;
1045 }
1046
1050 public function setTitle(?string $title): void
1051 {
1052 $this->title = $title;
1053 }
1054
1058 public function setDateOfBirth(?DateTimeImmutable $dateOfBirth): void
1059 {
1060 $this->dateOfBirth = $dateOfBirth;
1061 }
1062
1066 public function setCompanyName(?string $companyName): void
1067 {
1068 $this->companyName = $companyName;
1069 }
1070
1074 public function setVatId(?string $vatId): void
1075 {
1076 $this->vatId = $vatId;
1077 }
1078
1083 {
1084 $this->addresses = $addresses;
1085 }
1086
1091 {
1092 $this->defaultShippingAddressId = $defaultShippingAddressId;
1093 }
1094
1098 public function setShippingAddressIds(?array $shippingAddressIds): void
1099 {
1100 $this->shippingAddressIds = $shippingAddressIds;
1101 }
1102
1107 {
1108 $this->defaultBillingAddressId = $defaultBillingAddressId;
1109 }
1110
1114 public function setBillingAddressIds(?array $billingAddressIds): void
1115 {
1116 $this->billingAddressIds = $billingAddressIds;
1117 }
1118
1122 public function setIsEmailVerified(?bool $isEmailVerified): void
1123 {
1124 $this->isEmailVerified = $isEmailVerified;
1125 }
1126
1131 {
1132 $this->customerGroup = $customerGroup;
1133 }
1134
1139 {
1140 $this->customerGroupAssignments = $customerGroupAssignments;
1141 }
1142
1146 public function setCustom(?CustomFields $custom): void
1147 {
1148 $this->custom = $custom;
1149 }
1150
1154 public function setLocale(?string $locale): void
1155 {
1156 $this->locale = $locale;
1157 }
1158
1162 public function setSalutation(?string $salutation): void
1163 {
1164 $this->salutation = $salutation;
1165 }
1166
1171 {
1172 $this->stores = $stores;
1173 }
1174
1178 public function setAuthenticationMode(?string $authenticationMode): void
1179 {
1180 $this->authenticationMode = $authenticationMode;
1181 }
1182
1183
1184 #[\ReturnTypeWillChange]
1185 public function jsonSerialize()
1186 {
1187 $data = $this->toArray();
1188 if (isset($data[Customer::FIELD_CREATED_AT]) && $data[Customer::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
1189 $data[Customer::FIELD_CREATED_AT] = $data[Customer::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1190 }
1191
1192 if (isset($data[Customer::FIELD_LAST_MODIFIED_AT]) && $data[Customer::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
1193 $data[Customer::FIELD_LAST_MODIFIED_AT] = $data[Customer::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
1194 }
1195
1196 if (isset($data[Customer::FIELD_DATE_OF_BIRTH]) && $data[Customer::FIELD_DATE_OF_BIRTH] instanceof \DateTimeImmutable) {
1197 $data[Customer::FIELD_DATE_OF_BIRTH] = $data[Customer::FIELD_DATE_OF_BIRTH]->format('Y-m-d');
1198 }
1199 return (object) $data;
1200 }
1201}
__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, ?CustomerGroupAssignmentCollection $customerGroupAssignments=null, ?CustomFields $custom=null, ?string $locale=null, ?string $salutation=null, ?StoreKeyReferenceCollection $stores=null, ?string $authenticationMode=null)
setCustomerGroup(?CustomerGroupReference $customerGroup)
setCustomerGroupAssignments(?CustomerGroupAssignmentCollection $customerGroupAssignments)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setCreatedAt(?DateTimeImmutable $createdAt)
setStores(?StoreKeyReferenceCollection $stores)
setDateOfBirth(?DateTimeImmutable $dateOfBirth)
setDefaultBillingAddressId(?string $defaultBillingAddressId)
setDefaultShippingAddressId(?string $defaultShippingAddressId)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setAuthenticationMode(?string $authenticationMode)
static fromArray(array $data)