1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Moip\Resource; |
4
|
|
|
|
5
|
|
|
use stdClass; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Account. |
9
|
|
|
*/ |
10
|
|
|
class Account extends MoipResource |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Path accounts API. |
14
|
|
|
* |
15
|
|
|
* @const string |
16
|
|
|
*/ |
17
|
|
|
const PATH = 'accounts'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Standard country . |
21
|
|
|
* |
22
|
|
|
* @const string |
23
|
|
|
*/ |
24
|
|
|
const ADDRESS_COUNTRY = 'BRA'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Standard document type. |
28
|
|
|
* |
29
|
|
|
* @const string |
30
|
|
|
*/ |
31
|
|
|
const TAX_DOCUMENT = 'CPF'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Standard company document type. |
35
|
|
|
* |
36
|
|
|
* @const string |
37
|
|
|
*/ |
38
|
|
|
const COMPANY_TAX_DOCUMENT = 'CNPJ'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Default Account Type. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
const ACCOUNT_TYPE = 'MERCHANT'; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Initialize a new instance. |
49
|
|
|
*/ |
50
|
|
|
public function initialize() |
51
|
|
|
{ |
52
|
|
|
$this->data = new stdClass(); |
53
|
|
|
$this->data->email = new stdClass(); |
54
|
|
|
$this->data->person = new stdClass(); |
55
|
|
|
$this->data->person->alternativePhones = []; |
56
|
|
|
$this->data->type = self::ACCOUNT_TYPE; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Add a new address to the account. |
61
|
|
|
* |
62
|
|
|
* @param string $street Street address. |
63
|
|
|
* @param string $number Number address. |
64
|
|
|
* @param string $district Neighborhood address. |
65
|
|
|
* @param string $city City address. |
66
|
|
|
* @param string $state State address. |
67
|
|
|
* @param string $zip The zip code billing address. |
68
|
|
|
* @param string $complement Address complement. |
69
|
|
|
* @param string $country Country ISO-alpha3 format, BRA example. |
70
|
|
|
* |
71
|
|
|
* @return $this |
72
|
|
|
*/ |
73
|
|
View Code Duplication |
public function addAddress($street, $number, $district, $city, $state, $zip, $complement = null, $country = self::ADDRESS_COUNTRY) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
$address = new stdClass(); |
76
|
|
|
$address->street = $street; |
77
|
|
|
$address->streetNumber = $number; |
78
|
|
|
$address->complement = $complement; |
79
|
|
|
$address->district = $district; |
80
|
|
|
$address->city = $city; |
81
|
|
|
$address->state = $state; |
82
|
|
|
$address->country = $country; |
83
|
|
|
$address->zipCode = $zip; |
84
|
|
|
|
85
|
|
|
$this->data->person->address = $address; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Add alternative phone to an account. |
92
|
|
|
* |
93
|
|
|
* @param int $areaCode DDD telephone. |
94
|
|
|
* @param int $number Telephone number. |
95
|
|
|
* @param int $countryCode Country code. |
96
|
|
|
* |
97
|
|
|
* @return \Moip\Resource\Account |
98
|
|
|
*/ |
99
|
|
|
public function addAlternativePhone($areaCode, $number, $countryCode = 55) |
100
|
|
|
{ |
101
|
|
|
$alternativePhone = new stdClass(); |
102
|
|
|
$alternativePhone->countryCode = $countryCode; |
103
|
|
|
$alternativePhone->areaCode = $areaCode; |
104
|
|
|
$alternativePhone->number = $number; |
105
|
|
|
|
106
|
|
|
$this->data->person->alternativePhones[] = $alternativePhone; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Create a new account. |
113
|
|
|
* |
114
|
|
|
* @return \stdClass |
115
|
|
|
*/ |
116
|
|
|
public function create() |
117
|
|
|
{ |
118
|
|
|
return $this->createResource(sprintf('/%s/%s/', MoipResource::VERSION, self::PATH)); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Find a account. |
123
|
|
|
* |
124
|
|
|
* @param string $moip_id |
125
|
|
|
* |
126
|
|
|
* @return stdClass |
127
|
|
|
*/ |
128
|
|
|
public function get($moip_id) |
129
|
|
|
{ |
130
|
|
|
return $this->getByPath(sprintf('/%s/%s/%s', MoipResource::VERSION, self::PATH, $moip_id)); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get account id. |
135
|
|
|
* |
136
|
|
|
* @return string The buyer id. |
137
|
|
|
*/ |
138
|
|
|
public function getId() |
139
|
|
|
{ |
140
|
|
|
return $this->getIfSet('id'); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Get account address. |
145
|
|
|
* |
146
|
|
|
* @return \stdClass Account's address. |
147
|
|
|
*/ |
148
|
|
|
public function getAddress() |
149
|
|
|
{ |
150
|
|
|
return $this->getIfSet('address', $this->data->person); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get account fullname. |
155
|
|
|
* |
156
|
|
|
* @return string Account's full name. |
157
|
|
|
*/ |
158
|
|
|
public function getFullname() |
159
|
|
|
{ |
160
|
|
|
return $this->getIfSet('name', $this->data->person).' '.$this->getIfSet('lastName', $this->data->person); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Get birth date from account. |
165
|
|
|
* |
166
|
|
|
* @return \DateTime|null Date of birth of the credit card holder. |
167
|
|
|
*/ |
168
|
|
|
public function getBirthDate() |
169
|
|
|
{ |
170
|
|
|
return $this->getIfSetDate('birthDate', $this->data->person); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get phone area code from account. |
175
|
|
|
* |
176
|
|
|
* @return int DDD telephone. |
177
|
|
|
*/ |
178
|
|
|
public function getPhoneAreaCode() |
179
|
|
|
{ |
180
|
|
|
return $this->getIfSet('areaCode', $this->data->person->phone); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Get phone country code from account. |
185
|
|
|
* |
186
|
|
|
* @return int Country code. |
187
|
|
|
*/ |
188
|
|
|
public function getPhoneCountryCode() |
189
|
|
|
{ |
190
|
|
|
return $this->getIfSet('countryCode', $this->data->person->phone); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get phone number from account. |
195
|
|
|
* |
196
|
|
|
* @return int Telephone number. |
197
|
|
|
*/ |
198
|
|
|
public function getPhoneNumber() |
199
|
|
|
{ |
200
|
|
|
return $this->getIfSet('number', $this->data->person->phone); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Get tax document type from account. |
205
|
|
|
* |
206
|
|
|
* @return string Type of value: CPF and CNPJ |
207
|
|
|
*/ |
208
|
|
|
public function getTaxDocumentType() |
209
|
|
|
{ |
210
|
|
|
return $this->getIfSet('type', $this->data->person->taxDocument); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get alternative phones. |
215
|
|
|
* |
216
|
|
|
* @return array |
217
|
|
|
*/ |
218
|
|
|
public function getAlternativePhones() |
219
|
|
|
{ |
220
|
|
|
return $this->getIfSet('alternativePhones', $this->data->person); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Get company data. |
225
|
|
|
* |
226
|
|
|
* @return array |
227
|
|
|
*/ |
228
|
|
|
public function getCompany() |
229
|
|
|
{ |
230
|
|
|
return $this->getIfSet('company', $this->data); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Get tax document number from account. |
235
|
|
|
* |
236
|
|
|
* @return string Document Number. |
237
|
|
|
*/ |
238
|
|
|
public function getTaxDocumentNumber() |
239
|
|
|
{ |
240
|
|
|
return $this->getIfSet('number', $this->data->person->taxDocument); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Get account type. |
245
|
|
|
* |
246
|
|
|
* @return string Document Number. |
247
|
|
|
*/ |
248
|
|
|
public function getType() |
249
|
|
|
{ |
250
|
|
|
return $this->getIfSet('type', $this->data); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Mount the seller structure from account. |
255
|
|
|
* |
256
|
|
|
* @param \stdClass $response |
257
|
|
|
* |
258
|
|
|
* @return \Moip\Resource\Account Account data |
259
|
|
|
*/ |
260
|
|
|
protected function populate(stdClass $response) |
261
|
|
|
{ |
262
|
|
|
$account = clone $this; |
263
|
|
|
$account->data->email = new stdClass(); |
264
|
|
|
|
265
|
|
|
$email = $this->getIfSet('email', $response); |
266
|
|
|
|
267
|
|
|
$account->data->email->address = $this->getIfSet('address', $email); |
268
|
|
|
$account->data->person = new stdClass(); |
269
|
|
|
|
270
|
|
|
$person = $this->getIfSet('person', $response); |
271
|
|
|
|
272
|
|
|
$account->data->person->name = $this->getIfSet('name', $person); |
273
|
|
|
$account->data->person->lastName = $this->getIfSet('lastName', $person); |
274
|
|
|
$account->data->person->taxDocument = new stdClass(); |
275
|
|
|
|
276
|
|
|
$taxDocument = $this->getIfSet('taxDocument', $person); |
277
|
|
|
|
278
|
|
|
$account->data->person->taxDocument->type = $this->getIfSet('type', $taxDocument); |
279
|
|
|
$account->data->person->taxDocument->number = $this->getIfSet('number', $taxDocument); |
280
|
|
|
$account->data->person->phone = new stdClass(); |
281
|
|
|
|
282
|
|
|
$phone = $this->getIfSet('phone', $person); |
283
|
|
|
|
284
|
|
|
$account->data->person->phone->countryCode = $this->getIfSet('countryCode', $phone); |
285
|
|
|
$account->data->person->phone->areaCode = $this->getIfSet('areaCode', $phone); |
286
|
|
|
$account->data->person->phone->number = $this->getIfSet('number', $phone); |
287
|
|
|
$account->data->person->identityDocument = new stdClass(); |
288
|
|
|
|
289
|
|
|
$identityDocument = $this->getIfSet('identityDocument', $person); |
290
|
|
|
|
291
|
|
|
$account->data->person->identityDocument->type = $this->getIfSet('type', $identityDocument); |
292
|
|
|
$account->data->person->identityDocument->number = $this->getIfSet('number', $identityDocument); |
293
|
|
|
$account->data->person->identityDocument->issuer = $this->getIfSet('issuer', $identityDocument); |
294
|
|
|
$account->data->person->identityDocument->issueDate = $this->getIfSet('issueDate', $identityDocument); |
295
|
|
|
|
296
|
|
|
$account->data->person->birthDate = $this->getIfSet('birthDate', $person); |
297
|
|
|
$account->data->person->address = $this->getIfSet('address', $person); |
298
|
|
|
|
299
|
|
|
$account->data->person->alternativePhones = $this->getIfSet('alternativePhones', $person); |
300
|
|
|
|
301
|
|
|
$account->data->company = $this->getIfSet('company', $response); |
302
|
|
|
$account->data->_links = $this->getIfSet('_links', $response); |
303
|
|
|
$account->data->type = $this->getIfSet('type', $response); |
304
|
|
|
$account->data->id = $this->getIfSet('id', $response); |
305
|
|
|
|
306
|
|
|
return $account; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Set e-mail from account. |
311
|
|
|
* |
312
|
|
|
* @param string $email Email account. |
313
|
|
|
* |
314
|
|
|
* @return \Moip\Resource\Account |
315
|
|
|
*/ |
316
|
|
|
public function setEmail($email) |
317
|
|
|
{ |
318
|
|
|
$this->data->email->address = $email; |
319
|
|
|
|
320
|
|
|
return $this; |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Set name from account. |
325
|
|
|
* |
326
|
|
|
* @param string $name Account's person name. |
327
|
|
|
* |
328
|
|
|
* @return \Moip\Resource\Account |
329
|
|
|
*/ |
330
|
|
|
public function setName($name) |
331
|
|
|
{ |
332
|
|
|
$this->data->person->name = $name; |
333
|
|
|
|
334
|
|
|
return $this; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Set name from account. |
339
|
|
|
* |
340
|
|
|
* @param string $lastname Account's person name. |
341
|
|
|
* |
342
|
|
|
* @return \Moip\Resource\Account |
343
|
|
|
*/ |
344
|
|
|
public function setLastName($lastname) |
345
|
|
|
{ |
346
|
|
|
$this->data->person->lastName = $lastname; |
347
|
|
|
|
348
|
|
|
return $this; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Set birth date from account. |
353
|
|
|
* |
354
|
|
|
* @param \DateTime|string $birthDate Date of birth of the credit card holder. |
355
|
|
|
* |
356
|
|
|
* @return \Moip\Resource\Account |
357
|
|
|
*/ |
358
|
|
View Code Duplication |
public function setBirthDate($birthDate) |
|
|
|
|
359
|
|
|
{ |
360
|
|
|
if ($birthDate instanceof \DateTime) { |
361
|
|
|
$birthDate = $birthDate->format('Y-m-d'); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
$this->data->person->birthDate = $birthDate; |
365
|
|
|
|
366
|
|
|
return $this; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Set tax document from account. |
371
|
|
|
* |
372
|
|
|
* @param string $number Document number. |
373
|
|
|
* @param string $type Document type. |
374
|
|
|
* |
375
|
|
|
* @return \Moip\Resource\Account |
376
|
|
|
*/ |
377
|
|
View Code Duplication |
public function setTaxDocument($number, $type = self::TAX_DOCUMENT) |
|
|
|
|
378
|
|
|
{ |
379
|
|
|
$this->data->person->taxDocument = new stdClass(); |
380
|
|
|
$this->data->person->taxDocument->type = $type; |
381
|
|
|
$this->data->person->taxDocument->number = $number; |
382
|
|
|
|
383
|
|
|
return $this; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* Set phone from account. |
388
|
|
|
* |
389
|
|
|
* @param int $areaCode DDD telephone. |
390
|
|
|
* @param int $number Telephone number. |
391
|
|
|
* @param int $countryCode Country code. |
392
|
|
|
* |
393
|
|
|
* @return \Moip\Resource\Account |
394
|
|
|
*/ |
395
|
|
View Code Duplication |
public function setPhone($areaCode, $number, $countryCode = 55) |
|
|
|
|
396
|
|
|
{ |
397
|
|
|
$this->data->person->phone = new stdClass(); |
398
|
|
|
$this->data->person->phone->countryCode = $countryCode; |
399
|
|
|
$this->data->person->phone->areaCode = $areaCode; |
400
|
|
|
$this->data->person->phone->number = $number; |
401
|
|
|
|
402
|
|
|
return $this; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Set identity document from account. |
407
|
|
|
* |
408
|
|
|
* @param string $number Número do documento. |
409
|
|
|
* @param string $issuer Emissor do documento. |
410
|
|
|
* @param $issueDate |
411
|
|
|
* @param string $type Tipo do documento. Valores possíveis: RG. |
412
|
|
|
* |
413
|
|
|
* @return Account |
414
|
|
|
*/ |
415
|
|
|
public function setIdentityDocument($number, $issuer, $issueDate, $type = 'RG') |
416
|
|
|
{ |
417
|
|
|
$this->data->person->identityDocument = new stdClass(); |
418
|
|
|
$this->data->person->identityDocument->type = $type; |
419
|
|
|
$this->data->person->identityDocument->number = $number; |
420
|
|
|
$this->data->person->identityDocument->issuer = $issuer; |
421
|
|
|
$this->data->person->identityDocument->issueDate = $issueDate; |
422
|
|
|
|
423
|
|
|
return $this; |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* Set person nationality. |
428
|
|
|
* |
429
|
|
|
* @param string $nationality Abbreviation for nationality (3 max length). |
430
|
|
|
* |
431
|
|
|
* @return $this |
432
|
|
|
*/ |
433
|
|
|
public function setNationality($nationality = self::ADDRESS_COUNTRY) |
434
|
|
|
{ |
435
|
|
|
$this->data->person->nationality = $nationality; |
436
|
|
|
|
437
|
|
|
return $this; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Set person birth place. |
442
|
|
|
* |
443
|
|
|
* @param string $birthPlace Birth place (city). |
444
|
|
|
* |
445
|
|
|
* @return $this |
446
|
|
|
*/ |
447
|
|
|
public function setBirthPlace($birthPlace) |
448
|
|
|
{ |
449
|
|
|
$this->data->person->birthPlace = $birthPlace; |
450
|
|
|
|
451
|
|
|
return $this; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* Set parents name. |
456
|
|
|
* |
457
|
|
|
* @param string $motherName Mother name. |
458
|
|
|
* @param string $fatherName Father name. |
459
|
|
|
* |
460
|
|
|
* @return $this |
461
|
|
|
*/ |
462
|
|
|
public function setParentsName($motherName, $fatherName) |
463
|
|
|
{ |
464
|
|
|
$this->data->person->parentsName = new stdClass(); |
465
|
|
|
$this->data->person->parentsName->mother = $motherName; |
466
|
|
|
$this->data->person->parentsName->father = $fatherName; |
467
|
|
|
|
468
|
|
|
return $this; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Set site. |
473
|
|
|
* |
474
|
|
|
* @param string $site URL from site. |
475
|
|
|
* |
476
|
|
|
* @return $this |
477
|
|
|
*/ |
478
|
|
|
public function setSite($site) |
479
|
|
|
{ |
480
|
|
|
$this->data->site = $site; |
481
|
|
|
|
482
|
|
|
return $this; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* Set transparent account. |
487
|
|
|
* |
488
|
|
|
* @param bool $transparentAccount Set true if you want create a transparent account. |
489
|
|
|
* |
490
|
|
|
* @return $this |
491
|
|
|
*/ |
492
|
|
|
public function setTransparentAccount($transparentAccount) |
493
|
|
|
{ |
494
|
|
|
$this->data->transparentAccount = $transparentAccount; |
495
|
|
|
|
496
|
|
|
return $this; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* Set business segment. |
501
|
|
|
* |
502
|
|
|
* @param int $segmentId business segment id. Possible values available at: https://documentao-moip.readme.io/v2.0/reference#tabela-de-categorias-de-estabelecimento . |
503
|
|
|
* |
504
|
|
|
* @return $this |
505
|
|
|
*/ |
506
|
|
|
public function setBusinessSegment($segmentId) |
507
|
|
|
{ |
508
|
|
|
$this->data->businessSegment->id = $segmentId; |
509
|
|
|
|
510
|
|
|
return $this; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* Set company name. |
515
|
|
|
* |
516
|
|
|
* @param string $name Trading Name. |
517
|
|
|
* @param string $businessName Company Name. |
518
|
|
|
* |
519
|
|
|
* @return $this |
520
|
|
|
*/ |
521
|
|
|
public function setCompanyName($name, $businessName) |
522
|
|
|
{ |
523
|
|
|
$this->initializeCompany(); |
524
|
|
|
$this->data->company->name = $name; |
525
|
|
|
$this->data->company->businessName = $businessName; |
526
|
|
|
|
527
|
|
|
return $this; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* Initialize company node. |
532
|
|
|
*/ |
533
|
|
|
private function initializeCompany() |
534
|
|
|
{ |
535
|
|
|
if (!isset($this->data->company)) { |
536
|
|
|
$this->data->company = new stdClass(); |
537
|
|
|
} |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Set company opening date. |
542
|
|
|
* |
543
|
|
|
* @param \DateTime|string $openingDate . |
544
|
|
|
* |
545
|
|
|
* @return $this |
546
|
|
|
*/ |
547
|
|
|
public function setCompanyOpeningDate($openingDate) |
548
|
|
|
{ |
549
|
|
|
if ($openingDate instanceof \DateTime) { |
550
|
|
|
$openingDate = $openingDate->format('Y-m-d'); |
551
|
|
|
} |
552
|
|
|
$this->initializeCompany(); |
553
|
|
|
$this->data->company->openingDate = $openingDate; |
554
|
|
|
|
555
|
|
|
return $this; |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Set company tax document. |
560
|
|
|
* |
561
|
|
|
* @param string $documentNumber . |
562
|
|
|
* |
563
|
|
|
* @return $this |
564
|
|
|
*/ |
565
|
|
View Code Duplication |
public function setCompanyTaxDocument($documentNumber) |
|
|
|
|
566
|
|
|
{ |
567
|
|
|
$this->initializeCompany(); |
568
|
|
|
$this->data->company->taxDocument = new stdClass(); |
569
|
|
|
$this->data->company->taxDocument->type = self::COMPANY_TAX_DOCUMENT; |
570
|
|
|
$this->data->company->taxDocument->number = $documentNumber; |
571
|
|
|
|
572
|
|
|
return $this; |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
/** |
576
|
|
|
* Set company tax document. |
577
|
|
|
* |
578
|
|
|
* @param string $documentNumber . |
|
|
|
|
579
|
|
|
* |
580
|
|
|
* @return $this |
581
|
|
|
*/ |
582
|
|
|
public function setCompanyMainActivity($cnae, $description) |
583
|
|
|
{ |
584
|
|
|
$this->initializeCompany(); |
585
|
|
|
$this->data->company->mainActivity = new stdClass(); |
586
|
|
|
$this->data->company->mainActivity->cnae = $cnae; |
587
|
|
|
$this->data->company->mainActivity->description = $description; |
588
|
|
|
|
589
|
|
|
return $this; |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* Set address to company. |
594
|
|
|
* |
595
|
|
|
* @param string $street Street address. |
596
|
|
|
* @param string $number Number address. |
597
|
|
|
* @param string $district Neighborhood address. |
598
|
|
|
* @param string $city City address. |
599
|
|
|
* @param string $state State address. |
600
|
|
|
* @param string $zip The zip code billing address. |
601
|
|
|
* @param string $complement Address complement. |
602
|
|
|
* @param string $country Country ISO-alpha3 format, BRA example. |
603
|
|
|
* |
604
|
|
|
* @return $this |
605
|
|
|
*/ |
606
|
|
View Code Duplication |
public function setCompanyAddress($street, $number, $district, $city, $state, $zip, $complement = null, $country = self::ADDRESS_COUNTRY) |
|
|
|
|
607
|
|
|
{ |
608
|
|
|
$address = new stdClass(); |
609
|
|
|
$address->street = $street; |
610
|
|
|
$address->streetNumber = $number; |
611
|
|
|
$address->complement = $complement; |
612
|
|
|
$address->district = $district; |
613
|
|
|
$address->city = $city; |
614
|
|
|
$address->state = $state; |
615
|
|
|
$address->country = $country; |
616
|
|
|
$address->zipCode = $zip; |
617
|
|
|
|
618
|
|
|
$this->initializeCompany(); |
619
|
|
|
$this->data->company->address = $address; |
620
|
|
|
|
621
|
|
|
return $this; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* Set company phone. |
626
|
|
|
* |
627
|
|
|
* @param int $areaCode DDD telephone. |
628
|
|
|
* @param int $number Telephone number. |
629
|
|
|
* @param int $countryCode Country code. |
630
|
|
|
* |
631
|
|
|
* @return \Moip\Resource\Account |
632
|
|
|
*/ |
633
|
|
|
public function setCompanyPhone($areaCode, $number, $countryCode = 55) |
634
|
|
|
{ |
635
|
|
|
$this->initializeCompany(); |
636
|
|
|
$this->data->company->phone = new stdClass(); |
637
|
|
|
$this->data->company->phone->countryCode = $countryCode; |
638
|
|
|
$this->data->company->phone->areaCode = $areaCode; |
639
|
|
|
$this->data->company->phone->number = $number; |
640
|
|
|
|
641
|
|
|
return $this; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* Set account type. Possible values: CONSUMER, MERCHANT. |
646
|
|
|
* |
647
|
|
|
* @param string $type |
648
|
|
|
* |
649
|
|
|
* @return \Moip\Resource\Account |
650
|
|
|
*/ |
651
|
|
|
public function setType($type) |
652
|
|
|
{ |
653
|
|
|
$this->data->type = $type; |
654
|
|
|
|
655
|
|
|
return $this; |
656
|
|
|
} |
657
|
|
|
} |
658
|
|
|
|
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.