1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Events; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
use WSW\Email\Email; |
7
|
|
|
use WSW\SiftScience\Collections\PaymentMethods; |
8
|
|
|
use WSW\SiftScience\Collections\Promotions; |
9
|
|
|
use WSW\SiftScience\Entities\Address; |
10
|
|
|
use WSW\SiftScience\Entities\PaymentMethod; |
11
|
|
|
use WSW\SiftScience\Entities\Promotion; |
12
|
|
|
use WSW\SiftScience\Support\AllowedValues\SocialSignOnType; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class AbstractAccount |
16
|
|
|
* |
17
|
|
|
* @package WSW\SiftScience\Events |
18
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractAccount extends BaseEvent |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var Email |
24
|
|
|
*/ |
25
|
|
|
protected $userEmail; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $name; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $phone; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $referrerUserId; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var PaymentMethods |
44
|
|
|
*/ |
45
|
|
|
protected $paymentMethods; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var Address |
49
|
|
|
*/ |
50
|
|
|
protected $billingAddress; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var Address |
54
|
|
|
*/ |
55
|
|
|
protected $shippingAddress; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var Promotions |
59
|
|
|
*/ |
60
|
|
|
protected $promotions; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
protected $socialSignOnType; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var bool |
69
|
|
|
*/ |
70
|
|
|
protected $changedPassword = false; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param $type |
74
|
|
|
*/ |
75
|
|
|
public function __construct($type) |
76
|
|
|
{ |
77
|
|
|
$this->type = $type; |
78
|
|
|
$this->paymentMethods = new PaymentMethods(); |
79
|
|
|
$this->promotions = new Promotions(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return Email |
84
|
|
|
*/ |
85
|
|
|
public function getUserEmail() |
86
|
|
|
{ |
87
|
|
|
return $this->userEmail; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param Email $userEmail |
92
|
|
|
* |
93
|
|
|
* @return $this |
94
|
|
|
*/ |
95
|
|
|
public function setUserEmail(Email $userEmail) |
96
|
|
|
{ |
97
|
|
|
$this->userEmail = $userEmail; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return string |
104
|
|
|
*/ |
105
|
|
|
public function getName() |
106
|
|
|
{ |
107
|
|
|
return $this->name; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $name |
112
|
|
|
* |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
|
|
public function setName($name) |
116
|
|
|
{ |
117
|
|
|
$this->name = $name; |
118
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
public function getPhone() |
126
|
|
|
{ |
127
|
|
|
return $this->phone; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param string $phone |
132
|
|
|
* |
133
|
|
|
* @return $this |
134
|
|
|
*/ |
135
|
|
|
public function setPhone($phone) |
136
|
|
|
{ |
137
|
|
|
$this->phone = $phone; |
138
|
|
|
|
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return string |
144
|
|
|
*/ |
145
|
|
|
public function getReferrerUserId() |
146
|
|
|
{ |
147
|
|
|
return $this->referrerUserId; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param string $referrerUserId |
152
|
|
|
* |
153
|
|
|
* @return $this |
154
|
|
|
*/ |
155
|
|
|
public function setReferrerUserId($referrerUserId) |
156
|
|
|
{ |
157
|
|
|
$this->referrerUserId = $referrerUserId; |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return PaymentMethods |
164
|
|
|
*/ |
165
|
|
|
public function getPaymentMethods() |
166
|
|
|
{ |
167
|
|
|
return $this->paymentMethods; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param PaymentMethod $paymentMethod |
172
|
|
|
* |
173
|
|
|
* @return $this |
174
|
|
|
*/ |
175
|
|
|
public function addPaymentMethod(PaymentMethod $paymentMethod) |
176
|
|
|
{ |
177
|
|
|
$this->paymentMethods->add($paymentMethod); |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return Address |
184
|
|
|
*/ |
185
|
|
|
public function getBillingAddress() |
186
|
|
|
{ |
187
|
|
|
return $this->billingAddress; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param Address $billingAddress |
192
|
|
|
* |
193
|
|
|
* @return $this |
194
|
|
|
*/ |
195
|
|
|
public function setBillingAddress(Address $billingAddress) |
196
|
|
|
{ |
197
|
|
|
$this->billingAddress = $billingAddress; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @return Address |
204
|
|
|
*/ |
205
|
|
|
public function getShippingAddress() |
206
|
|
|
{ |
207
|
|
|
return $this->shippingAddress; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param Address $shippingAddress |
212
|
|
|
* |
213
|
|
|
* @return $this |
214
|
|
|
*/ |
215
|
|
|
public function setShippingAddress(Address $shippingAddress) |
216
|
|
|
{ |
217
|
|
|
$this->shippingAddress = $shippingAddress; |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @return Promotions |
224
|
|
|
*/ |
225
|
|
|
public function getPromotions() |
226
|
|
|
{ |
227
|
|
|
return $this->promotions; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @param Promotion $promotion |
232
|
|
|
* |
233
|
|
|
* @return $this |
234
|
|
|
*/ |
235
|
|
|
public function addPromotion(Promotion $promotion) |
236
|
|
|
{ |
237
|
|
|
$this->promotions->add($promotion); |
238
|
|
|
|
239
|
|
|
return $this; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @return string |
244
|
|
|
*/ |
245
|
|
|
public function getSocialSignOnType() |
246
|
|
|
{ |
247
|
|
|
return $this->socialSignOnType; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* @param string $socialSignOnType |
252
|
|
|
* |
253
|
|
|
* @return $this |
254
|
|
|
*/ |
255
|
|
|
public function setSocialSignOnType($socialSignOnType) |
256
|
|
|
{ |
257
|
|
|
if (!SocialSignOnType::isValid($socialSignOnType)) { |
258
|
|
|
throw new InvalidArgumentException('You should inform a valid social sign on type.'); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
$this->socialSignOnType = $socialSignOnType; |
262
|
|
|
|
263
|
|
|
return $this; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* @return bool |
268
|
|
|
*/ |
269
|
|
|
public function isChangedPassword() |
270
|
|
|
{ |
271
|
|
|
return $this->changedPassword; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @param bool $changedPassword |
276
|
|
|
* |
277
|
|
|
* @return $this |
278
|
|
|
*/ |
279
|
|
|
public function setChangedPassword($changedPassword) |
280
|
|
|
{ |
281
|
|
|
$this->changedPassword = $changedPassword; |
282
|
|
|
|
283
|
|
|
return $this; |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
|