efi-bank 0.1.3

A SDK for interacting with the EFI Bank.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
use serde::{Deserialize, Serialize};
use serde_json::Value;

// ========== Split de pagamento Pix ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitRepasse {
    #[serde(rename = "tipo")]
    pub tipo: String,
    #[serde(rename = "valor")]
    pub valor: String,
    #[serde(rename = "favorecido")]
    pub favorecido: SplitFavorecido,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitFavorecido {
    #[serde(rename = "cpf")]
    pub cpf: String,
    #[serde(rename = "conta")]
    pub conta: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitParte {
    #[serde(rename = "tipo")]
    pub tipo: String,
    #[serde(rename = "valor")]
    pub valor: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitPayload {
    #[serde(rename = "descricao")]
    pub descricao: String,
    #[serde(rename = "lancamento")]
    pub lancamento: SplitLancamento,
    #[serde(rename = "split")]
    pub split: SplitConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitLancamento {
    #[serde(rename = "imediato")]
    pub imediato: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitConfig {
    #[serde(rename = "divisaoTarifa")]
    pub divisao_tarifa: String,
    #[serde(rename = "minhaParte")]
    pub minha_parte: SplitParte,
    #[serde(rename = "repasses")]
    pub repasses: Vec<SplitRepasse>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitConfigResponse {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "descricao")]
    pub descricao: Option<String>,
    #[serde(rename = "lancamento")]
    pub lancamento: Option<SplitLancamento>,
    #[serde(rename = "split")]
    pub split: Option<SplitConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitLinkResponse {
    #[serde(rename = "status")]
    pub status: String,
    #[serde(rename = "message")]
    pub message: Option<String>,
}

// ========== COB - Immediate Charge (Cobrança Imediata) ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobPayload {
    #[serde(rename = "calendario")]
    pub calendario: CobCalendario,
    #[serde(rename = "devedor")]
    pub devedor: Option<CobPessoa>,
    #[serde(rename = "valor")]
    pub valor: CobValor,
    #[serde(rename = "chave")]
    pub chave: String,
    #[serde(rename = "solicitacaoPagador")]
    pub solicitacao_pagador: Option<String>,
    #[serde(rename = "infoAdicionais")]
    pub info_adicionais: Option<Vec<CobInfoAdicional>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobCalendario {
    #[serde(rename = "dataDeVencimento")]
    pub data_de_vencimento: Option<String>,
    #[serde(rename = "validadeAposVencimento")]
    pub validade_apos_vencimento: Option<i32>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobPessoa {
    #[serde(rename = "cpf")]
    pub cpf: Option<String>,
    #[serde(rename = "cnpj")]
    pub cnpj: Option<String>,
    #[serde(rename = "nome")]
    pub nome: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobValor {
    #[serde(rename = "original")]
    pub original: String,
    #[serde(rename = "multa")]
    pub multa: Option<String>,
    #[serde(rename = "juros")]
    pub juros: Option<String>,
    #[serde(rename = "desconto")]
    pub desconto: Option<String>,
    #[serde(rename = "abatimento")]
    pub abatimento: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobInfoAdicional {
    #[serde(rename = "nome")]
    pub nome: String,
    #[serde(rename = "valor")]
    pub valor: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobResponse {
    #[serde(rename = "txid")]
    pub txid: String,
    #[serde(rename = "calendario")]
    pub calendario: Option<CobCalendarioResponse>,
    #[serde(rename = "devedor")]
    pub devedor: Option<CobPessoa>,
    #[serde(rename = "valor")]
    pub valor: Option<CobValor>,
    #[serde(rename = "chave")]
    pub chave: Option<String>,
    #[serde(rename = "solicitacaoPagador")]
    pub solicitacao_pagador: Option<String>,
    #[serde(rename = "infoAdicionais")]
    pub info_adicionais: Option<Vec<CobInfoAdicional>>,
    #[serde(rename = "br")]
    pub br: Option<String>,
    #[serde(rename = "status")]
    pub status: Option<String>,
    #[serde(rename = "criacaoDateTime")]
    pub criacao_date_time: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobCalendarioResponse {
    #[serde(rename = "criacaoDateTime")]
    pub criacao_date_time: Option<String>,
    #[serde(rename = "dataDeVencimento")]
    pub data_de_vencimento: Option<String>,
    #[serde(rename = "validadeAposVencimento")]
    pub validade_apos_vencimento: Option<i32>,
}

// ========== COBV - Expiring Charge (Cobrança com Vencimento) ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobvPayload {
    #[serde(rename = "calendario")]
    pub calendario: CobvCalendario,
    #[serde(rename = "devedor")]
    pub devedor: Option<CobPessoa>,
    #[serde(rename = "valor")]
    pub valor: CobValor,
    #[serde(rename = "chave")]
    pub chave: String,
    #[serde(rename = "solicitacaoPagador")]
    pub solicitacao_pagador: Option<String>,
    #[serde(rename = "infoAdicionais")]
    pub info_adicionais: Option<Vec<CobInfoAdicional>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobvCalendario {
    #[serde(rename = "dataDeVencimento")]
    pub data_de_vencimento: String,
    #[serde(rename = "validadeAposVencimento")]
    pub validade_apos_vencimento: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobvResponse {
    #[serde(rename = "txid")]
    pub txid: String,
    #[serde(rename = "calendario")]
    pub calendario: Option<CobvCalendarioResponse>,
    #[serde(rename = "devedor")]
    pub devedor: Option<CobPessoa>,
    #[serde(rename = "valor")]
    pub valor: Option<CobValor>,
    #[serde(rename = "chave")]
    pub chave: Option<String>,
    #[serde(rename = "solicitacaoPagador")]
    pub solicitacao_pagador: Option<String>,
    #[serde(rename = "infoAdicionais")]
    pub info_adicionais: Option<Vec<CobInfoAdicional>>,
    #[serde(rename = "br")]
    pub br: Option<String>,
    #[serde(rename = "status")]
    pub status: Option<String>,
    #[serde(rename = "criacaoDateTime")]
    pub criacao_date_time: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CobvCalendarioResponse {
    #[serde(rename = "criacaoDateTime")]
    pub criacao_date_time: Option<String>,
    #[serde(rename = "dataDeVencimento")]
    pub data_de_vencimento: Option<String>,
    #[serde(rename = "validadeAposVencimento")]
    pub validade_apos_vencimento: Option<i32>,
}

// ========== Webhook Management ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebhookPayload {
    #[serde(rename = "url")]
    pub url: String,
    #[serde(rename = "chave")]
    pub chave: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebhookResponse {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "url")]
    pub url: String,
    #[serde(rename = "chave")]
    pub chave: Option<String>,
    #[serde(rename = "criacaoDateTime")]
    pub criacao_date_time: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebhooksListResponse {
    #[serde(rename = "webhooks")]
    pub webhooks: Vec<WebhookResponse>,
}

// ========== PIX Transactions ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PixTransactionPayload {
    #[serde(rename = "valor")]
    pub valor: String,
    #[serde(rename = "chaveDestino")]
    pub chave_destino: String,
    #[serde(rename = "descricao")]
    pub descricao: Option<String>,
    #[serde(rename = "idempotencyKey")]
    pub idempotency_key: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PixTransactionResponse {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "endToEndId")]
    pub end_to_end_id: String,
    #[serde(rename = "valor")]
    pub valor: String,
    #[serde(rename = "status")]
    pub status: String,
    #[serde(rename = "chaveDestino")]
    pub chave_destino: Option<String>,
    #[serde(rename = "dataHora")]
    pub data_hora: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PixTransactionDetailResponse {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "endToEndId")]
    pub end_to_end_id: String,
    #[serde(rename = "valor")]
    pub valor: String,
    #[serde(rename = "status")]
    pub status: String,
    #[serde(rename = "chaveDestino")]
    pub chave_destino: Option<String>,
    #[serde(rename = "chaveOrigem")]
    pub chave_origem: Option<String>,
    #[serde(rename = "dataHora")]
    pub data_hora: Option<String>,
    #[serde(rename = "motivoCancelamento")]
    pub motivo_cancelamento: Option<String>,
}

// ========== Billing API - Split de Pagamento ==========

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingRepasse {
    #[serde(rename = "payee_code")]
    pub payee_code: String,
    /// transfer percentage, where 9000 equals 90%
    #[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
    pub percentage: Option<i32>,
    #[serde(rename = "fixed", skip_serializing_if = "Option::is_none")]
    pub fixed: Option<i32>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum BillingRepasseType {
    /// fee is deducted only from the account that issued the charge
    IssuerOnly = 1,
    /// fee is deducted proportionally according to the percentage defined for each account receiving the transfer
    Proportional = 2,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingMarketplace {
    #[serde(rename = "repasses")]
    pub repasses: Vec<BillingRepasse>,
    pub mode: BillingRepasseType,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingItem {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "value")]
    pub value: i64,
    #[serde(rename = "amount")]
    pub amount: i32,
    #[serde(rename = "marketplace")]
    pub marketplace: BillingMarketplace,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingShipping {
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "value")]
    pub value: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingAddress {
    #[serde(rename = "street")]
    pub street: Option<String>,
    #[serde(rename = "number")]
    pub number: Option<String>,
    #[serde(rename = "neighborhood")]
    pub neighborhood: Option<String>,
    #[serde(rename = "zipcode")]
    pub zipcode: Option<String>,
    #[serde(rename = "city")]
    pub city: Option<String>,
    #[serde(rename = "complement")]
    pub complement: Option<String>,
    #[serde(rename = "state")]
    pub state: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingJuridicalPerson {
    pub corporate_name: String,
    pub cnpj: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingCustomer {
    pub name: String,
    pub cpf: String,
    pub email: Option<String>,
    pub birth: Option<String>,
    pub phone_number: Option<String>,
    pub address: Option<BillingAddress>,
    pub juridical_person: Option<BillingJuridicalPerson>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingBilletConfigurations {
    #[serde(rename = "fine")]
    pub fine: Option<i64>,
    #[serde(rename = "interest")]
    pub interest: Option<i64>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingBankingBillet {
    #[serde(rename = "expire_at")]
    pub expire_at: Option<String>,
    #[serde(rename = "customer")]
    pub customer: BillingCustomer,
    #[serde(rename = "configurations")]
    pub configurations: Option<BillingBilletConfigurations>,
    #[serde(rename = "message")]
    pub message: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingPayment {
    #[serde(rename = "banking_billet")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub banking_billet: Option<BillingBankingBillet>,
    #[serde(rename = "credit_card")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credit_card: Option<BillingCreditCard>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingCreditCard {
    #[serde(rename = "customer")]
    pub customer: BillingCustomer,
    #[serde(rename = "installments")]
    pub installments: i32,
    #[serde(rename = "payment_token")]
    pub payment_token: String,
    #[serde(rename = "billing_address")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub billing_address: Option<BillingAddress>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargeMetadata {
    /// Your valid URL address that will receive notifications of transaction status changes.
    /// Maximum of 255 characters.
    pub notification_url: Option<String>,
    /// Allows associating an EfĂ­ transaction with a specific ID from your system or application,
    /// allowing you to identify it if you have a specific identification and want to maintain it.
    /// Maximum of 255 characters.
    pub custom_id: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargeCreateRequest {
    #[serde(rename = "items")]
    pub items: Vec<BillingItem>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<BillingChargeMetadata>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargeOneStepRequest {
    #[serde(rename = "items")]
    pub items: Vec<BillingItem>,
    #[serde(rename = "shippings")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shippings: Option<Vec<BillingShipping>>,
    #[serde(rename = "payment")]
    pub payment: BillingPayment,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<BillingChargeMetadata>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargePayRequest {
    #[serde(rename = "payment")]
    pub payment: BillingPayment,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargeResponse {
    #[serde(rename = "code")]
    pub code: i32,
    #[serde(rename = "data")]
    pub data: BillingChargeData,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingChargeData {
    #[serde(rename = "barcode")]
    pub barcode: Option<String>,
    #[serde(rename = "pix")]
    pub pix: Option<BillingPix>,
    #[serde(rename = "link")]
    pub link: Option<String>,
    #[serde(rename = "billet_link")]
    pub billet_link: Option<String>,
    #[serde(rename = "pdf")]
    pub pdf: Option<BillingPdf>,
    #[serde(rename = "expire_at")]
    pub expire_at: Option<String>,
    #[serde(rename = "charge_id")]
    pub charge_id: Option<i64>,
    #[serde(rename = "status")]
    pub status: Option<String>,
    #[serde(rename = "total")]
    pub total: Option<i64>,
    #[serde(rename = "payment")]
    pub payment: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingPix {
    #[serde(rename = "qrcode")]
    pub qrcode: Option<String>,
    #[serde(rename = "qrcode_image")]
    pub qrcode_image: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingPdf {
    #[serde(rename = "charge")]
    pub charge: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BillingNotificationResponse {
    #[serde(flatten)]
    pub data: Value,
}