|
1
|
|
|
<?php |
|
2
|
|
|
namespace PHPSC\PagSeguro\Requests\PreApprovals; |
|
3
|
|
|
|
|
4
|
|
|
use DateTime; |
|
5
|
|
|
use PHPSC\PagSeguro\Customer\Customer; |
|
6
|
|
|
use PHPSC\PagSeguro\Requests\RequestBuilder as RequestBuilderInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @author Luís Otávio Cobucci Oblonczyk <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class RequestBuilder implements RequestBuilderInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var Request |
|
15
|
|
|
*/ |
|
16
|
|
|
private $request; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param Request $request |
|
20
|
|
|
* @param boolean $manualCharge |
|
21
|
|
|
*/ |
|
22
|
4 |
|
public function __construct($manualCharge, Request $request = null) |
|
23
|
|
|
{ |
|
24
|
4 |
|
$this->request = $request ?: new Request(); |
|
25
|
|
|
|
|
26
|
4 |
|
$this->request->getPreApproval()->setChargeType( |
|
27
|
4 |
|
$manualCharge ? ChargeType::MANUAL : ChargeType::AUTOMATIC |
|
28
|
|
|
); |
|
29
|
4 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
1 |
|
public function setCustomer(Customer $customer) |
|
35
|
|
|
{ |
|
36
|
1 |
|
$this->request->setCustomer($customer); |
|
37
|
|
|
|
|
38
|
1 |
|
return $this; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function setName($name) |
|
45
|
|
|
{ |
|
46
|
1 |
|
$this->request->getPreApproval()->setName($name); |
|
47
|
|
|
|
|
48
|
1 |
|
return $this; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function setDetails($details) |
|
55
|
|
|
{ |
|
56
|
1 |
|
$this->request->getPreApproval()->setDetails($details); |
|
57
|
|
|
|
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritdoc} |
|
63
|
|
|
*/ |
|
64
|
1 |
|
public function setFinalDate(DateTime $finalDate) |
|
65
|
|
|
{ |
|
66
|
1 |
|
$this->request->getPreApproval()->setFinalDate($finalDate); |
|
67
|
|
|
|
|
68
|
1 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritdoc} |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public function setMaxTotalAmount($maxTotalAmount) |
|
75
|
|
|
{ |
|
76
|
1 |
|
$this->request->getPreApproval()->setMaxTotalAmount($maxTotalAmount); |
|
77
|
|
|
|
|
78
|
1 |
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritdoc} |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function setPeriod($period) |
|
85
|
|
|
{ |
|
86
|
1 |
|
$this->request->getPreApproval()->setPeriod($period); |
|
87
|
|
|
|
|
88
|
1 |
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* {@inheritdoc} |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function setRedirectTo($redirectTo) |
|
95
|
|
|
{ |
|
96
|
1 |
|
$this->request->setRedirectTo($redirectTo); |
|
97
|
|
|
|
|
98
|
1 |
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* {@inheritdoc} |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function setReference($reference) |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->request->setReference($reference); |
|
107
|
|
|
|
|
108
|
1 |
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* {@inheritdoc} |
|
113
|
|
|
*/ |
|
114
|
1 |
|
public function setReviewOn($reviewOn) |
|
115
|
|
|
{ |
|
116
|
1 |
|
$this->request->setReviewOn($reviewOn); |
|
117
|
|
|
|
|
118
|
1 |
|
return $this; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* {@inheritdoc} |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function setAmountPerPayment($amountPerPayment) |
|
125
|
|
|
{ |
|
126
|
1 |
|
$this->request->getPreApproval()->setAmountPerPayment($amountPerPayment); |
|
127
|
|
|
|
|
128
|
1 |
|
return $this; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* {@inheritdoc} |
|
133
|
|
|
*/ |
|
134
|
1 |
|
public function setMaxAmountPerPayment($maxAmountPerPayment) |
|
135
|
|
|
{ |
|
136
|
1 |
|
$this->request->getPreApproval()->setMaxAmountPerPayment($maxAmountPerPayment); |
|
137
|
|
|
|
|
138
|
1 |
|
return $this; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* {@inheritdoc} |
|
143
|
|
|
*/ |
|
144
|
1 |
|
public function setMaxPaymentsPerPeriod($maxPaymentsPerPeriod) |
|
145
|
|
|
{ |
|
146
|
1 |
|
$this->request->getPreApproval()->setMaxPaymentsPerPeriod($maxPaymentsPerPeriod); |
|
147
|
|
|
|
|
148
|
1 |
|
return $this; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* {@inheritdoc} |
|
153
|
|
|
*/ |
|
154
|
1 |
|
public function setMaxAmountPerPeriod($maxAmountPerPeriod) |
|
155
|
|
|
{ |
|
156
|
1 |
|
$this->request->getPreApproval()->setMaxAmountPerPeriod($maxAmountPerPeriod); |
|
157
|
|
|
|
|
158
|
1 |
|
return $this; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* {@inheritdoc} |
|
163
|
|
|
*/ |
|
164
|
1 |
|
public function setInitialDate(DateTime $initialDate) |
|
165
|
|
|
{ |
|
166
|
1 |
|
$this->request->getPreApproval()->setInitialDate($initialDate); |
|
167
|
|
|
|
|
168
|
1 |
|
return $this; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* {@inheritdoc} |
|
173
|
|
|
*/ |
|
174
|
1 |
|
public function getRequest() |
|
175
|
|
|
{ |
|
176
|
1 |
|
return $this->request; |
|
177
|
|
|
} |
|
178
|
|
|
} |
|
179
|
|
|
|