|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GoCardlessPayment\MandateCheckout; |
|
4
|
|
|
|
|
5
|
|
|
use GoCardlessPayment\Makeable; |
|
6
|
|
|
|
|
7
|
|
|
class PrefilledCustomer implements \JsonSerializable |
|
8
|
|
|
{ |
|
9
|
|
|
use Makeable; |
|
10
|
|
|
|
|
11
|
|
|
protected ?string $givenName = null; |
|
12
|
|
|
|
|
13
|
|
|
protected ?string $familyName = null; |
|
14
|
|
|
|
|
15
|
|
|
protected ?string $email = null; |
|
16
|
|
|
|
|
17
|
|
|
protected ?string $companyName = null; |
|
18
|
|
|
|
|
19
|
|
|
protected ?string $city = null; |
|
20
|
|
|
|
|
21
|
|
|
protected ?string $addressLine1 = null; |
|
22
|
|
|
|
|
23
|
|
|
protected ?string $addressLine2 = null; |
|
24
|
|
|
|
|
25
|
|
|
protected ?string $addressLine3 = null; |
|
26
|
|
|
|
|
27
|
|
|
protected ?string $region = null; |
|
28
|
|
|
|
|
29
|
|
|
protected ?string $postalCode = null; |
|
30
|
|
|
|
|
31
|
|
|
protected ?string $countryCode = null; |
|
32
|
|
|
|
|
33
|
1 |
|
public function __construct(?string $email = null, ?string $givenName = null, ?string $familyName = null) |
|
34
|
|
|
{ |
|
35
|
1 |
|
$this->email = $email; |
|
36
|
1 |
|
$this->givenName = $givenName; |
|
37
|
1 |
|
$this->familyName = $familyName; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
1 |
|
public function givenName(?string $givenName): static |
|
41
|
|
|
{ |
|
42
|
1 |
|
$this->givenName = $givenName; |
|
43
|
|
|
|
|
44
|
1 |
|
$this->companyName = null; |
|
45
|
|
|
|
|
46
|
1 |
|
return $this; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
public function familyName(?string $familyName): static |
|
50
|
|
|
{ |
|
51
|
1 |
|
$this->familyName = $familyName; |
|
52
|
|
|
|
|
53
|
1 |
|
$this->companyName = null; |
|
54
|
|
|
|
|
55
|
1 |
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
public function email(?string $email): static |
|
59
|
|
|
{ |
|
60
|
1 |
|
$this->email = $email; |
|
61
|
|
|
|
|
62
|
1 |
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* WARNING: Company name overrides first and last name. |
|
67
|
|
|
*/ |
|
68
|
|
|
public function companyName(?string $companyName): static |
|
69
|
|
|
{ |
|
70
|
|
|
$this->companyName = $companyName; |
|
71
|
|
|
|
|
72
|
|
|
$this->givenName = null; |
|
73
|
|
|
$this->familyName = null; |
|
74
|
|
|
|
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
1 |
|
public function city(?string $city): static |
|
79
|
|
|
{ |
|
80
|
1 |
|
$this->city = $city; |
|
81
|
|
|
|
|
82
|
1 |
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
1 |
|
public function addressLine1(?string $addressLine1): static |
|
86
|
|
|
{ |
|
87
|
1 |
|
$this->addressLine1 = $addressLine1; |
|
88
|
|
|
|
|
89
|
1 |
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
1 |
|
public function addressLine2(?string $addressLine2): static |
|
93
|
|
|
{ |
|
94
|
1 |
|
$this->addressLine2 = $addressLine2; |
|
95
|
|
|
|
|
96
|
1 |
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
1 |
|
public function addressLine3(?string $addressLine3): static |
|
100
|
|
|
{ |
|
101
|
1 |
|
$this->addressLine3 = $addressLine3; |
|
102
|
|
|
|
|
103
|
1 |
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
1 |
|
public function region(?string $region): static |
|
107
|
|
|
{ |
|
108
|
1 |
|
$this->region = $region; |
|
109
|
|
|
|
|
110
|
1 |
|
return $this; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
1 |
|
public function postalCode(?string $postalCode): static |
|
114
|
|
|
{ |
|
115
|
1 |
|
$this->postalCode = $postalCode; |
|
116
|
|
|
|
|
117
|
1 |
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
1 |
|
public function countryCode(?string $countryCode): static |
|
121
|
|
|
{ |
|
122
|
1 |
|
$this->countryCode = $countryCode; |
|
123
|
|
|
|
|
124
|
1 |
|
return $this; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
1 |
|
public function jsonSerialize(): array |
|
128
|
|
|
{ |
|
129
|
1 |
|
return array_filter([ |
|
130
|
1 |
|
'given_name' => $this->givenName, |
|
131
|
1 |
|
'family_name' => $this->familyName, |
|
132
|
1 |
|
'email' => $this->email, |
|
133
|
1 |
|
'company_name' => $this->companyName, |
|
134
|
1 |
|
'city' => $this->city, |
|
135
|
1 |
|
'address_line1' => $this->addressLine1, |
|
136
|
1 |
|
'address_line2' => $this->addressLine2, |
|
137
|
1 |
|
'address_line3' => $this->addressLine3, |
|
138
|
1 |
|
'region' => $this->region, |
|
139
|
1 |
|
'postal_code' => $this->postalCode, |
|
140
|
1 |
|
'country_code' => $this->countryCode, |
|
141
|
1 |
|
], fn ($i) => ! is_null($i)); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
|