@@ -13,20 +13,66 @@ Python client library for CEP (http://www.banxico.org.mx/cep/)
13
13
pip install cepmex
14
14
```
15
15
16
- ### Uso
16
+ ## Development & Testing
17
+
18
+ You can use a staging environment to test the library:
17
19
18
20
``` python
19
- from datetime import date
21
+ from cep import Config
22
+
23
+ Config.BASE_URL = ' http://www.banxico.org.mx/cep-beta'
24
+ ```
25
+
26
+ To run unit tests, use ` pytest ` .
27
+ ``` bash
28
+ pytest
29
+ ```
30
+
31
+ ### Usage
20
32
33
+ ``` python
34
+ from datetime import date
21
35
from cep import Transferencia
36
+ from cep.exc import NotFoundError
22
37
23
- tr = Transferencia.validar(
24
- fecha = date(2019 , 4 , 12 ),
25
- clave_rastreo = ' CUENCA1555093850' ,
26
- emisor = ' 90646' , # STP
27
- receptor = ' 40012' , # BBVA
28
- cuenta = ' 012180004643051249' ,
29
- monto = 8.17 ,
30
- )
31
- pdf = tr.descargar()
38
+ try :
39
+ tr = Transferencia.validar(
40
+ fecha = date(2019 , 4 , 12 ),
41
+ clave_rastreo = ' CUENCA1555093850' ,
42
+ emisor = ' 90646' , # STP
43
+ receptor = ' 40012' , # BBVA
44
+ cuenta = ' 012180004643051249' ,
45
+ monto = 8.17 ,
46
+ )
47
+ pdf = tr.descargar()
48
+ with open (' CUENCA1555093850.pdf' , ' wb' ) as f:
49
+ f.write(pdf)
50
+ except NotFoundError as e:
51
+ print (' No se encontro la transferencia' )
52
+ ```
53
+
54
+ ## Validate Transfer Parameters
55
+
56
+ Use the ` validar ` method to validate a transfer with the following parameters:
57
+
58
+ ### Required Parameters:
59
+ - ` fecha ` (` datetime.date ` ): Transfer date.
60
+ - ` clave_rastreo ` (` str ` ): Transfer tracking key.
61
+ - ` emisor ` (` str ` ): Transfer sender bank code.
62
+ - ` receptor ` (` str ` ): Transfer receiver bank code.
63
+ - ` cuenta ` (` str ` ): Transfer account number.
64
+ - ` monto ` (` Decimal ` ): Transfer amount.
65
+
66
+ ### Optional Parameters:
67
+ - ` pago_a_banco ` (` bool ` , default=` False ` ): Set to ` True ` for transfer types 4 and 31.
68
+
69
+ ## Download Transfer Data
70
+
71
+ Use the ` descargar ` method to download a transfer in one of the following formats:
72
+ - ` PDF ` (default)
73
+ - ` XML `
74
+ - ` ZIP `
75
+
76
+ ``` python
77
+ tr.descargar(formato = ' XML' )
32
78
```
0 commit comments