1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ipag\Sdk\Model; |
4
|
|
|
|
5
|
|
|
use Ipag\Sdk\Model\Schema\Mutator; |
6
|
|
|
use Ipag\Sdk\Model\Schema\Schema; |
7
|
|
|
use Ipag\Sdk\Model\Schema\SchemaBuilder; |
8
|
|
|
use Kubinyete\Assertation\Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* PaymentSplitRules Class |
12
|
|
|
* |
13
|
|
|
* Classe responsável por representar o recurso Payment Split Rules. |
14
|
|
|
*/ |
15
|
|
|
class PaymentSplitRules extends Model |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param array $data |
19
|
|
|
* array de dados do Split Rules. |
20
|
|
|
* |
21
|
|
|
* + [`'seller_id'`] string. |
22
|
|
|
* + [`'amount'`] float. |
23
|
|
|
* + [`'percentage'`] float. |
24
|
|
|
* + [`'liable'`] bool. |
25
|
|
|
* + [`'charge_processing_fee'`] bool. |
26
|
|
|
* + [`'hold_receivables'`] bool. |
27
|
|
|
*/ |
28
|
|
|
public function __construct(?array $data = []) |
29
|
|
|
{ |
30
|
|
|
parent::__construct($data); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
protected function schema(SchemaBuilder $schema): Schema |
34
|
|
|
{ |
35
|
|
|
$schema->string('seller_id')->nullable(); |
36
|
|
|
$schema->float('percentage')->nullable(); |
37
|
|
|
$schema->float('amount')->nullable(); |
38
|
|
|
$schema->bool('liable')->nullable(); |
39
|
|
|
$schema->bool('charge_processing_fee')->nullable(); |
40
|
|
|
$schema->bool('hold_receivables')->nullable(); |
41
|
|
|
|
42
|
|
|
return $schema->build(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected function amount(): Mutator |
46
|
|
|
{ |
47
|
|
|
return new Mutator( |
48
|
|
|
null, |
49
|
|
|
fn($value, $ctx) => |
50
|
|
|
is_null($value) ? $value : |
51
|
|
|
( |
52
|
|
|
Assert::value(floatval($value))->gte(0)->get() |
53
|
|
|
?? $ctx->raise('inválido') |
54
|
|
|
) |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function percentage(): Mutator |
59
|
|
|
{ |
60
|
|
|
return new Mutator( |
61
|
|
|
null, |
62
|
|
|
fn($value, $ctx) => |
63
|
|
|
is_null($value) ? $value : |
64
|
|
|
( |
65
|
|
|
Assert::value(floatval($value))->gte(0)->get() |
66
|
|
|
?? $ctx->raise('inválido') |
67
|
|
|
) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Retorna o valor da propriedade `seller_id`. |
73
|
|
|
* |
74
|
|
|
* @return string|null |
75
|
|
|
*/ |
76
|
|
|
public function getSellerId(): ?string |
77
|
|
|
{ |
78
|
|
|
return $this->get('seller_id'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Seta o valor da propriedade `seller_id`. |
83
|
|
|
* |
84
|
|
|
* @param string|null $sellerId |
85
|
|
|
* @return self |
86
|
|
|
*/ |
87
|
|
|
public function setSellerId(?string $sellerId = null): self |
88
|
|
|
{ |
89
|
|
|
$this->set('seller_id', $sellerId); |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Retorna o valor da propriedade `percentage`. |
95
|
|
|
* |
96
|
|
|
* @return float|null |
97
|
|
|
*/ |
98
|
|
|
public function getPercentage(): ?float |
99
|
|
|
{ |
100
|
|
|
return $this->get('percentage'); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Seta o valor da propriedade `percentage`. |
105
|
|
|
* |
106
|
|
|
* @param float|null $percentage |
107
|
|
|
* @return self |
108
|
|
|
*/ |
109
|
|
|
public function setPercentage(?float $percentage = null): self |
110
|
|
|
{ |
111
|
|
|
$this->set('percentage', $percentage); |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Retorna o valor da propriedade `amount`. |
117
|
|
|
* |
118
|
|
|
* @return float|null |
119
|
|
|
*/ |
120
|
|
|
public function getAmount(): ?float |
121
|
|
|
{ |
122
|
|
|
return $this->get('amount'); |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Seta o valor da propriedade `amount`. |
128
|
|
|
* |
129
|
|
|
* @param float|null $amount |
130
|
|
|
* @return self |
131
|
|
|
*/ |
132
|
|
|
public function setAmount(?float $amount = null): self |
133
|
|
|
{ |
134
|
|
|
$this->set('amount', $amount); |
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Retorna o valor da propriedade `liable`. |
140
|
|
|
* |
141
|
|
|
* @return boolean|null |
142
|
|
|
*/ |
143
|
|
|
public function getLiable(): ?bool |
144
|
|
|
{ |
145
|
|
|
return $this->get('liable'); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Seta o valor da propriedade `liable`. |
150
|
|
|
* |
151
|
|
|
* @param boolean|null $liable |
152
|
|
|
* @return self |
153
|
|
|
*/ |
154
|
|
|
public function setLiable(?bool $liable = null): self |
155
|
|
|
{ |
156
|
|
|
$this->set('liable', $liable); |
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Retorna o valor da propriedade `charge_processing_fee`. |
162
|
|
|
* |
163
|
|
|
* @return boolean|null |
164
|
|
|
*/ |
165
|
|
|
public function getChargeProcessingFee(): ?bool |
166
|
|
|
{ |
167
|
|
|
return $this->get('charge_processing_fee'); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Seta o valor da propriedade `charge_processing_fee`. |
172
|
|
|
* |
173
|
|
|
* @param boolean|null $chargeProcessingFee |
174
|
|
|
* @return self |
175
|
|
|
*/ |
176
|
|
|
public function setChargeProcessingFee(?bool $chargeProcessingFee = null): self |
177
|
|
|
{ |
178
|
|
|
$this->set('charge_processing_fee', $chargeProcessingFee); |
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Retorna o valor da propriedade `hold_receivables`. |
184
|
|
|
* |
185
|
|
|
* @return boolean|null |
186
|
|
|
*/ |
187
|
|
|
public function getHoldReceivables(): ?bool |
188
|
|
|
{ |
189
|
|
|
return $this->get('hold_receivables'); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Seta o valor da propriedade `hold_receivables`. |
194
|
|
|
* |
195
|
|
|
* @param boolean|null $holdReceivables |
196
|
|
|
* @return self |
197
|
|
|
*/ |
198
|
|
|
public function setHoldReceivables(?bool $holdReceivables = null): self |
199
|
|
|
{ |
200
|
|
|
$this->set('hold_receivables', $holdReceivables); |
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
} |