commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
All Classes Namespaces Functions Variables Pages
CustomerDraftModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
29final class CustomerDraftModel extends JsonObjectModel implements CustomerDraft
30{
35 protected $key;
36
41 protected $customerNumber;
42
47 protected $externalId;
48
53 protected $email;
54
59 protected $password;
60
65 protected $firstName;
66
71 protected $lastName;
72
77 protected $middleName;
78
83 protected $title;
84
90
95 protected $anonymousCart;
96
101 protected $anonymousId;
102
107 protected $dateOfBirth;
108
113 protected $companyName;
114
119 protected $vatId;
120
125 protected $addresses;
126
132
138
144
150
156
161 protected $customerGroup;
162
167 protected $custom;
168
173 protected $locale;
174
179 protected $salutation;
180
185 protected $stores;
186
192
198
199
203 public function __construct(
204 ?string $key = null,
205 ?string $customerNumber = null,
206 ?string $externalId = null,
207 ?string $email = null,
208 ?string $password = null,
209 ?string $firstName = null,
210 ?string $lastName = null,
211 ?string $middleName = null,
212 ?string $title = null,
213 ?string $anonymousCartId = null,
215 ?string $anonymousId = null,
216 ?DateTimeImmutable $dateOfBirth = null,
217 ?string $companyName = null,
218 ?string $vatId = null,
220 ?int $defaultShippingAddress = null,
221 ?array $shippingAddresses = null,
222 ?int $defaultBillingAddress = null,
223 ?array $billingAddresses = null,
224 ?bool $isEmailVerified = null,
227 ?string $locale = null,
228 ?string $salutation = null,
230 ?string $authenticationMode = null,
232 ) {
233 $this->key = $key;
234 $this->customerNumber = $customerNumber;
235 $this->externalId = $externalId;
236 $this->email = $email;
237 $this->password = $password;
238 $this->firstName = $firstName;
239 $this->lastName = $lastName;
240 $this->middleName = $middleName;
241 $this->title = $title;
242 $this->anonymousCartId = $anonymousCartId;
243 $this->anonymousCart = $anonymousCart;
244 $this->anonymousId = $anonymousId;
245 $this->dateOfBirth = $dateOfBirth;
246 $this->companyName = $companyName;
247 $this->vatId = $vatId;
248 $this->addresses = $addresses;
249 $this->defaultShippingAddress = $defaultShippingAddress;
250 $this->shippingAddresses = $shippingAddresses;
251 $this->defaultBillingAddress = $defaultBillingAddress;
252 $this->billingAddresses = $billingAddresses;
253 $this->isEmailVerified = $isEmailVerified;
254 $this->customerGroup = $customerGroup;
255 $this->custom = $custom;
256 $this->locale = $locale;
257 $this->salutation = $salutation;
258 $this->stores = $stores;
259 $this->authenticationMode = $authenticationMode;
260 $this->customerGroupAssignments = $customerGroupAssignments;
261 }
262
271 public function getKey()
272 {
273 if (is_null($this->key)) {
275 $data = $this->raw(self::FIELD_KEY);
276 if (is_null($data)) {
277 return null;
278 }
279 $this->key = (string) $data;
280 }
281
282 return $this->key;
283 }
284
293 public function getCustomerNumber()
294 {
295 if (is_null($this->customerNumber)) {
297 $data = $this->raw(self::FIELD_CUSTOMER_NUMBER);
298 if (is_null($data)) {
299 return null;
300 }
301 $this->customerNumber = (string) $data;
302 }
303
305 }
306
313 public function getExternalId()
314 {
315 if (is_null($this->externalId)) {
317 $data = $this->raw(self::FIELD_EXTERNAL_ID);
318 if (is_null($data)) {
319 return null;
320 }
321 $this->externalId = (string) $data;
322 }
323
324 return $this->externalId;
325 }
326
334 public function getEmail()
335 {
336 if (is_null($this->email)) {
338 $data = $this->raw(self::FIELD_EMAIL);
339 if (is_null($data)) {
340 return null;
341 }
342 $this->email = (string) $data;
343 }
344
345 return $this->email;
346 }
347
355 public function getPassword()
356 {
357 if (is_null($this->password)) {
359 $data = $this->raw(self::FIELD_PASSWORD);
360 if (is_null($data)) {
361 return null;
362 }
363 $this->password = (string) $data;
364 }
365
366 return $this->password;
367 }
368
375 public function getFirstName()
376 {
377 if (is_null($this->firstName)) {
379 $data = $this->raw(self::FIELD_FIRST_NAME);
380 if (is_null($data)) {
381 return null;
382 }
383 $this->firstName = (string) $data;
384 }
385
386 return $this->firstName;
387 }
388
395 public function getLastName()
396 {
397 if (is_null($this->lastName)) {
399 $data = $this->raw(self::FIELD_LAST_NAME);
400 if (is_null($data)) {
401 return null;
402 }
403 $this->lastName = (string) $data;
404 }
405
406 return $this->lastName;
407 }
408
415 public function getMiddleName()
416 {
417 if (is_null($this->middleName)) {
419 $data = $this->raw(self::FIELD_MIDDLE_NAME);
420 if (is_null($data)) {
421 return null;
422 }
423 $this->middleName = (string) $data;
424 }
425
426 return $this->middleName;
427 }
428
435 public function getTitle()
436 {
437 if (is_null($this->title)) {
439 $data = $this->raw(self::FIELD_TITLE);
440 if (is_null($data)) {
441 return null;
442 }
443 $this->title = (string) $data;
444 }
445
446 return $this->title;
447 }
448
455 public function getAnonymousCartId()
456 {
457 if (is_null($this->anonymousCartId)) {
459 $data = $this->raw(self::FIELD_ANONYMOUS_CART_ID);
460 if (is_null($data)) {
461 return null;
462 }
463 $this->anonymousCartId = (string) $data;
464 }
465
467 }
468
475 public function getAnonymousCart()
476 {
477 if (is_null($this->anonymousCart)) {
479 $data = $this->raw(self::FIELD_ANONYMOUS_CART);
480 if (is_null($data)) {
481 return null;
482 }
483
484 $this->anonymousCart = CartResourceIdentifierModel::of($data);
485 }
486
488 }
489
496 public function getAnonymousId()
497 {
498 if (is_null($this->anonymousId)) {
500 $data = $this->raw(self::FIELD_ANONYMOUS_ID);
501 if (is_null($data)) {
502 return null;
503 }
504 $this->anonymousId = (string) $data;
505 }
506
507 return $this->anonymousId;
508 }
509
516 public function getDateOfBirth()
517 {
518 if (is_null($this->dateOfBirth)) {
520 $data = $this->raw(self::FIELD_DATE_OF_BIRTH);
521 if (is_null($data)) {
522 return null;
523 }
524 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATE_FORMAT, $data);
525 if (false === $data) {
526 return null;
527 }
528 $this->dateOfBirth = $data;
529 }
530
531 return $this->dateOfBirth;
532 }
533
540 public function getCompanyName()
541 {
542 if (is_null($this->companyName)) {
544 $data = $this->raw(self::FIELD_COMPANY_NAME);
545 if (is_null($data)) {
546 return null;
547 }
548 $this->companyName = (string) $data;
549 }
550
551 return $this->companyName;
552 }
553
560 public function getVatId()
561 {
562 if (is_null($this->vatId)) {
564 $data = $this->raw(self::FIELD_VAT_ID);
565 if (is_null($data)) {
566 return null;
567 }
568 $this->vatId = (string) $data;
569 }
570
571 return $this->vatId;
572 }
573
580 public function getAddresses()
581 {
582 if (is_null($this->addresses)) {
584 $data = $this->raw(self::FIELD_ADDRESSES);
585 if (is_null($data)) {
586 return null;
587 }
588 $this->addresses = BaseAddressCollection::fromArray($data);
589 }
590
591 return $this->addresses;
592 }
593
602 {
603 if (is_null($this->defaultShippingAddress)) {
605 $data = $this->raw(self::FIELD_DEFAULT_SHIPPING_ADDRESS);
606 if (is_null($data)) {
607 return null;
608 }
609 $this->defaultShippingAddress = (int) $data;
610 }
611
613 }
614
622 public function getShippingAddresses()
623 {
624 if (is_null($this->shippingAddresses)) {
626 $data = $this->raw(self::FIELD_SHIPPING_ADDRESSES);
627 if (is_null($data)) {
628 return null;
629 }
630 $this->shippingAddresses = $data;
631 }
632
634 }
635
643 public function getDefaultBillingAddress()
644 {
645 if (is_null($this->defaultBillingAddress)) {
647 $data = $this->raw(self::FIELD_DEFAULT_BILLING_ADDRESS);
648 if (is_null($data)) {
649 return null;
650 }
651 $this->defaultBillingAddress = (int) $data;
652 }
653
655 }
656
664 public function getBillingAddresses()
665 {
666 if (is_null($this->billingAddresses)) {
668 $data = $this->raw(self::FIELD_BILLING_ADDRESSES);
669 if (is_null($data)) {
670 return null;
671 }
672 $this->billingAddresses = $data;
673 }
674
676 }
677
685 public function getIsEmailVerified()
686 {
687 if (is_null($this->isEmailVerified)) {
689 $data = $this->raw(self::FIELD_IS_EMAIL_VERIFIED);
690 if (is_null($data)) {
691 return null;
692 }
693 $this->isEmailVerified = (bool) $data;
694 }
695
697 }
698
705 public function getCustomerGroup()
706 {
707 if (is_null($this->customerGroup)) {
709 $data = $this->raw(self::FIELD_CUSTOMER_GROUP);
710 if (is_null($data)) {
711 return null;
712 }
713
714 $this->customerGroup = CustomerGroupResourceIdentifierModel::of($data);
715 }
716
718 }
719
726 public function getCustom()
727 {
728 if (is_null($this->custom)) {
730 $data = $this->raw(self::FIELD_CUSTOM);
731 if (is_null($data)) {
732 return null;
733 }
734
735 $this->custom = CustomFieldsDraftModel::of($data);
736 }
737
738 return $this->custom;
739 }
740
748 public function getLocale()
749 {
750 if (is_null($this->locale)) {
752 $data = $this->raw(self::FIELD_LOCALE);
753 if (is_null($data)) {
754 return null;
755 }
756 $this->locale = (string) $data;
757 }
758
759 return $this->locale;
760 }
761
768 public function getSalutation()
769 {
770 if (is_null($this->salutation)) {
772 $data = $this->raw(self::FIELD_SALUTATION);
773 if (is_null($data)) {
774 return null;
775 }
776 $this->salutation = (string) $data;
777 }
778
779 return $this->salutation;
780 }
781
792 public function getStores()
793 {
794 if (is_null($this->stores)) {
796 $data = $this->raw(self::FIELD_STORES);
797 if (is_null($data)) {
798 return null;
799 }
800 $this->stores = StoreResourceIdentifierCollection::fromArray($data);
801 }
802
803 return $this->stores;
804 }
805
815 public function getAuthenticationMode()
816 {
817 if (is_null($this->authenticationMode)) {
819 $data = $this->raw(self::FIELD_AUTHENTICATION_MODE);
820 if (is_null($data)) {
821 return null;
822 }
823 $this->authenticationMode = (string) $data;
824 }
825
827 }
828
836 {
837 if (is_null($this->customerGroupAssignments)) {
839 $data = $this->raw(self::FIELD_CUSTOMER_GROUP_ASSIGNMENTS);
840 if (is_null($data)) {
841 return null;
842 }
843 $this->customerGroupAssignments = CustomerGroupAssignmentDraftCollection::fromArray($data);
844 }
845
847 }
848
849
853 public function setKey(?string $key): void
854 {
855 $this->key = $key;
856 }
857
861 public function setCustomerNumber(?string $customerNumber): void
862 {
863 $this->customerNumber = $customerNumber;
864 }
865
869 public function setExternalId(?string $externalId): void
870 {
871 $this->externalId = $externalId;
872 }
873
877 public function setEmail(?string $email): void
878 {
879 $this->email = $email;
880 }
881
885 public function setPassword(?string $password): void
886 {
887 $this->password = $password;
888 }
889
893 public function setFirstName(?string $firstName): void
894 {
895 $this->firstName = $firstName;
896 }
897
901 public function setLastName(?string $lastName): void
902 {
903 $this->lastName = $lastName;
904 }
905
909 public function setMiddleName(?string $middleName): void
910 {
911 $this->middleName = $middleName;
912 }
913
917 public function setTitle(?string $title): void
918 {
919 $this->title = $title;
920 }
921
925 public function setAnonymousCartId(?string $anonymousCartId): void
926 {
927 $this->anonymousCartId = $anonymousCartId;
928 }
929
934 {
935 $this->anonymousCart = $anonymousCart;
936 }
937
941 public function setAnonymousId(?string $anonymousId): void
942 {
943 $this->anonymousId = $anonymousId;
944 }
945
949 public function setDateOfBirth(?DateTimeImmutable $dateOfBirth): void
950 {
951 $this->dateOfBirth = $dateOfBirth;
952 }
953
957 public function setCompanyName(?string $companyName): void
958 {
959 $this->companyName = $companyName;
960 }
961
965 public function setVatId(?string $vatId): void
966 {
967 $this->vatId = $vatId;
968 }
969
974 {
975 $this->addresses = $addresses;
976 }
977
982 {
983 $this->defaultShippingAddress = $defaultShippingAddress;
984 }
985
989 public function setShippingAddresses(?array $shippingAddresses): void
990 {
991 $this->shippingAddresses = $shippingAddresses;
992 }
993
998 {
999 $this->defaultBillingAddress = $defaultBillingAddress;
1000 }
1001
1005 public function setBillingAddresses(?array $billingAddresses): void
1006 {
1007 $this->billingAddresses = $billingAddresses;
1008 }
1009
1013 public function setIsEmailVerified(?bool $isEmailVerified): void
1014 {
1015 $this->isEmailVerified = $isEmailVerified;
1016 }
1017
1022 {
1023 $this->customerGroup = $customerGroup;
1024 }
1025
1029 public function setCustom(?CustomFieldsDraft $custom): void
1030 {
1031 $this->custom = $custom;
1032 }
1033
1037 public function setLocale(?string $locale): void
1038 {
1039 $this->locale = $locale;
1040 }
1041
1045 public function setSalutation(?string $salutation): void
1046 {
1047 $this->salutation = $salutation;
1048 }
1049
1054 {
1055 $this->stores = $stores;
1056 }
1057
1061 public function setAuthenticationMode(?string $authenticationMode): void
1062 {
1063 $this->authenticationMode = $authenticationMode;
1064 }
1065
1070 {
1071 $this->customerGroupAssignments = $customerGroupAssignments;
1072 }
1073
1074
1075 #[\ReturnTypeWillChange]
1076 public function jsonSerialize()
1077 {
1078 $data = $this->toArray();
1079 if (isset($data[CustomerDraft::FIELD_DATE_OF_BIRTH]) && $data[CustomerDraft::FIELD_DATE_OF_BIRTH] instanceof \DateTimeImmutable) {
1081 }
1082 return (object) $data;
1083 }
1084}
setCustomerGroupAssignments(?CustomerGroupAssignmentDraftCollection $customerGroupAssignments)
setCustomerGroup(?CustomerGroupResourceIdentifier $customerGroup)
__construct(?string $key=null, ?string $customerNumber=null, ?string $externalId=null, ?string $email=null, ?string $password=null, ?string $firstName=null, ?string $lastName=null, ?string $middleName=null, ?string $title=null, ?string $anonymousCartId=null, ?CartResourceIdentifier $anonymousCart=null, ?string $anonymousId=null, ?DateTimeImmutable $dateOfBirth=null, ?string $companyName=null, ?string $vatId=null, ?BaseAddressCollection $addresses=null, ?int $defaultShippingAddress=null, ?array $shippingAddresses=null, ?int $defaultBillingAddress=null, ?array $billingAddresses=null, ?bool $isEmailVerified=null, ?CustomerGroupResourceIdentifier $customerGroup=null, ?CustomFieldsDraft $custom=null, ?string $locale=null, ?string $salutation=null, ?StoreResourceIdentifierCollection $stores=null, ?string $authenticationMode=null, ?CustomerGroupAssignmentDraftCollection $customerGroupAssignments=null)
setAnonymousCart(?CartResourceIdentifier $anonymousCart)
setStores(?StoreResourceIdentifierCollection $stores)
static fromArray(array $data)