flashpi 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flashpi-0.2.3 → flashpi-0.3.0}/CHANGELOG.md +9 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/PKG-INFO +71 -15
- {flashpi-0.2.3 → flashpi-0.3.0}/README.en.md +70 -14
- {flashpi-0.2.3 → flashpi-0.3.0}/README.md +70 -14
- {flashpi-0.2.3 → flashpi-0.3.0}/openapi/openapi.json +1203 -142
- {flashpi-0.2.3 → flashpi-0.3.0}/pyproject.toml +1 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_client.py +11 -2
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_http.py +4 -2
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_version.py +1 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/__init__.py +3 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/events.py +3 -3
- flashpi-0.3.0/src/flashpi/resources/exports.py +149 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/issuers.py +49 -4
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/types/__init__.py +18 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/types/_generated.py +202 -3
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/_context.py +4 -1
- flashpi-0.3.0/tests/examples/readme/en_04.py +13 -0
- flashpi-0.3.0/tests/examples/readme/en_05.py +19 -0
- flashpi-0.2.3/tests/examples/readme/en_04.py → flashpi-0.3.0/tests/examples/readme/en_06.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_05.py → flashpi-0.3.0/tests/examples/readme/en_07.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_06.py → flashpi-0.3.0/tests/examples/readme/en_08.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_07.py → flashpi-0.3.0/tests/examples/readme/en_09.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_08.py → flashpi-0.3.0/tests/examples/readme/en_10.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_09.py → flashpi-0.3.0/tests/examples/readme/en_11.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_10.py → flashpi-0.3.0/tests/examples/readme/en_12.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_11.py → flashpi-0.3.0/tests/examples/readme/en_13.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_12.py → flashpi-0.3.0/tests/examples/readme/en_14.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_13.py → flashpi-0.3.0/tests/examples/readme/en_15.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_14.py → flashpi-0.3.0/tests/examples/readme/en_16.py +1 -1
- flashpi-0.2.3/tests/examples/readme/en_15.py → flashpi-0.3.0/tests/examples/readme/en_17.py +1 -1
- flashpi-0.3.0/tests/examples/readme/es_04.py +13 -0
- flashpi-0.3.0/tests/examples/readme/es_05.py +19 -0
- flashpi-0.2.3/tests/examples/readme/es_04.py → flashpi-0.3.0/tests/examples/readme/es_06.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_05.py → flashpi-0.3.0/tests/examples/readme/es_07.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_06.py → flashpi-0.3.0/tests/examples/readme/es_08.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_07.py → flashpi-0.3.0/tests/examples/readme/es_09.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_08.py → flashpi-0.3.0/tests/examples/readme/es_10.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_09.py → flashpi-0.3.0/tests/examples/readme/es_11.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_10.py → flashpi-0.3.0/tests/examples/readme/es_12.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_11.py → flashpi-0.3.0/tests/examples/readme/es_13.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_12.py → flashpi-0.3.0/tests/examples/readme/es_14.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_13.py → flashpi-0.3.0/tests/examples/readme/es_15.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_14.py → flashpi-0.3.0/tests/examples/readme/es_16.py +1 -1
- flashpi-0.2.3/tests/examples/readme/es_15.py → flashpi-0.3.0/tests/examples/readme/es_17.py +1 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_openapi.py +2 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_operations.py +6 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_resource_types.py +22 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_resources.py +281 -2
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_retries.py +15 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_types.py +91 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_webhooks.py +47 -1
- {flashpi-0.2.3 → flashpi-0.3.0}/.gitignore +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/LICENSE +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/scripts/__init__.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/scripts/installed_check.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/scripts/openapi.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/scripts/package_check.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/scripts/readme.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/__init__.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_errors.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_network.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_pagination.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_resource.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_response.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_validate.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/_webhooks.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/py.typed +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/documents.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/issuer_onboardings.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/status.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/uploads.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/src/flashpi/resources/webhook_endpoints.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/__init__.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/conftest.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/en_01.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/en_02.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/en_03.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/es_01.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/es_02.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/readme/es_03.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/http/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/views/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/views/decorators/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/views/decorators/csrf.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/django/views/decorators/http.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/fastapi/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/fastapi/responses.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/examples/typings/flask/__init__.pyi +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/live/__init__.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/live/test_live.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/support.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_cancellation.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_client.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_deadline.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_errors.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_headers.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_http.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_network.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_package_check.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_pagination.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_readme.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_review_fixes.py +0 -0
- {flashpi-0.2.3 → flashpi-0.3.0}/tests/test_version.py +0 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/flashpi1/flashpi-python/compare/v0.2.3...v0.3.0) (2026-12-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* bulk exports and certificate deletion ([376d4a1](https://github.com/flashpi1/flashpi-python/commit/376d4a15d0d03d32cb2df83ba5c16b902f6b9a93))
|
|
9
|
+
* **certificates:** delete a certificate ([ba0184c](https://github.com/flashpi1/flashpi-python/commit/ba0184ce7cc75451da426a039049909ccdf44b02))
|
|
10
|
+
* **exports:** add the bulk exports of an issuer's documents ([0767420](https://github.com/flashpi1/flashpi-python/commit/0767420155952224766db00649a37247cc04e183))
|
|
11
|
+
|
|
3
12
|
## [0.2.3](https://github.com/flashpi1/flashpi-python/compare/v0.2.2...v0.2.3) (2026-12-01)
|
|
4
13
|
|
|
5
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: flashpi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: The official Python SDK for Flashpi, the electronic invoicing API for Ecuador's SRI.
|
|
5
5
|
Project-URL: Homepage, https://flashpi.com.ec
|
|
6
6
|
Project-URL: Documentation, https://flashpi.com.ec/docs/sdks/
|
|
@@ -36,8 +36,9 @@ Ecuador, para Python.
|
|
|
36
36
|
|
|
37
37
|
[English](https://github.com/flashpi1/flashpi-python/blob/main/README.en.md)
|
|
38
38
|
|
|
39
|
-
- Las
|
|
40
|
-
emisores con establecimientos, puntos de emisión y certificados .p12,
|
|
39
|
+
- Las 50 operaciones de la API: los seis comprobantes, documentos (XML, RIDE en PDF, correo),
|
|
40
|
+
exportaciones en ZIP, emisores con establecimientos, puntos de emisión y certificados .p12,
|
|
41
|
+
webhooks y eventos.
|
|
41
42
|
- Un cliente síncrono (`Flashpi`) y uno asíncrono (`AsyncFlashpi`, asyncio) con los mismos
|
|
42
43
|
métodos.
|
|
43
44
|
- Tipos (`TypedDict`) generados del documento OpenAPI de la API: tu editor y tu verificador de
|
|
@@ -171,6 +172,51 @@ Path(f"{invoice['accessKey']}.pdf").write_bytes(pdf)
|
|
|
171
172
|
flashpi.documents.send_email(invoice["id"]) # reenvía RIDE y XML al correo del comprador
|
|
172
173
|
```
|
|
173
174
|
|
|
175
|
+
## Exportaciones
|
|
176
|
+
|
|
177
|
+
Una exportación reúne en un ZIP el XML autorizado y el RIDE de cada comprobante autorizado de un
|
|
178
|
+
emisor emitido entre dos fechas (fechas de Ecuador, ambas incluidas, hasta un año), más un
|
|
179
|
+
`index.csv` con todos los comprobantes de esas fechas, en cualquier estado. Es gratis: no usa
|
|
180
|
+
créditos. Exporta los comprobantes del ambiente de tu clave (pruebas o producción).
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
export = flashpi.exports.create(
|
|
184
|
+
{"issuerId": "<id de tu emisor>", "issueDateFrom": "2026-11-01", "issueDateTo": "2026-11-30"}
|
|
185
|
+
)
|
|
186
|
+
print(export["status"]) # "queued"; luego "processing" y al final "completed" o "failed"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Flashpi la prepara en segundo plano. Para saber cuándo termina, escucha los webhooks
|
|
190
|
+
`export.completed` y `export.failed` (su `data` es la exportación), o consúltala con
|
|
191
|
+
`flashpi.exports.get(export["id"])`. Un emisor tiene una sola exportación en cola o en
|
|
192
|
+
preparación por ambiente (`ConflictError` `export_in_progress`), y
|
|
193
|
+
`flashpi.exports.list({"issuerId": ..., "status": "completed"})` lista las exportaciones, de la
|
|
194
|
+
más reciente a la más antigua.
|
|
195
|
+
|
|
196
|
+
Cuando está `completed`, `download_link()` te da el enlace del ZIP (`url`, `expiresAt` y
|
|
197
|
+
`filename`); el SDK no descarga el archivo por ti. Descárgalo con una petición HTTP normal,
|
|
198
|
+
**sin** el encabezado `Authorization`: el enlace lleva su propia firma y va directo al
|
|
199
|
+
almacenamiento, que nunca debe recibir tu clave de API.
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from pathlib import Path
|
|
203
|
+
|
|
204
|
+
import httpx
|
|
205
|
+
|
|
206
|
+
link = flashpi.exports.download_link(export["id"])
|
|
207
|
+
with httpx.stream("GET", link["url"]) as response: # sin Authorization ni tu clave
|
|
208
|
+
response.raise_for_status()
|
|
209
|
+
with Path(link["filename"]).open("wb") as file:
|
|
210
|
+
for chunk in response.iter_bytes():
|
|
211
|
+
file.write(chunk)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
El enlace funciona 5 minutos (una descarga que ya empezó termina): pide uno nuevo cada vez que lo
|
|
215
|
+
necesites, mientras se guarde el ZIP, 7 días después de prepararse. Antes de que la exportación
|
|
216
|
+
esté lista, o si falló, `download_link()` lanza un `ConflictError` `export_not_ready`; cuando el
|
|
217
|
+
ZIP ya se eliminó, un `APIError` 410 `export_expired`. Más en
|
|
218
|
+
[Exportar comprobantes](https://flashpi.com.ec/docs/exports/).
|
|
219
|
+
|
|
174
220
|
## Listas y paginación
|
|
175
221
|
|
|
176
222
|
Una lista devuelve una página. Con `for` recorres todas las páginas, que se piden a medida que
|
|
@@ -210,18 +256,19 @@ except APIError as error:
|
|
|
210
256
|
raise
|
|
211
257
|
```
|
|
212
258
|
|
|
213
|
-
| Clase | Estado | Ejemplos de `code`
|
|
214
|
-
| -------------------------- | ------ |
|
|
215
|
-
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key`
|
|
216
|
-
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key`
|
|
217
|
-
| `APIError` | 402 | `insufficient_credits`
|
|
218
|
-
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen`
|
|
219
|
-
| `NotFoundError` | 404 | `not_found`
|
|
220
|
-
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
259
|
+
| Clase | Estado | Ejemplos de `code` |
|
|
260
|
+
| -------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
|
|
261
|
+
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
|
|
262
|
+
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
|
|
263
|
+
| `APIError` | 402 | `insufficient_credits` |
|
|
264
|
+
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen` |
|
|
265
|
+
| `NotFoundError` | 404 | `not_found` |
|
|
266
|
+
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`, `export_in_progress` |
|
|
267
|
+
| `APIError` | 410 | `export_expired` |
|
|
268
|
+
| `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
|
|
269
|
+
| `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
|
|
270
|
+
| `InternalServerError` | 5xx | `internal_error` |
|
|
271
|
+
| `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
|
|
225
272
|
|
|
226
273
|
Todas derivan de `FlashpiError`. Algunos errores traen datos extra en `error.problem`, por
|
|
227
274
|
ejemplo `documentId`, `limit`, `resetsAt` o `rideStatus`. Para recibir los mensajes en español:
|
|
@@ -428,6 +475,15 @@ agrega el certificado. En cambio,
|
|
|
428
475
|
`flashpi.issuers.certificates.upload(issuer_id, {"file": ..., "password": ...})` sube un
|
|
429
476
|
certificado solo para el modo de la clave que usas (pruebas o producción).
|
|
430
477
|
|
|
478
|
+
Para **eliminar un certificado** que Flashpi ya no debe guardar (una firma que reemplazaste o una
|
|
479
|
+
que subiste por error), llama a `flashpi.issuers.certificates.delete(issuer_id, certificate_id)`.
|
|
480
|
+
Flashpi borra el .p12 y su contraseña de inmediato y devuelve el certificado con `status`
|
|
481
|
+
`deleted` y `deletedAt`; sus datos públicos quedan, para que los comprobantes que firmó sigan
|
|
482
|
+
siendo explicables. El emisor no firma hasta que se acepte otro certificado: si reemplazas una
|
|
483
|
+
firma, sube primero la nueva. Mientras se firman comprobantes con él, o mientras sigue en
|
|
484
|
+
`processing`, lanza un `ConflictError` `certificate_in_use`: intenta de nuevo en unos minutos.
|
|
485
|
+
Más en [Eliminar un certificado](https://flashpi.com.ec/docs/certificates/#eliminar-un-certificado).
|
|
486
|
+
|
|
431
487
|
## Opciones
|
|
432
488
|
|
|
433
489
|
```python
|
|
@@ -5,8 +5,9 @@ Ecuador's SRI.
|
|
|
5
5
|
|
|
6
6
|
[Español](https://github.com/flashpi1/flashpi-python/blob/main/README.md)
|
|
7
7
|
|
|
8
|
-
- The
|
|
9
|
-
issuers with establishments, emission points and .p12 certificates, webhooks and
|
|
8
|
+
- The 50 operations of the API: the six document types, documents (XML, RIDE PDF, email), ZIP
|
|
9
|
+
exports, issuers with establishments, emission points and .p12 certificates, webhooks and
|
|
10
|
+
events.
|
|
10
11
|
- A sync client (`Flashpi`) and an async one (`AsyncFlashpi`, asyncio) with the same methods.
|
|
11
12
|
- Types (`TypedDict`) generated from the API's OpenAPI document, so your editor and type checker
|
|
12
13
|
know every field.
|
|
@@ -138,6 +139,51 @@ Path(f"{invoice['accessKey']}.pdf").write_bytes(pdf)
|
|
|
138
139
|
flashpi.documents.send_email(invoice["id"]) # emails the RIDE and XML to the buyer again
|
|
139
140
|
```
|
|
140
141
|
|
|
142
|
+
## Exports
|
|
143
|
+
|
|
144
|
+
An export puts in one ZIP the authorized XML and the RIDE of each authorized document of an
|
|
145
|
+
issuer issued between two dates (Ecuador dates, both inclusive, up to one year), plus an
|
|
146
|
+
`index.csv` of every document of those dates, in any status. It is free: it uses no credits. It
|
|
147
|
+
exports the documents of your key's mode (test or live).
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
export = flashpi.exports.create(
|
|
151
|
+
{"issuerId": "<your issuer's id>", "issueDateFrom": "2026-11-01", "issueDateTo": "2026-11-30"}
|
|
152
|
+
)
|
|
153
|
+
print(export["status"]) # "queued"; then "processing", and "completed" or "failed" at the end
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Flashpi builds it in the background. To know when it is done, listen to the `export.completed`
|
|
157
|
+
and `export.failed` webhooks (their `data` is the export), or read it with
|
|
158
|
+
`flashpi.exports.get(export["id"])`. An issuer has one export queued or being built per mode at
|
|
159
|
+
most (`ConflictError` `export_in_progress`), and
|
|
160
|
+
`flashpi.exports.list({"issuerId": ..., "status": "completed"})` lists the exports, newest
|
|
161
|
+
first.
|
|
162
|
+
|
|
163
|
+
Once it is `completed`, `download_link()` gives you the ZIP's link (`url`, `expiresAt` and
|
|
164
|
+
`filename`); the SDK does not download the file for you. Fetch it with a plain HTTP request,
|
|
165
|
+
**without** the `Authorization` header: the link carries its own signature and goes straight to
|
|
166
|
+
storage, which must never get your API key.
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from pathlib import Path
|
|
170
|
+
|
|
171
|
+
import httpx
|
|
172
|
+
|
|
173
|
+
link = flashpi.exports.download_link(export["id"])
|
|
174
|
+
with httpx.stream("GET", link["url"]) as response: # no Authorization, no API key
|
|
175
|
+
response.raise_for_status()
|
|
176
|
+
with Path(link["filename"]).open("wb") as file:
|
|
177
|
+
for chunk in response.iter_bytes():
|
|
178
|
+
file.write(chunk)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The link works for 5 minutes (a download that started finishes): ask for a new one whenever you
|
|
182
|
+
need it, while the ZIP is kept, 7 days after it was built. Before the export is ready, or when it
|
|
183
|
+
failed, `download_link()` raises a `ConflictError` `export_not_ready`; once the ZIP was deleted,
|
|
184
|
+
an `APIError` 410 `export_expired`. More in
|
|
185
|
+
[Export documents](https://flashpi.com.ec/docs/en/exports/).
|
|
186
|
+
|
|
141
187
|
## Lists and pagination
|
|
142
188
|
|
|
143
189
|
A list call returns a page. A `for` loop walks every page, fetching them as you go:
|
|
@@ -176,18 +222,19 @@ except APIError as error:
|
|
|
176
222
|
raise
|
|
177
223
|
```
|
|
178
224
|
|
|
179
|
-
| Class | Status | Example `code`s
|
|
180
|
-
| -------------------------- | ------ |
|
|
181
|
-
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key`
|
|
182
|
-
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key`
|
|
183
|
-
| `APIError` | 402 | `insufficient_credits`
|
|
184
|
-
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen`
|
|
185
|
-
| `NotFoundError` | 404 | `not_found`
|
|
186
|
-
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
225
|
+
| Class | Status | Example `code`s |
|
|
226
|
+
| -------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
|
|
227
|
+
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
|
|
228
|
+
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
|
|
229
|
+
| `APIError` | 402 | `insufficient_credits` |
|
|
230
|
+
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen` |
|
|
231
|
+
| `NotFoundError` | 404 | `not_found` |
|
|
232
|
+
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`, `export_in_progress` |
|
|
233
|
+
| `APIError` | 410 | `export_expired` |
|
|
234
|
+
| `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
|
|
235
|
+
| `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
|
|
236
|
+
| `InternalServerError` | 5xx | `internal_error` |
|
|
237
|
+
| `APIConnectionError` | — | no answer (network); `APITimeoutError` when it timed out |
|
|
191
238
|
|
|
192
239
|
All of them derive from `FlashpiError`. Some errors carry extra members in `error.problem`, such
|
|
193
240
|
as `documentId`, `limit`, `resetsAt` or `rideStatus`. For Spanish messages:
|
|
@@ -392,6 +439,15 @@ new .p12: Flashpi recognizes the RUC (`existingIssuer`) and `complete()` with no
|
|
|
392
439
|
certificate. `flashpi.issuers.certificates.upload(issuer_id, {"file": ..., "password": ...})`,
|
|
393
440
|
instead, uploads a certificate for the mode of the key you use only (test or live).
|
|
394
441
|
|
|
442
|
+
To **delete a certificate** Flashpi should no longer keep (a signature you replaced or one you
|
|
443
|
+
uploaded by mistake), call `flashpi.issuers.certificates.delete(issuer_id, certificate_id)`.
|
|
444
|
+
Flashpi erases the .p12 and its password at once and returns the certificate with `status`
|
|
445
|
+
`deleted` and `deletedAt`; its public data stays, so the documents it signed stay explainable.
|
|
446
|
+
The issuer cannot sign until another certificate is accepted: when replacing a signature, upload
|
|
447
|
+
the new one first. While documents are being signed with it, or while it is still `processing`,
|
|
448
|
+
it raises a `ConflictError` `certificate_in_use`: try again in a few minutes. More in
|
|
449
|
+
[Delete a certificate](https://flashpi.com.ec/docs/en/certificates/#delete-a-certificate).
|
|
450
|
+
|
|
395
451
|
## Options
|
|
396
452
|
|
|
397
453
|
```python
|
|
@@ -5,8 +5,9 @@ Ecuador, para Python.
|
|
|
5
5
|
|
|
6
6
|
[English](https://github.com/flashpi1/flashpi-python/blob/main/README.en.md)
|
|
7
7
|
|
|
8
|
-
- Las
|
|
9
|
-
emisores con establecimientos, puntos de emisión y certificados .p12,
|
|
8
|
+
- Las 50 operaciones de la API: los seis comprobantes, documentos (XML, RIDE en PDF, correo),
|
|
9
|
+
exportaciones en ZIP, emisores con establecimientos, puntos de emisión y certificados .p12,
|
|
10
|
+
webhooks y eventos.
|
|
10
11
|
- Un cliente síncrono (`Flashpi`) y uno asíncrono (`AsyncFlashpi`, asyncio) con los mismos
|
|
11
12
|
métodos.
|
|
12
13
|
- Tipos (`TypedDict`) generados del documento OpenAPI de la API: tu editor y tu verificador de
|
|
@@ -140,6 +141,51 @@ Path(f"{invoice['accessKey']}.pdf").write_bytes(pdf)
|
|
|
140
141
|
flashpi.documents.send_email(invoice["id"]) # reenvía RIDE y XML al correo del comprador
|
|
141
142
|
```
|
|
142
143
|
|
|
144
|
+
## Exportaciones
|
|
145
|
+
|
|
146
|
+
Una exportación reúne en un ZIP el XML autorizado y el RIDE de cada comprobante autorizado de un
|
|
147
|
+
emisor emitido entre dos fechas (fechas de Ecuador, ambas incluidas, hasta un año), más un
|
|
148
|
+
`index.csv` con todos los comprobantes de esas fechas, en cualquier estado. Es gratis: no usa
|
|
149
|
+
créditos. Exporta los comprobantes del ambiente de tu clave (pruebas o producción).
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
export = flashpi.exports.create(
|
|
153
|
+
{"issuerId": "<id de tu emisor>", "issueDateFrom": "2026-11-01", "issueDateTo": "2026-11-30"}
|
|
154
|
+
)
|
|
155
|
+
print(export["status"]) # "queued"; luego "processing" y al final "completed" o "failed"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Flashpi la prepara en segundo plano. Para saber cuándo termina, escucha los webhooks
|
|
159
|
+
`export.completed` y `export.failed` (su `data` es la exportación), o consúltala con
|
|
160
|
+
`flashpi.exports.get(export["id"])`. Un emisor tiene una sola exportación en cola o en
|
|
161
|
+
preparación por ambiente (`ConflictError` `export_in_progress`), y
|
|
162
|
+
`flashpi.exports.list({"issuerId": ..., "status": "completed"})` lista las exportaciones, de la
|
|
163
|
+
más reciente a la más antigua.
|
|
164
|
+
|
|
165
|
+
Cuando está `completed`, `download_link()` te da el enlace del ZIP (`url`, `expiresAt` y
|
|
166
|
+
`filename`); el SDK no descarga el archivo por ti. Descárgalo con una petición HTTP normal,
|
|
167
|
+
**sin** el encabezado `Authorization`: el enlace lleva su propia firma y va directo al
|
|
168
|
+
almacenamiento, que nunca debe recibir tu clave de API.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from pathlib import Path
|
|
172
|
+
|
|
173
|
+
import httpx
|
|
174
|
+
|
|
175
|
+
link = flashpi.exports.download_link(export["id"])
|
|
176
|
+
with httpx.stream("GET", link["url"]) as response: # sin Authorization ni tu clave
|
|
177
|
+
response.raise_for_status()
|
|
178
|
+
with Path(link["filename"]).open("wb") as file:
|
|
179
|
+
for chunk in response.iter_bytes():
|
|
180
|
+
file.write(chunk)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
El enlace funciona 5 minutos (una descarga que ya empezó termina): pide uno nuevo cada vez que lo
|
|
184
|
+
necesites, mientras se guarde el ZIP, 7 días después de prepararse. Antes de que la exportación
|
|
185
|
+
esté lista, o si falló, `download_link()` lanza un `ConflictError` `export_not_ready`; cuando el
|
|
186
|
+
ZIP ya se eliminó, un `APIError` 410 `export_expired`. Más en
|
|
187
|
+
[Exportar comprobantes](https://flashpi.com.ec/docs/exports/).
|
|
188
|
+
|
|
143
189
|
## Listas y paginación
|
|
144
190
|
|
|
145
191
|
Una lista devuelve una página. Con `for` recorres todas las páginas, que se piden a medida que
|
|
@@ -179,18 +225,19 @@ except APIError as error:
|
|
|
179
225
|
raise
|
|
180
226
|
```
|
|
181
227
|
|
|
182
|
-
| Clase | Estado | Ejemplos de `code`
|
|
183
|
-
| -------------------------- | ------ |
|
|
184
|
-
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key`
|
|
185
|
-
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key`
|
|
186
|
-
| `APIError` | 402 | `insufficient_credits`
|
|
187
|
-
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen`
|
|
188
|
-
| `NotFoundError` | 404 | `not_found`
|
|
189
|
-
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`
|
|
190
|
-
| `
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
228
|
+
| Clase | Estado | Ejemplos de `code` |
|
|
229
|
+
| -------------------------- | ------ | ------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
|
|
231
|
+
| `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
|
|
232
|
+
| `APIError` | 402 | `insufficient_credits` |
|
|
233
|
+
| `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required`, `credits_frozen` |
|
|
234
|
+
| `NotFoundError` | 404 | `not_found` |
|
|
235
|
+
| `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached`, `export_in_progress` |
|
|
236
|
+
| `APIError` | 410 | `export_expired` |
|
|
237
|
+
| `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
|
|
238
|
+
| `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
|
|
239
|
+
| `InternalServerError` | 5xx | `internal_error` |
|
|
240
|
+
| `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
|
|
194
241
|
|
|
195
242
|
Todas derivan de `FlashpiError`. Algunos errores traen datos extra en `error.problem`, por
|
|
196
243
|
ejemplo `documentId`, `limit`, `resetsAt` o `rideStatus`. Para recibir los mensajes en español:
|
|
@@ -397,6 +444,15 @@ agrega el certificado. En cambio,
|
|
|
397
444
|
`flashpi.issuers.certificates.upload(issuer_id, {"file": ..., "password": ...})` sube un
|
|
398
445
|
certificado solo para el modo de la clave que usas (pruebas o producción).
|
|
399
446
|
|
|
447
|
+
Para **eliminar un certificado** que Flashpi ya no debe guardar (una firma que reemplazaste o una
|
|
448
|
+
que subiste por error), llama a `flashpi.issuers.certificates.delete(issuer_id, certificate_id)`.
|
|
449
|
+
Flashpi borra el .p12 y su contraseña de inmediato y devuelve el certificado con `status`
|
|
450
|
+
`deleted` y `deletedAt`; sus datos públicos quedan, para que los comprobantes que firmó sigan
|
|
451
|
+
siendo explicables. El emisor no firma hasta que se acepte otro certificado: si reemplazas una
|
|
452
|
+
firma, sube primero la nueva. Mientras se firman comprobantes con él, o mientras sigue en
|
|
453
|
+
`processing`, lanza un `ConflictError` `certificate_in_use`: intenta de nuevo en unos minutos.
|
|
454
|
+
Más en [Eliminar un certificado](https://flashpi.com.ec/docs/certificates/#eliminar-un-certificado).
|
|
455
|
+
|
|
400
456
|
## Opciones
|
|
401
457
|
|
|
402
458
|
```python
|