Skip to content

Commit 6c2deb4

Browse files
feat(lib): add new version 2.0.0 of python
1 parent eb7af6f commit 6c2deb4

33 files changed

Lines changed: 3247 additions & 311 deletions

‎.github/workflows/auto_merge.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
auto-merge:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v7
1414
- uses: ahmadnassri/action-dependabot-auto-merge@v2
1515
with:
1616
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE }}

‎.github/workflows/docs.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: docs
22

33
permissions:
4-
contents: read
4+
contents: write
55

66
on:
77
release:
@@ -11,14 +11,14 @@ jobs:
1111
deploy:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v7
1515
- name: Set up Python 3.13
16-
uses: actions/setup-python@v5
16+
uses: actions/setup-python@v7
1717
with:
1818
python-version: 3.13
1919
- name: Install dependencies
2020
run: make install-test
2121
- name: Install mkdocs
22-
run: pip install -qU mkdocs-material mkdocstrings
22+
run: python -m pip install -r requirements-docs.txt
2323
- name: Deploy Github Page
2424
run: mkdocs gh-deploy --force

‎.github/workflows/openapi.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: update-openapi-client
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '17 12 * * 1'
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
generate:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v7
17+
- uses: actions/setup-python@v7
18+
with:
19+
python-version: '3.13'
20+
- name: Install generator dependencies
21+
run: python -m pip install -r requirements.txt -r requirements-test.txt
22+
- name: Generate the SDK from the current OpenAPI document
23+
run: python scripts/generate_openapi.py
24+
- name: Verify generated client
25+
run: |
26+
make lint
27+
pytest -x
28+
- name: Create update pull request
29+
uses: peter-evans/create-pull-request@v8
30+
with:
31+
branch: codex/update-openapi-client
32+
delete-branch: true
33+
commit-message: 'chore: update generated OpenAPI client'
34+
title: 'chore: update generated OpenAPI client'
35+
body: |
36+
Automated SDK update generated from Facturapi's public OpenAPI
37+
document. CI verifies formatting, typing, and tests before merge.
38+
labels: |
39+
automated
40+
openapi

‎.github/workflows/release.yml‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
name: release
22

3-
permissions:
4-
contents: read
5-
63
on:
74
release:
85
types: [published]
96

107
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v7
12+
- name: Set up Python
13+
uses: actions/setup-python@v7
14+
with:
15+
python-version: '3.13'
16+
- name: Build distributions
17+
run: |
18+
python -m pip install --upgrade build twine
19+
python -c "import os, runpy; version = runpy.run_path('facturapi/version.py')['__version__']; assert os.environ['GITHUB_REF_NAME'] == f'v{version}', 'release tag must match package version'"
20+
python -m build
21+
python -m twine check dist/*
22+
- uses: actions/upload-artifact@v7
23+
with:
24+
name: python-package-distributions
25+
path: dist/
26+
1127
publish-pypi:
28+
needs: build
1229
runs-on: ubuntu-latest
30+
environment:
31+
name: pypi
32+
url: https://pypi.org/p/facturapi
33+
permissions:
34+
id-token: write
1335
steps:
14-
- uses: actions/checkout@master
15-
- name: Set up Python 3.8
16-
uses: actions/setup-python@v2.2.2
36+
- uses: actions/download-artifact@v8
1737
with:
18-
python-version: 3.8
19-
- name: Install dependencies
20-
run: pip install -qU setuptools wheel twine
21-
- name: Generating distribution archives
22-
run: python setup.py sdist bdist_wheel
23-
- name: Publish distribution 📦 to PyPI
38+
name: python-package-distributions
39+
path: dist/
40+
- name: Publish distributions to PyPI
2441
uses: pypa/gh-action-pypi-publish@release/v1
25-
with:
26-
user: __token__
27-
password: ${{ secrets.pypi_password }}

‎.github/workflows/test.yml‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
lint:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v7
1313
- name: Set up Python
14-
uses: actions/setup-python@v5
14+
uses: actions/setup-python@v7
1515
with:
1616
python-version: 3.13
1717
- name: Install dependencies
@@ -23,11 +23,11 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
python-version: ["3.10", "3.11", "3.12", "3.13"]
26+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v7
2929
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v5
30+
uses: actions/setup-python@v7
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333
- name: Install dependencies
@@ -37,10 +37,13 @@ jobs:
3737

3838
coverage:
3939
runs-on: ubuntu-latest
40+
permissions:
41+
contents: read
42+
id-token: write
4043
steps:
41-
- uses: actions/checkout@v4
44+
- uses: actions/checkout@v7
4245
- name: Setup Python
43-
uses: actions/setup-python@v5
46+
uses: actions/setup-python@v7
4447
with:
4548
python-version: 3.13
4649
- name: Install dependencies
@@ -50,8 +53,8 @@ jobs:
5053
- name: Upload coverage to Codecov
5154
uses: codecov/codecov-action@v5
5255
with:
53-
token: ${{ secrets.CODECOV_TOKEN }}
54-
file: ./coverage.xml
56+
use_oidc: true
57+
files: ./coverage.xml
5558
flags: unittests
5659
name: codecov-umbrella
5760
fail_ci_if_error: true

‎MANIFEST.in‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include LICENSE
2+
include README.md
3+
include README.es-MX.md
4+
include requirements-docs.txt
5+
recursive-include docs *.md *.png *.svg
6+
recursive-include examples *.py
7+
recursive-include scripts *.py
8+
recursive-include tests *.py *.yaml

‎Makefile‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ SHELL := bash
22
PATH := ./venv/bin:${PATH}
33
PYTHON = python3.13
44
PROJECT = facturapi
5-
isort = isort $(PROJECT) tests setup.py examples
6-
black = black -S -l 79 --target-version py313 $(PROJECT) tests setup.py examples
5+
isort = isort $(PROJECT) tests scripts setup.py examples
6+
black = black -S -l 79 --target-version py313 $(PROJECT) tests scripts setup.py examples
77

88

99
all: test
@@ -21,15 +21,21 @@ install-test: install
2121
test: clean install-test lint
2222
pytest
2323

24+
generate:
25+
python scripts/generate_openapi.py
26+
27+
generate-check:
28+
python scripts/generate_openapi.py --check
29+
2430
format:
2531
$(isort)
2632
$(black)
2733

2834
lint:
29-
flake8 $(PROJECT) tests setup.py
35+
flake8 $(PROJECT) tests scripts setup.py
3036
$(isort) --check-only
3137
$(black) --check
32-
mypy $(PROJECT) tests
38+
mypy $(PROJECT) tests scripts
3339

3440
clean:
3541
rm -rf `find . -name __pycache__`
@@ -46,9 +52,12 @@ clean:
4652
rm -rf build
4753
rm -rf dist
4854

49-
release: test clean
50-
python setup.py sdist bdist_wheel
51-
twine upload dist/*
55+
build: clean
56+
python -m build
57+
python -m twine check dist/*
58+
59+
release: test build
60+
@echo "Create a GitHub release to publish with PyPI Trusted Publishing."
5261

5362

54-
.PHONY: all install-test test format lint clean release
63+
.PHONY: all install-test test generate generate-check format lint clean build release

‎README.es-MX.md‎

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
FacturAPI – Librería de Python
88
</h1>
99

10-
![test](https://github.com/cuenca-mx/facturapi-python/workflows/test/badge.svg)
11-
[![codecov](https://codecov.io/gh/cuenca-mx/facturapi-python/branch/main/graph/badge.svg?token=U89Q4PR339)](https://codecov.io/gh/cuenca-mx/facturapi-python)
10+
![test](https://github.com/FacturAPI/facturapi-python/actions/workflows/test.yml/badge.svg)
1211
[![PyPI version](https://badge.fury.io/py/facturapi.svg)](https://badge.fury.io/py/facturapi)
1312
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1413

15-
Esta es una librería de Python para https://www.facturapi.io
16-
17-
**⚠️Advertencia: Esta librería NO es oficial y aún sigue en desarrollo. No es un producto final.⚠️**
14+
SDK oficial de Python para https://www.facturapi.io
1815

1916
FacturAPI facilita la creación de facturas válidas para desarrolladores en México (Facturas Electrónicas o CFDI).
2017

@@ -30,39 +27,28 @@ pip install facturapi
3027

3128
## 🚀 Primeros pasos
3229

33-
### Autenticación con API Key
30+
### Cliente recomendado
3431
Asegurate de crear una cuenta gratis en [FacturAPI](https://www.facturapi.io) y tener acceso a tus llaves de test y live.
3532

36-
Hay dos formas de configurar tus llaves para usar la librería:
37-
38-
1. **Variable de entorno:** Configura una variable de entorno y la librería usará la llave automáticamente:
39-
40-
```bash
41-
export FACTURAPI_KEY=TU_API_KEY
42-
```
43-
44-
2. **Usando el método `configure`:** Puedes configurar tu llave en el código usando el método `configure`:
45-
46-
```python
47-
from facturapi import configure
48-
49-
configure(api_key='TU_API_KEY')
50-
```
51-
52-
### Crea un Cliente
53-
Después de configurar tu llave, puedes usar la librería para realizar varias acciones en los recursos de FacturAPI, por ejempo crear un Cliente:
33+
El cliente por instancia incluye todos los métodos de la referencia de API:
5434

5535
```python
56-
import facturapi
57-
from facturapi.resources.customers import CustomerRequest, CustomerUpdateRequest
58-
59-
customer = facturapi.Customer.create(data=CustomerRequest(
60-
legal_name='Frida Kahlo',
61-
tax_id='ABCD111111CBA',
62-
email='frida_kahlo@test.com',
63-
))
36+
from facturapi import Facturapi
37+
38+
facturapi = Facturapi("sk_test_...")
39+
customer = facturapi.customers.create({
40+
"legal_name": "Frida Kahlo",
41+
"tax_id": "ABCD111111CBA",
42+
"tax_system": "601",
43+
"email": "frida@example.com",
44+
"address": {"zip": "01234", "country": "MEX"},
45+
})
6446
```
6547

48+
También puedes omitir la llave y usar la variable de entorno
49+
`FACTURAPI_KEY`. La API anterior basada en `facturapi.Customer` y
50+
`facturapi.Invoice` sigue disponible por compatibilidad.
51+
6652
Para más detalles en los datos necesarios para crear un Cliente y otros recursos, revisa la [documentación](http://docs.facturapi.io).
6753

6854
Puedes encontrar más ejemplos de código de cómo crear y usar recursos en el directorio de [examples](./examples/).
@@ -71,7 +57,8 @@ Puedes encontrar más ejemplos de código de cómo crear y usar recursos en el d
7157

7258
Encuentra más información de Facturapi y sus recursos en sus [docs](http://docs.facturapi.io).
7359

74-
O para más detalles técnicos y de la librería, entra a la [documentación](https://cuenca-mx.github.io/facturapi-python/) de `facturapi-python`.
60+
La capa de recursos se genera automáticamente desde el documento OpenAPI de
61+
Facturapi. El workflow semanal propone un pull request cuando la API cambia.
7562

7663
## 💡 Contribuye
7764
### ¿Encontraste un bug?
@@ -84,12 +71,5 @@ No olvides mantener la cobertura del código arriba de 98%, nos encanta tener c
8471
### Contactos:
8572
- **Facturapi:** contacto@facturapi.io
8673

87-
- **Cuenca:** dev@cuenca.com
88-
8974
---
90-
Desarrollado y mantenido con 💙 por [Cuenca](https://cuenca.com/)
91-
<p align="center">
92-
<a href="https://cuenca.com/">
93-
<img alt="Cuenca Logo" src="./docs/images/cuenca-full-logo.svg" width="200" />
94-
</a>
95-
</p>
75+
Desarrollado y mantenido por [Facturapi](https://facturapi.io/).

0 commit comments

Comments
 (0)