|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jayS-de <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Customer; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\AddressCollection; |
|
9
|
|
|
use Commercetools\Core\Model\Common\LocaleTrait; |
|
10
|
|
|
use Commercetools\Core\Model\Common\Resource; |
|
11
|
|
|
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference; |
|
12
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
|
13
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
|
14
|
|
|
use Commercetools\Core\Model\Common\DateDecorator; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @package Commercetools\Core\Model\Customer |
|
18
|
|
|
* @link https://dev.commercetools.com/http-api-projects-customers.html#customer |
|
19
|
|
|
* @method string getId() |
|
20
|
|
|
* @method Customer setId(string $id = null) |
|
21
|
|
|
* @method int getVersion() |
|
22
|
|
|
* @method Customer setVersion(int $version = null) |
|
23
|
|
|
* @method string getCustomerNumber() |
|
24
|
|
|
* @method Customer setCustomerNumber(string $customerNumber = null) |
|
25
|
|
|
* @method DateTimeDecorator getCreatedAt() |
|
26
|
|
|
* @method Customer setCreatedAt(\DateTime $createdAt = null) |
|
27
|
|
|
* @method DateTimeDecorator getLastModifiedAt() |
|
28
|
|
|
* @method Customer setLastModifiedAt(\DateTime $lastModifiedAt = null) |
|
29
|
|
|
* @method string getEmail() |
|
30
|
|
|
* @method Customer setEmail(string $email = null) |
|
31
|
|
|
* @method string getFirstName() |
|
32
|
|
|
* @method Customer setFirstName(string $firstName = null) |
|
33
|
|
|
* @method string getLastName() |
|
34
|
|
|
* @method Customer setLastName(string $lastName = null) |
|
35
|
|
|
* @method string getPassword() |
|
36
|
|
|
* @method Customer setPassword(string $password = null) |
|
37
|
|
|
* @method string getMiddleName() |
|
38
|
|
|
* @method Customer setMiddleName(string $middleName = null) |
|
39
|
|
|
* @method string getTitle() |
|
40
|
|
|
* @method Customer setTitle(string $title = null) |
|
41
|
|
|
* @method DateDecorator getDateOfBirth() |
|
42
|
|
|
* @method Customer setDateOfBirth(\DateTime $dateOfBirth = null) |
|
43
|
|
|
* @method string getCompanyName() |
|
44
|
|
|
* @method Customer setCompanyName(string $companyName = null) |
|
45
|
|
|
* @method string getVatId() |
|
46
|
|
|
* @method Customer setVatId(string $vatId = null) |
|
47
|
|
|
* @method AddressCollection getAddresses() |
|
48
|
|
|
* @method Customer setAddresses(AddressCollection $addresses = null) |
|
49
|
|
|
* @method string getDefaultShippingAddressId() |
|
50
|
|
|
* @method Customer setDefaultShippingAddressId(string $defaultShippingAddressId = null) |
|
51
|
|
|
* @method string getDefaultBillingAddressId() |
|
52
|
|
|
* @method Customer setDefaultBillingAddressId(string $defaultBillingAddressId = null) |
|
53
|
|
|
* @method bool getIsEmailVerified() |
|
54
|
|
|
* @method Customer setIsEmailVerified(bool $isEmailVerified = null) |
|
55
|
|
|
* @method string getExternalId() |
|
56
|
|
|
* @method Customer setExternalId(string $externalId = null) |
|
57
|
|
|
* @method CustomerGroupReference getCustomerGroup() |
|
58
|
|
|
* @method Customer setCustomerGroup(CustomerGroupReference $customerGroup = null) |
|
59
|
|
|
* @method CustomFieldObject getCustom() |
|
60
|
|
|
* @method Customer setCustom(CustomFieldObject $custom = null) |
|
61
|
|
|
* @method string getLocale() |
|
62
|
|
|
* @method CustomerReference getReference() |
|
63
|
|
|
*/ |
|
64
|
|
|
class Customer extends Resource |
|
65
|
|
|
{ |
|
66
|
|
|
use LocaleTrait; |
|
67
|
|
|
|
|
68
|
105 |
|
public function fieldDefinitions() |
|
69
|
|
|
{ |
|
70
|
|
|
return [ |
|
71
|
105 |
|
'id' => [static::TYPE => 'string'], |
|
72
|
105 |
|
'version' => [static::TYPE => 'int'], |
|
73
|
105 |
|
'customerNumber' => [static::TYPE => 'string'], |
|
74
|
|
|
'createdAt' => [ |
|
75
|
105 |
|
static::TYPE => '\DateTime', |
|
76
|
105 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' |
|
77
|
|
|
], |
|
78
|
|
|
'lastModifiedAt' => [ |
|
79
|
105 |
|
static::TYPE => '\DateTime', |
|
80
|
105 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' |
|
81
|
|
|
], |
|
82
|
105 |
|
'email' => [static::TYPE => 'string'], |
|
83
|
105 |
|
'firstName' => [static::TYPE => 'string'], |
|
84
|
105 |
|
'lastName' => [static::TYPE => 'string'], |
|
85
|
105 |
|
'password' => [static::TYPE => 'string'], |
|
86
|
105 |
|
'middleName' => [static::TYPE => 'string'], |
|
87
|
105 |
|
'title' => [static::TYPE => 'string'], |
|
88
|
|
|
'dateOfBirth' => [ |
|
89
|
105 |
|
static::TYPE => '\DateTime', |
|
90
|
105 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateDecorator' |
|
91
|
|
|
], |
|
92
|
105 |
|
'companyName' => [static::TYPE => 'string'], |
|
93
|
105 |
|
'vatId' => [static::TYPE => 'string'], |
|
94
|
105 |
|
'addresses' => [static::TYPE => '\Commercetools\Core\Model\Common\AddressCollection'], |
|
95
|
105 |
|
'defaultShippingAddressId' => [static::TYPE => 'string'], |
|
96
|
105 |
|
'defaultBillingAddressId' => [static::TYPE => 'string'], |
|
97
|
105 |
|
'isEmailVerified' => [static::TYPE => 'bool'], |
|
98
|
105 |
|
'externalId' => [static::TYPE => 'string'], |
|
99
|
105 |
|
'customerGroup' => [static::TYPE => '\Commercetools\Core\Model\CustomerGroup\CustomerGroupReference'], |
|
100
|
105 |
|
'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject'], |
|
101
|
105 |
|
'locale' => [static::TYPE => 'string'], |
|
102
|
|
|
]; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
36 |
|
public function getDefaultShippingAddress() |
|
106
|
|
|
{ |
|
107
|
36 |
|
if (!is_null($this->getAddresses())) { |
|
108
|
35 |
|
return $this->getAddresses()->getById($this->getDefaultShippingAddressId()); |
|
109
|
|
|
} |
|
110
|
1 |
|
return null; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
36 |
|
public function getDefaultBillingAddress() |
|
114
|
|
|
{ |
|
115
|
36 |
|
if (!is_null($this->getAddresses())) { |
|
116
|
35 |
|
return $this->getAddresses()->getById($this->getDefaultBillingAddressId()); |
|
117
|
|
|
} |
|
118
|
1 |
|
return null; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|