1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zephia\PilotApiClient\Model; |
4
|
|
|
|
5
|
|
|
use Zephia\PilotApiClient\Exception\InvalidArgumentException; |
6
|
|
|
|
7
|
|
|
class LeadData |
8
|
|
|
{ |
9
|
|
|
const REQUIRED_VALUES = [ |
10
|
|
|
'firstname', |
11
|
|
|
'contact_type_id', |
12
|
|
|
'business_type_id', |
13
|
|
|
'suborigin_id', |
14
|
|
|
]; |
15
|
|
|
|
16
|
|
|
private $firstname; |
17
|
|
|
private $lastname; |
18
|
|
|
private $phone; |
19
|
|
|
private $cellphone; |
20
|
|
|
private $email; |
21
|
|
|
private $contact_type_id; |
22
|
|
|
private $business_type_id; |
23
|
|
|
private $notes; |
24
|
|
|
private $origin_id; |
25
|
|
|
private $suborigin_id; |
26
|
|
|
private $assigned_user; |
27
|
|
|
private $car_brand; |
28
|
|
|
private $car_modelo; |
29
|
|
|
private $city; |
30
|
|
|
private $province; |
31
|
|
|
private $country; |
32
|
|
|
private $vendor_name; |
33
|
|
|
private $vendor_email; |
34
|
|
|
private $vendor_phone; |
35
|
|
|
private $provider_service; |
36
|
|
|
private $provider_url; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* LeadData constructor. |
40
|
|
|
* |
41
|
|
|
* @param array $data |
42
|
|
|
*/ |
43
|
|
|
public function __construct($data = []) |
44
|
|
|
{ |
45
|
|
|
$missing = array_diff_key(array_flip(self::REQUIRED_VALUES), $data); |
46
|
|
|
if (count($missing) > 0) { |
47
|
|
|
throw new InvalidArgumentException( |
48
|
|
|
'Missing required value: ' . array_keys($missing)[0] . '.' |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
foreach ($data as $key => $value) { |
53
|
|
|
if (property_exists($this, $key)) { |
54
|
|
|
// snake_case to CamelCase |
55
|
|
|
$camel_case_key = implode( |
56
|
|
|
'', |
57
|
|
|
array_map('ucfirst', explode('_', $key)) |
58
|
|
|
); |
59
|
|
|
$this->{'set' . $camel_case_key}($value); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function toArray() |
65
|
|
|
{ |
66
|
|
|
return [ |
67
|
|
|
'pilot_firstname' => $this->getFirstname(), |
68
|
|
|
'pilot_lastname' => $this->getLastname(), |
69
|
|
|
'pilot_phone' => $this->getPhone(), |
70
|
|
|
'pilot_cellphone' => $this->getCellphone(), |
71
|
|
|
'pilot_email' => $this->getEmail(), |
72
|
|
|
'pilot_contact_type_id' => $this->getContactTypeId(), |
73
|
|
|
'pilot_business_type_id' => $this->getBusinessTypeId(), |
74
|
|
|
'pilot_notes' => $this->getNotes(), |
75
|
|
|
'pilot_origin_id' => $this->getOriginId(), |
76
|
|
|
'pilot_suborigin_id' => $this->getSuboriginId(), |
77
|
|
|
'pilot_assigned_user' => $this->getAssignedUser(), |
78
|
|
|
'pilot_car_brand' => $this->getCarBrand(), |
79
|
|
|
'pilot_car_modelo' => $this->getCarModelo(), |
80
|
|
|
'pilot_city' => $this->getCity(), |
81
|
|
|
'pilot_province' => $this->getProvince(), |
82
|
|
|
'pilot_country' => $this->getCountry(), |
83
|
|
|
'pilot_vendor_name' => $this->getVendorName(), |
84
|
|
|
'pilot_vendor_email' => $this->getVendorEmail(), |
85
|
|
|
'pilot_vendor_phone' => $this->getVendorPhone(), |
86
|
|
|
'pilot_provider_service' => $this->getProviderService(), |
87
|
|
|
'pilot_provider_url' => $this->getProviderUrl() |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return mixed |
93
|
|
|
*/ |
94
|
|
|
public function getFirstname() |
95
|
|
|
{ |
96
|
|
|
return $this->firstname; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param mixed $firstname |
101
|
|
|
*/ |
102
|
|
|
public function setFirstname($firstname) |
103
|
|
|
{ |
104
|
|
|
$this->firstname = $firstname; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return mixed |
109
|
|
|
*/ |
110
|
|
|
public function getLastname() |
111
|
|
|
{ |
112
|
|
|
return $this->lastname; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param mixed $lastname |
117
|
|
|
*/ |
118
|
|
|
public function setLastname($lastname) |
119
|
|
|
{ |
120
|
|
|
$this->lastname = $lastname; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return mixed |
125
|
|
|
*/ |
126
|
|
|
public function getPhone() |
127
|
|
|
{ |
128
|
|
|
return $this->phone; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param mixed $phone |
133
|
|
|
*/ |
134
|
|
|
public function setPhone($phone) |
135
|
|
|
{ |
136
|
|
|
$this->phone = $phone; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return mixed |
141
|
|
|
*/ |
142
|
|
|
public function getCellphone() |
143
|
|
|
{ |
144
|
|
|
return $this->cellphone; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param mixed $cellphone |
149
|
|
|
*/ |
150
|
|
|
public function setCellphone($cellphone) |
151
|
|
|
{ |
152
|
|
|
$this->cellphone = $cellphone; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return mixed |
157
|
|
|
*/ |
158
|
|
|
public function getEmail() |
159
|
|
|
{ |
160
|
|
|
return $this->email; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param mixed $email |
165
|
|
|
*/ |
166
|
|
|
public function setEmail($email) |
167
|
|
|
{ |
168
|
|
|
$this->email = $email; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
|
|
public function getContactTypeId() |
175
|
|
|
{ |
176
|
|
|
return $this->contact_type_id; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param mixed $contact_type_id |
181
|
|
|
*/ |
182
|
|
|
public function setContactTypeId($contact_type_id) |
183
|
|
|
{ |
184
|
|
|
$this->contact_type_id = $contact_type_id; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return mixed |
189
|
|
|
*/ |
190
|
|
|
public function getBusinessTypeId() |
191
|
|
|
{ |
192
|
|
|
return $this->business_type_id; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @param mixed $business_type_id |
197
|
|
|
*/ |
198
|
|
|
public function setBusinessTypeId($business_type_id) |
199
|
|
|
{ |
200
|
|
|
$this->business_type_id = $business_type_id; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @return mixed |
205
|
|
|
*/ |
206
|
|
|
public function getNotes() |
207
|
|
|
{ |
208
|
|
|
return $this->notes; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @param mixed $notes |
213
|
|
|
*/ |
214
|
|
|
public function setNotes($notes) |
215
|
|
|
{ |
216
|
|
|
$this->notes = $notes; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return mixed |
221
|
|
|
*/ |
222
|
|
|
public function getOriginId() |
223
|
|
|
{ |
224
|
|
|
return $this->origin_id; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @param mixed $origin_id |
229
|
|
|
*/ |
230
|
|
|
public function setOriginId($origin_id) |
231
|
|
|
{ |
232
|
|
|
$this->origin_id = $origin_id; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return mixed |
237
|
|
|
*/ |
238
|
|
|
public function getSuboriginId() |
239
|
|
|
{ |
240
|
|
|
return $this->suborigin_id; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param mixed $suborigin_id |
245
|
|
|
*/ |
246
|
|
|
public function setSuboriginId($suborigin_id) |
247
|
|
|
{ |
248
|
|
|
$this->suborigin_id = $suborigin_id; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @return mixed |
253
|
|
|
*/ |
254
|
|
|
public function getAssignedUser() |
255
|
|
|
{ |
256
|
|
|
return $this->assigned_user; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @param mixed $assigned_user |
261
|
|
|
*/ |
262
|
|
|
public function setAssignedUser($assigned_user) |
263
|
|
|
{ |
264
|
|
|
$this->assigned_user = $assigned_user; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @return mixed |
269
|
|
|
*/ |
270
|
|
|
public function getCarBrand() |
271
|
|
|
{ |
272
|
|
|
return $this->car_brand; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param mixed $car_brand |
277
|
|
|
*/ |
278
|
|
|
public function setCarBrand($car_brand) |
279
|
|
|
{ |
280
|
|
|
$this->car_brand = $car_brand; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @return mixed |
285
|
|
|
*/ |
286
|
|
|
public function getCarModelo() |
287
|
|
|
{ |
288
|
|
|
return $this->car_modelo; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* @param mixed $car_modelo |
293
|
|
|
*/ |
294
|
|
|
public function setCarModelo($car_modelo) |
295
|
|
|
{ |
296
|
|
|
$this->car_modelo = $car_modelo; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* @return mixed |
301
|
|
|
*/ |
302
|
|
|
public function getCity() |
303
|
|
|
{ |
304
|
|
|
return $this->city; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @param mixed $city |
309
|
|
|
*/ |
310
|
|
|
public function setCity($city) |
311
|
|
|
{ |
312
|
|
|
$this->city = $city; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @return mixed |
317
|
|
|
*/ |
318
|
|
|
public function getProvince() |
319
|
|
|
{ |
320
|
|
|
return $this->province; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @param mixed $province |
325
|
|
|
*/ |
326
|
|
|
public function setProvince($province) |
327
|
|
|
{ |
328
|
|
|
$this->province = $province; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @return mixed |
333
|
|
|
*/ |
334
|
|
|
public function getCountry() |
335
|
|
|
{ |
336
|
|
|
return $this->country; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @param mixed $country |
341
|
|
|
*/ |
342
|
|
|
public function setCountry($country) |
343
|
|
|
{ |
344
|
|
|
$this->country = $country; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @return mixed |
349
|
|
|
*/ |
350
|
|
|
public function getVendorName() |
351
|
|
|
{ |
352
|
|
|
return $this->vendor_name; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @param mixed $vendor_name |
357
|
|
|
*/ |
358
|
|
|
public function setVendorName($vendor_name) |
359
|
|
|
{ |
360
|
|
|
$this->vendor_name = $vendor_name; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @return mixed |
365
|
|
|
*/ |
366
|
|
|
public function getVendorEmail() |
367
|
|
|
{ |
368
|
|
|
return $this->vendor_email; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @param mixed $vendor_email |
373
|
|
|
*/ |
374
|
|
|
public function setVendorEmail($vendor_email) |
375
|
|
|
{ |
376
|
|
|
$this->vendor_email = $vendor_email; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @return mixed |
381
|
|
|
*/ |
382
|
|
|
public function getVendorPhone() |
383
|
|
|
{ |
384
|
|
|
return $this->vendor_phone; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @param mixed $vendor_phone |
389
|
|
|
*/ |
390
|
|
|
public function setVendorPhone($vendor_phone) |
391
|
|
|
{ |
392
|
|
|
$this->vendor_phone = $vendor_phone; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @return mixed |
397
|
|
|
*/ |
398
|
|
|
public function getProviderService() |
399
|
|
|
{ |
400
|
|
|
return $this->provider_service; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* @param mixed $provider_service |
405
|
|
|
*/ |
406
|
|
|
public function setProviderService($provider_service) |
407
|
|
|
{ |
408
|
|
|
$this->provider_service = $provider_service; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* @return mixed |
413
|
|
|
*/ |
414
|
|
|
public function getProviderUrl() |
415
|
|
|
{ |
416
|
|
|
return $this->provider_url; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @param mixed $provider_url |
421
|
|
|
*/ |
422
|
|
|
public function setProviderUrl($provider_url) |
423
|
|
|
{ |
424
|
|
|
$this->provider_url = $provider_url; |
425
|
|
|
} |
426
|
|
|
} |
427
|
|
|
|