1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Moip\Resource; |
5
|
|
|
|
6
|
|
|
use Requests; |
7
|
|
|
use stdClass; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Transfers |
11
|
|
|
* |
12
|
|
|
* @package Moip\Resource |
13
|
|
|
*/ |
14
|
|
|
class Transfers extends MoipResource |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @const strign |
18
|
|
|
*/ |
19
|
|
|
const PATH = 'transfers'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @const strign |
23
|
|
|
*/ |
24
|
|
|
const METHOD = 'BANK_ACCOUNT'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @const strign |
28
|
|
|
*/ |
29
|
|
|
const TYPE = 'CHECKING'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @const strign |
33
|
|
|
*/ |
34
|
|
|
const TYPE_HOLD = 'CPF'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Initializes new instances. |
38
|
|
|
*/ |
39
|
|
|
protected function initialize() |
40
|
|
|
{ |
41
|
|
|
$this->data = new stdClass(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param stdClass $response |
46
|
|
|
* |
47
|
|
|
* @return Transfers |
48
|
|
|
*/ |
49
|
|
|
protected function populate(stdClass $response) |
50
|
|
|
{ |
51
|
|
|
$transfers = clone $this; |
52
|
|
|
|
53
|
|
|
return $transfers; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Set info of transfers. |
58
|
|
|
* |
59
|
|
|
* @param $amount |
60
|
|
|
* @param $bankNumber Bank number. possible values: 001, 237, 341, 041. |
61
|
|
|
* @param $agencyNumber |
62
|
|
|
* @param $agencyCheckNumber |
63
|
|
|
* @param $accountNumber |
64
|
|
|
* @param $accountCheckNumber |
65
|
|
|
* |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function setTransfers( |
69
|
|
|
$amount, |
70
|
|
|
$bankNumber, |
71
|
|
|
$agencyNumber, |
72
|
|
|
$agencyCheckNumber, |
73
|
|
|
$accountNumber, |
74
|
|
|
$accountCheckNumber |
75
|
|
|
) { |
76
|
|
|
$this->data->amount = $amount; |
77
|
|
|
$this->data->transferInstrument = new stdClass(); |
78
|
|
|
$this->data->transferInstrument->method = self::METHOD; |
79
|
|
|
$this->data->transferInstrument->bankAccount = new stdClass(); |
80
|
|
|
$this->data->transferInstrument->bankAccount->type = self::TYPE; |
81
|
|
|
$this->data->transferInstrument->bankAccount->bankNumber = $bankNumber; |
82
|
|
|
$this->data->transferInstrument->bankAccount->agencyNumber = $agencyNumber; |
83
|
|
|
$this->data->transferInstrument->bankAccount->agencyCheckNumber = $agencyCheckNumber; |
84
|
|
|
$this->data->transferInstrument->bankAccount->accountNumber = $accountNumber; |
85
|
|
|
$this->data->transferInstrument->bankAccount->accountCheckNumber = $accountCheckNumber; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
* @param $fullname |
93
|
|
|
* @param $taxDocument |
94
|
|
|
* |
95
|
|
|
* @return $this |
96
|
|
|
*/ |
97
|
|
|
public function setHolder($fullname, $taxDocument){ |
98
|
|
|
|
99
|
|
|
$this->data->transferInstrument->bankAccount->holder = new stdClass(); |
100
|
|
|
$this->data->transferInstrument->bankAccount->holder->fullname = $fullname; |
101
|
|
|
$this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass(); |
102
|
|
|
$this->data->transferInstrument->bankAccount->holder->taxDocument->type = self::TYPE_HOLD; |
103
|
|
|
$this->data->transferInstrument->bankAccount->holder->taxDocument->number = $taxDocument; |
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Execute Tranfers. |
109
|
|
|
* |
110
|
|
|
* @return Transfers |
111
|
|
|
*/ |
112
|
|
|
public function execute() |
113
|
|
|
{ |
114
|
|
|
$path = sprintf('/%s/%s', MoipResource::VERSION, self::PATH); |
115
|
|
|
|
116
|
|
|
$response = $this->httpRequest($path, Requests::POST, $this); |
117
|
|
|
|
118
|
|
|
return $this->populate($response); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get MoIP Transfers id. |
123
|
|
|
* |
124
|
|
|
* @return strign |
125
|
|
|
*/ |
126
|
|
|
public function getId() |
127
|
|
|
{ |
128
|
|
|
return $this->getIfSet('id'); |
129
|
|
|
} |
130
|
|
|
} |