|
2 | 2 |
|
3 | 3 | [](https://github.com/cuenca-mx/cep-python/actions?query=workflow%3Atest) |
4 | 4 | [](https://codecov.io/gh/cuenca-mx/cep-python) |
5 | | -[](https://pypi.org/project/cuenca/) |
| 5 | +[](https://pypi.org/project/cepmex/) |
6 | 6 |
|
7 | 7 | Python client library for CEP (http://www.banxico.org.mx/cep/) |
8 | 8 |
|
9 | 9 |
|
10 | | -## Instalación |
| 10 | +## Installation |
11 | 11 |
|
12 | 12 | ```bash |
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 | +import cep |
| 22 | + |
| 23 | +cep.configure(beta=True) |
| 24 | +``` |
20 | 25 |
|
| 26 | +To run unit tests, use `pytest`. |
| 27 | +```bash |
| 28 | +pytest |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +```python |
| 34 | +from datetime import date |
21 | 35 | from cep import Transferencia |
| 36 | +from cep.exc import TransferNotFoundError |
| 37 | + |
| 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=817, # In cents |
| 46 | + ) |
| 47 | + pdf = tr.descargar() |
| 48 | + with open('CUENCA1555093850.pdf', 'wb') as f: |
| 49 | + f.write(pdf) |
| 50 | +except TransferNotFoundError 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` (`int`): Transfer amount **in cents**. |
| 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 |
22 | 70 |
|
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() |
| 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 | ``` |
| 79 | + |
| 80 | +## Exceptions |
| 81 | + |
| 82 | +- `TransferNotFoundError`: The transfer was not found. |
| 83 | +- `MaxRequestError`: The maximum number of requests has been reached. |
| 84 | +- `CepNotAvailableError`: The transfer was found, but the CEP is not available. |
| 85 | + |
0 commit comments