|
1 |
| -# quienesquien-python |
| 1 | +# quienesquien |
2 | 2 |
|
3 |
| -Cliente para el servicio de listas de Quienesquien |
| 3 | +[](https://github.com/cuenca-mx/quienesquien-python/actions?query=workflow%3Atest) |
| 4 | +[](https://codecov.io/gh/cuenca-mx/quienesquien-python) |
| 5 | +[](https://pypi.org/project/quienesquien/) |
4 | 6 |
|
5 |
| -**Requerimientos** |
6 |
| -Python v3 o superior |
| 7 | +Client for the Quienesquien list service (https://app.q-detect.com/) |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install quienesquien |
| 13 | +``` |
| 14 | + |
| 15 | +## Development & Testing |
| 16 | + |
| 17 | +The project configuration is managed through environment variables. Set them before running tests: |
| 18 | +```bash |
| 19 | +export $(<env.template) |
| 20 | +``` |
| 21 | + |
| 22 | +To run unit tests, use `pytest`. |
| 23 | +```bash |
| 24 | +pytest |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +Before using the client, configure the required environment variables: |
| 30 | +```bash |
| 31 | +export QEQ_USER=your_user |
| 32 | +export QEQ_CLIENT_ID=your_client_id |
| 33 | +export QEQ_SECRET_ID=your_secret_key |
| 34 | +``` |
| 35 | + |
| 36 | +## Example |
| 37 | +```python |
| 38 | +import os |
| 39 | +from quienesquien import Client |
| 40 | +from quienesquien.enums import Gender, SearchList, SearchType |
| 41 | +from quienesquien.exc import ( |
| 42 | + InsufficientBalanceError, |
| 43 | + InvalidPlanError, |
| 44 | + InvalidTokenError, |
| 45 | + PersonNotFoundError, |
| 46 | +) |
| 47 | + |
| 48 | +client = Client( |
| 49 | + os.environ['QEQ_USER'], |
| 50 | + os.environ['QEQ_CLIENT_ID'], |
| 51 | + os.environ['QEQ_SECRET_ID'], |
| 52 | +) |
| 53 | + |
| 54 | +try: |
| 55 | + persons = await client.search( |
| 56 | + full_name='Andres Manuel Lopez Obrador', |
| 57 | + match_score=85, |
| 58 | + rfc='LOOA531113F15', |
| 59 | + curp='LOOA531113HTCPBN07', |
| 60 | + gender=Gender.masculino, |
| 61 | + birthday=dt.date(1953, 11, 13), |
| 62 | + search_type=SearchType.fisica, |
| 63 | + search_list=(SearchList.PPE, SearchList.ONU), |
| 64 | + ) |
| 65 | +except InsufficientBalanceError: |
| 66 | + print('Saldo insuficiente') |
| 67 | +except InvalidPlanError: |
| 68 | + print('Plan inválido') |
| 69 | +except InvalidTokenError: |
| 70 | + print('Token inválido') |
| 71 | +except PersonNotFoundError: |
| 72 | + persons = [] |
| 73 | +``` |
| 74 | + |
| 75 | +## Search Parameters |
| 76 | +- `full_name` (str): Full name of the person. |
| 77 | +- `match_score` (int): Minimum match percentage (default: 60). |
| 78 | +- `rfc` (str): Mexican RFC. |
| 79 | +- `curp` (str): Mexican CURP. |
| 80 | +- `gender` (Gender): masculino or femenino. |
| 81 | +- `birthday` (datetime.date): Date of birth. |
| 82 | +- `search_type` (SearchType): fisica or moral. |
| 83 | +- `search_list` (tuple[SearchList, ...]): Lists to search. |
| 84 | + If not provided, searches all. |
| 85 | + |
| 86 | +The search follows a hierarchical approach: it first attempts to find a match using the RFC. |
| 87 | +If no match is found, it searches by CURP. Finally, if neither is found, it looks for a match by name. |
| 88 | +You must specify at least one search parameter: full_name, rfc or curp. |
| 89 | + |
| 90 | +## Response Structure |
| 91 | +- `persons` (list): List of matched persons. |
0 commit comments