Skip to content

Commit 23dc02d

Browse files
authored
Merge pull request #9 from cuenca-mx/feature/new-api-integration
Feature/new api integration
2 parents 695910c + 88a371f commit 23dc02d

33 files changed

+1853
-419
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-pypi:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python 3.13
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.13
16+
- name: Install dependencies
17+
run: pip install -qU setuptools wheel twine
18+
- name: Generating distribution archives
19+
run: python setup.py sdist bdist_wheel
20+
- name: Publish distribution 📦 to PyPI
21+
uses: pypa/gh-action-pypi-publish@release/v1
22+
with:
23+
user: __token__
24+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: test
2+
3+
on: push
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- name: Set up Python
11+
uses: actions/setup-python@v5
12+
with:
13+
python-version: 3.13
14+
- name: Install dependencies
15+
run: make install-test
16+
- name: Lint
17+
run: make lint
18+
19+
pytest:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
python-version: ['3.10', '3.11', '3.12', '3.13']
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install dependencies
31+
run: make install-test
32+
- name: Run tests
33+
run: |
34+
export $(<env.template)
35+
pytest
36+
37+
coverage:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- name: Setup Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: 3.13
45+
- name: Install dependencies
46+
run: make install-test
47+
- name: Generate coverage report
48+
run: |
49+
export $(<env.template)
50+
pytest --cov-report=xml
51+
- name: Upload coverage to Codecov
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
file: ./coverage.xml
56+
flags: unittests
57+
name: codecov-umbrella
58+
fail_ci_if_error: true

Makefile

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
11
SHELL := bash
22
PATH := ./venv/bin:${PATH}
3-
PYTHON=python3.7
3+
PYTHON = python3.13
4+
PROJECT = quienesquien
5+
isort = isort $(PROJECT) tests setup.py
6+
black = black -S -l 79 --target-version py313 $(PROJECT) tests setup.py
47

58

69
all: test
710

8-
install-dev:
9-
pip install -q -e .[dev]
10-
1111
venv:
12-
$(PYTHON) -m venv --prompt quienesquien venv
13-
source venv/bin/activate
14-
pip install --quiet --upgrade pip
12+
$(PYTHON) -m venv --prompt $(PROJECT) venv
13+
pip install -qU pip
14+
15+
install:
16+
pip install -qU -r requirements.txt
1517

16-
test: clean install-dev lint
17-
python setup.py test
18+
install-test: install
19+
pip install -qU -r requirements-test.txt
1820

19-
coverage: clean install-dev lint
20-
coverage run --source=quienesquien setup.py test
21-
coverage report -m
21+
test: clean install-test lint
22+
pytest
23+
24+
format:
25+
$(isort)
26+
$(black)
2227

2328
lint:
24-
pycodestyle setup.py quienesquien/
29+
flake8 $(PROJECT) tests setup.py
30+
$(isort) --check-only
31+
$(black) --check
32+
mypy $(PROJECT) tests
2533

2634
clean:
27-
find . -name '*.pyc' -exec rm -f {} +
28-
find . -name '*.pyo' -exec rm -f {} +
29-
find . -name '*~' -exec rm -f {} +
30-
rm -rf build dist quienesquien.egg-info
31-
32-
.PHONY: all coverage lint install-dev release test clean
35+
rm -rf `find . -name __pycache__`
36+
rm -f `find . -type f -name '*.py[co]' `
37+
rm -f `find . -type f -name '*~' `
38+
rm -f `find . -type f -name '.*~' `
39+
rm -rf .cache
40+
rm -rf .pytest_cache
41+
rm -rf .mypy_cache
42+
rm -rf htmlcov
43+
rm -rf *.egg-info
44+
rm -f .coverage
45+
rm -f .coverage.*
46+
rm -rf build
47+
rm -rf dist
48+
49+
release: test clean
50+
python setup.py sdist bdist_wheel
51+
twine upload dist/*
52+
53+
54+
.PHONY: all install-test test format lint clean release

README.md

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,91 @@
1-
# quienesquien-python
1+
# quienesquien
22

3-
Cliente para el servicio de listas de Quienesquien
3+
[![test](https://github.com/cuenca-mx/quienesquien-python/workflows/test/badge.svg)](https://github.com/cuenca-mx/quienesquien-python/actions?query=workflow%3Atest)
4+
[![codecov](https://codecov.io/gh/cuenca-mx/quienesquien-python/branch/master/graph/badge.svg)](https://codecov.io/gh/cuenca-mx/quienesquien-python)
5+
[![PyPI](https://img.shields.io/pypi/v/quienesquien.svg)](https://pypi.org/project/quienesquien/)
46

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.

env.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
QEQ_CLIENT_ID=123456-1234-1234
3+
QEQ_SECRET_ID=notsecurepassword

quienesquien/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
name = "quienesquien"
1+
__all__ = ['__version__', 'Client', 'Person']
2+
3+
from .client import Client
4+
from .person import Person
5+
from .version import __version__

0 commit comments

Comments
 (0)