1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
* @created: 11.02.15, 14:23 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Model\Customer; |
8
|
|
|
|
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
11
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
12
|
|
|
use Commercetools\Core\Model\Common\LocaleTrait; |
13
|
|
|
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference; |
14
|
|
|
use Commercetools\Core\Model\Common\AddressCollection; |
15
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
16
|
|
|
use Commercetools\Core\Model\Common\DateDecorator; |
17
|
|
|
use DateTime; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @package Commercetools\Core\Model\Customer |
21
|
|
|
* @link https://docs.commercetools.com/http-api-projects-me-profile.html#mycustomerdraft |
22
|
|
|
* @method string getEmail() |
23
|
|
|
* @method MyCustomerDraft setEmail(string $email = null) |
24
|
|
|
* @method string getPassword() |
25
|
|
|
* @method MyCustomerDraft setPassword(string $password = null) |
26
|
|
|
* @method string getFirstName() |
27
|
|
|
* @method MyCustomerDraft setFirstName(string $firstName = null) |
28
|
|
|
* @method string getMiddleName() |
29
|
|
|
* @method MyCustomerDraft setMiddleName(string $middleName = null) |
30
|
|
|
* @method string getLastName() |
31
|
|
|
* @method MyCustomerDraft setLastName(string $lastName = null) |
32
|
|
|
* @method string getTitle() |
33
|
|
|
* @method MyCustomerDraft setTitle(string $title = null) |
34
|
|
|
* @method DateDecorator getDateOfBirth() |
35
|
|
|
* @method MyCustomerDraft setDateOfBirth(DateTime $dateOfBirth = null) |
36
|
|
|
* @method string getCompanyName() |
37
|
|
|
* @method MyCustomerDraft setCompanyName(string $companyName = null) |
38
|
|
|
* @method string getVatId() |
39
|
|
|
* @method MyCustomerDraft setVatId(string $vatId = null) |
40
|
|
|
* @method AddressCollection getAddresses() |
41
|
|
|
* @method MyCustomerDraft setAddresses(AddressCollection $addresses = null) |
42
|
|
|
* @method int getDefaultShippingAddress() |
43
|
|
|
* @method MyCustomerDraft setDefaultShippingAddress(int $defaultShippingAddress = null) |
44
|
|
|
* @method int getDefaultBillingAddress() |
45
|
|
|
* @method MyCustomerDraft setDefaultBillingAddress(int $defaultBillingAddress = null) |
46
|
|
|
* @method CustomFieldObjectDraft getCustom() |
47
|
|
|
* @method MyCustomerDraft setCustom(CustomFieldObjectDraft $custom = null) |
48
|
|
|
* @method string getLocale() |
49
|
|
|
*/ |
50
|
|
|
class MyCustomerDraft extends JsonObject |
51
|
|
|
{ |
52
|
|
|
use LocaleTrait; |
53
|
|
|
|
54
|
1 |
|
public function fieldDefinitions() |
55
|
|
|
{ |
56
|
|
|
return [ |
57
|
1 |
|
'email' => [static::TYPE => 'string'], |
58
|
1 |
|
'password' => [static::TYPE => 'string'], |
59
|
1 |
|
'firstName' => [static::TYPE => 'string'], |
60
|
1 |
|
'middleName' => [static::TYPE => 'string'], |
61
|
1 |
|
'lastName' => [static::TYPE => 'string'], |
62
|
1 |
|
'title' => [static::TYPE => 'string'], |
63
|
|
|
'dateOfBirth' => [ |
64
|
1 |
|
static::TYPE => DateTime::class, |
65
|
1 |
|
static::DECORATOR => DateDecorator::class |
66
|
|
|
], |
67
|
1 |
|
'companyName' => [static::TYPE => 'string'], |
68
|
1 |
|
'vatId' => [static::TYPE => 'string'], |
69
|
1 |
|
'addresses' => [static::TYPE => AddressCollection::class], |
70
|
1 |
|
'defaultShippingAddress' => [static::TYPE => 'int'], |
71
|
1 |
|
'defaultBillingAddress' => [static::TYPE => 'int'], |
72
|
1 |
|
'custom' => [static::TYPE => CustomFieldObjectDraft::class], |
73
|
1 |
|
'locale' => [static::TYPE => 'string'], |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $email |
79
|
|
|
* @param string $firstName |
80
|
|
|
* @param string $lastName |
81
|
|
|
* @param string $password |
82
|
|
|
* @param Context|callable $context |
83
|
|
|
* @return MyCustomerDraft |
84
|
|
|
*/ |
85
|
|
View Code Duplication |
public static function ofEmailNameAndPassword($email, $firstName, $lastName, $password, $context = null) |
|
|
|
|
86
|
|
|
{ |
87
|
|
|
$draft = static::of($context); |
88
|
|
|
return $draft->setEmail($email) |
89
|
|
|
->setFirstName($firstName) |
90
|
|
|
->setLastName($lastName) |
91
|
|
|
->setPassword($password); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.