flashpi 0.2.1__tar.gz → 0.2.3__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.
Files changed (99) hide show
  1. {flashpi-0.2.1 → flashpi-0.2.3}/CHANGELOG.md +16 -0
  2. {flashpi-0.2.1 → flashpi-0.2.3}/PKG-INFO +19 -13
  3. {flashpi-0.2.1 → flashpi-0.2.3}/README.en.md +18 -12
  4. {flashpi-0.2.1 → flashpi-0.2.3}/README.md +18 -12
  5. {flashpi-0.2.1 → flashpi-0.2.3}/openapi/openapi.json +100 -6
  6. {flashpi-0.2.1 → flashpi-0.2.3}/pyproject.toml +1 -1
  7. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_version.py +1 -1
  8. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/issuer_onboardings.py +5 -0
  9. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/status.py +9 -5
  10. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/types/__init__.py +4 -0
  11. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/types/_generated.py +59 -5
  12. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_02.py +2 -1
  13. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_02.py +2 -1
  14. {flashpi-0.2.1 → flashpi-0.2.3}/tests/live/test_live.py +11 -3
  15. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_resources.py +56 -3
  16. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_retries.py +10 -0
  17. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_types.py +72 -1
  18. {flashpi-0.2.1 → flashpi-0.2.3}/.gitignore +0 -0
  19. {flashpi-0.2.1 → flashpi-0.2.3}/LICENSE +0 -0
  20. {flashpi-0.2.1 → flashpi-0.2.3}/scripts/__init__.py +0 -0
  21. {flashpi-0.2.1 → flashpi-0.2.3}/scripts/installed_check.py +0 -0
  22. {flashpi-0.2.1 → flashpi-0.2.3}/scripts/openapi.py +0 -0
  23. {flashpi-0.2.1 → flashpi-0.2.3}/scripts/package_check.py +0 -0
  24. {flashpi-0.2.1 → flashpi-0.2.3}/scripts/readme.py +0 -0
  25. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/__init__.py +0 -0
  26. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_client.py +0 -0
  27. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_errors.py +0 -0
  28. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_http.py +0 -0
  29. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_network.py +0 -0
  30. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_pagination.py +0 -0
  31. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_resource.py +0 -0
  32. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_response.py +0 -0
  33. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_validate.py +0 -0
  34. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/_webhooks.py +0 -0
  35. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/py.typed +0 -0
  36. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/__init__.py +0 -0
  37. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/documents.py +0 -0
  38. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/events.py +0 -0
  39. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/issuers.py +0 -0
  40. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/uploads.py +0 -0
  41. {flashpi-0.2.1 → flashpi-0.2.3}/src/flashpi/resources/webhook_endpoints.py +0 -0
  42. {flashpi-0.2.1 → flashpi-0.2.3}/tests/__init__.py +0 -0
  43. {flashpi-0.2.1 → flashpi-0.2.3}/tests/conftest.py +0 -0
  44. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/_context.py +0 -0
  45. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_01.py +0 -0
  46. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_03.py +0 -0
  47. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_04.py +0 -0
  48. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_05.py +0 -0
  49. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_06.py +0 -0
  50. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_07.py +0 -0
  51. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_08.py +0 -0
  52. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_09.py +0 -0
  53. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_10.py +0 -0
  54. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_11.py +0 -0
  55. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_12.py +0 -0
  56. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_13.py +0 -0
  57. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_14.py +0 -0
  58. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/en_15.py +0 -0
  59. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_01.py +0 -0
  60. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_03.py +0 -0
  61. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_04.py +0 -0
  62. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_05.py +0 -0
  63. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_06.py +0 -0
  64. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_07.py +0 -0
  65. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_08.py +0 -0
  66. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_09.py +0 -0
  67. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_10.py +0 -0
  68. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_11.py +0 -0
  69. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_12.py +0 -0
  70. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_13.py +0 -0
  71. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_14.py +0 -0
  72. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/readme/es_15.py +0 -0
  73. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/__init__.pyi +0 -0
  74. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/http/__init__.pyi +0 -0
  75. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/views/__init__.pyi +0 -0
  76. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/views/decorators/__init__.pyi +0 -0
  77. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/views/decorators/csrf.pyi +0 -0
  78. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/django/views/decorators/http.pyi +0 -0
  79. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/fastapi/__init__.pyi +0 -0
  80. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/fastapi/responses.pyi +0 -0
  81. {flashpi-0.2.1 → flashpi-0.2.3}/tests/examples/typings/flask/__init__.pyi +0 -0
  82. {flashpi-0.2.1 → flashpi-0.2.3}/tests/live/__init__.py +0 -0
  83. {flashpi-0.2.1 → flashpi-0.2.3}/tests/support.py +0 -0
  84. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_cancellation.py +0 -0
  85. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_client.py +0 -0
  86. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_deadline.py +0 -0
  87. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_errors.py +0 -0
  88. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_headers.py +0 -0
  89. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_http.py +0 -0
  90. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_network.py +0 -0
  91. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_openapi.py +0 -0
  92. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_operations.py +0 -0
  93. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_package_check.py +0 -0
  94. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_pagination.py +0 -0
  95. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_readme.py +0 -0
  96. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_resource_types.py +0 -0
  97. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_review_fixes.py +0 -0
  98. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_version.py +0 -0
  99. {flashpi-0.2.1 → flashpi-0.2.3}/tests/test_webhooks.py +0 -0
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3](https://github.com/flashpi1/flashpi-python/compare/v0.2.2...v0.2.3) (2026-12-01)
4
+
5
+
6
+ ### Bug fixes
7
+
8
+ * **types:** add the billing error codes insufficient_credits and credits_frozen ([ca2209a](https://github.com/flashpi1/flashpi-python/commit/ca2209aebf5bac916fdd797f50c7a8e321496068))
9
+ * **types:** add the billing error codes insufficient_credits and credits_frozen ([137f3d8](https://github.com/flashpi1/flashpi-python/commit/137f3d85117234771ef1583bcd41e3a7e76a285f))
10
+
11
+ ## [0.2.2](https://github.com/flashpi1/flashpi-python/compare/v0.2.1...v0.2.2) (2026-12-01)
12
+
13
+
14
+ ### Bug fixes
15
+
16
+ * **types:** export SriStatus and SriEnvironmentStatus from flashpi.types ([18824ce](https://github.com/flashpi1/flashpi-python/commit/18824cea08c1683d4270bbb7d45c61790a9daf34))
17
+ * **types:** sync the API contract of 2026-12-01 ([44e373f](https://github.com/flashpi1/flashpi-python/commit/44e373f9107f41cf66e4527281db56aecf963c1d))
18
+
3
19
  ## [0.2.1](https://github.com/flashpi1/flashpi-python/compare/v0.2.0...v0.2.1) (2026-11-25)
4
20
 
5
21
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: flashpi
3
- Version: 0.2.1
3
+ Version: 0.2.3
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/
@@ -127,7 +127,8 @@ from flashpi import AsyncFlashpi
127
127
  async def main() -> None:
128
128
  async with AsyncFlashpi() as flashpi:
129
129
  status = await flashpi.status.get()
130
- print(status["status"])
130
+ # "operational", y el SRI de producción: operational, degraded, outage o unknown
131
+ print(status["status"], status["sri"]["production"]["status"])
131
132
 
132
133
  async for document in flashpi.documents.list({"status": "authorized"}):
133
134
  print(document["accessKey"])
@@ -209,17 +210,18 @@ except APIError as error:
209
210
  raise
210
211
  ```
211
212
 
212
- | Clase | Estado | Ejemplos de `code` |
213
- | -------------------------- | ------ | --------------------------------------------------------------------------------- |
214
- | `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
215
- | `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
216
- | `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required` |
217
- | `NotFoundError` | 404 | `not_found` |
218
- | `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached` |
219
- | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
220
- | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
221
- | `InternalServerError` | 5xx | `internal_error` |
222
- | `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
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
+ | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
222
+ | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
223
+ | `InternalServerError` | 5xx | `internal_error` |
224
+ | `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
223
225
 
224
226
  Todas derivan de `FlashpiError`. Algunos errores traen datos extra en `error.problem`, por
225
227
  ejemplo `documentId`, `limit`, `resetsAt` o `rideStatus`. Para recibir los mensajes en español:
@@ -266,6 +268,10 @@ Una llamada de `AsyncFlashpi` cuya tarea se cancela lanza `asyncio.CancelledErro
266
268
  Los límites diarios (como la cuota del emisor demo) no se reintentan: se lanzan como
267
269
  `RateLimitError` con `retry_after` en segundos.
268
270
 
271
+ Tampoco se reintentan un 402 `insufficient_credits` (la cuenta no tiene créditos para un
272
+ documento live; los documentos de prueba siguen gratis) ni un 403 `credits_frozen` (los créditos de
273
+ la cuenta están retenidos mientras Flashpi revisa un pago; escribe a soporte@flashpi.com.ec).
274
+
269
275
  ## Webhooks
270
276
 
271
277
  Verifica cada webhook con el cuerpo **tal cual llegó** (sin parsear) y el secreto `whsec_` del
@@ -94,7 +94,8 @@ from flashpi import AsyncFlashpi
94
94
  async def main() -> None:
95
95
  async with AsyncFlashpi() as flashpi:
96
96
  status = await flashpi.status.get()
97
- print(status["status"])
97
+ # "operational", and the production SRI: operational, degraded, outage or unknown
98
+ print(status["status"], status["sri"]["production"]["status"])
98
99
 
99
100
  async for document in flashpi.documents.list({"status": "authorized"}):
100
101
  print(document["accessKey"])
@@ -175,17 +176,18 @@ except APIError as error:
175
176
  raise
176
177
  ```
177
178
 
178
- | Class | Status | Example `code`s |
179
- | -------------------------- | ------ | --------------------------------------------------------------------------------- |
180
- | `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
181
- | `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
182
- | `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required` |
183
- | `NotFoundError` | 404 | `not_found` |
184
- | `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached` |
185
- | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
186
- | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
187
- | `InternalServerError` | 5xx | `internal_error` |
188
- | `APIConnectionError` | — | no answer (network); `APITimeoutError` when it timed out |
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
+ | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
188
+ | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
189
+ | `InternalServerError` | 5xx | `internal_error` |
190
+ | `APIConnectionError` | — | no answer (network); `APITimeoutError` when it timed out |
189
191
 
190
192
  All of them derive from `FlashpiError`. Some errors carry extra members in `error.problem`, such
191
193
  as `documentId`, `limit`, `resetsAt` or `rideStatus`. For Spanish messages:
@@ -232,6 +234,10 @@ An `AsyncFlashpi` call whose task is cancelled raises `asyncio.CancelledError`,
232
234
  Daily limits (such as the demo issuer's quota) are not retried: they are raised as a
233
235
  `RateLimitError` with `retry_after` in seconds.
234
236
 
237
+ A 402 `insufficient_credits` (the account has no credits left for a live document; test
238
+ documents stay free) and a 403 `credits_frozen` (the account's credits are on hold while Flashpi
239
+ reviews a payment; contact soporte@flashpi.com.ec) are not retried either.
240
+
235
241
  ## Webhooks
236
242
 
237
243
  Verify every webhook with the body **exactly as received** (not parsed) and the endpoint's
@@ -96,7 +96,8 @@ from flashpi import AsyncFlashpi
96
96
  async def main() -> None:
97
97
  async with AsyncFlashpi() as flashpi:
98
98
  status = await flashpi.status.get()
99
- print(status["status"])
99
+ # "operational", y el SRI de producción: operational, degraded, outage o unknown
100
+ print(status["status"], status["sri"]["production"]["status"])
100
101
 
101
102
  async for document in flashpi.documents.list({"status": "authorized"}):
102
103
  print(document["accessKey"])
@@ -178,17 +179,18 @@ except APIError as error:
178
179
  raise
179
180
  ```
180
181
 
181
- | Clase | Estado | Ejemplos de `code` |
182
- | -------------------------- | ------ | --------------------------------------------------------------------------------- |
183
- | `BadRequestError` | 400 | `malformed_json`, `invalid_idempotency_key` |
184
- | `AuthenticationError` | 401 | `authentication_required`, `invalid_api_key` |
185
- | `PermissionDeniedError` | 403 | `key_read_only`, `key_scope_mismatch`, `ip_not_allowed`, `live_key_required` |
186
- | `NotFoundError` | 404 | `not_found` |
187
- | `ConflictError` | 409 | `sequential_already_used`, `ride_not_available`, `webhook_endpoint_limit_reached` |
188
- | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
189
- | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
190
- | `InternalServerError` | 5xx | `internal_error` |
191
- | `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
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
+ | `UnprocessableEntityError` | 422 | `validation_failed`, `total_mismatch` |
191
+ | `RateLimitError` | 429 | `demo_issuer_quota_exceeded`, `account_email_limit_reached` |
192
+ | `InternalServerError` | 5xx | `internal_error` |
193
+ | `APIConnectionError` | — | sin respuesta (red); `APITimeoutError` si se agotó el plazo |
192
194
 
193
195
  Todas derivan de `FlashpiError`. Algunos errores traen datos extra en `error.problem`, por
194
196
  ejemplo `documentId`, `limit`, `resetsAt` o `rideStatus`. Para recibir los mensajes en español:
@@ -235,6 +237,10 @@ Una llamada de `AsyncFlashpi` cuya tarea se cancela lanza `asyncio.CancelledErro
235
237
  Los límites diarios (como la cuota del emisor demo) no se reintentan: se lanzan como
236
238
  `RateLimitError` con `retry_after` en segundos.
237
239
 
240
+ Tampoco se reintentan un 402 `insufficient_credits` (la cuenta no tiene créditos para un
241
+ documento live; los documentos de prueba siguen gratis) ni un 403 `credits_frozen` (los créditos de
242
+ la cuenta están retenidos mientras Flashpi revisa un pago; escribe a soporte@flashpi.com.ec).
243
+
238
244
  ## Webhooks
239
245
 
240
246
  Verifica cada webhook con el cuerpo **tal cual llegó** (sin parsear) y el secreto `whsec_` del
@@ -3,7 +3,7 @@
3
3
  "paths": {
4
4
  "/v1/status": {
5
5
  "get": {
6
- "description": "Public status of the Flashpi API: `operational` whenever the API answers. It reports no components and no SRI availability. Flashpi's status page, https://flashpi.com.ec/status, shows each component and the notices about incidents, maintenance and the SRI.",
6
+ "description": "Public status of the Flashpi API, `operational` whenever the API answers, and the availability of the SRI's web services per environment, which Flashpi checks every minute from its servers. Flashpi's status page, https://flashpi.com.ec/status, also shows the console, the docs and the notices about incidents and maintenance.",
7
7
  "operationId": "statusGet",
8
8
  "parameters": [
9
9
  {
@@ -6302,6 +6302,71 @@
6302
6302
  }
6303
6303
  },
6304
6304
  "schemas": {
6305
+ "SriEnvironmentStatus": {
6306
+ "type": "object",
6307
+ "properties": {
6308
+ "status": {
6309
+ "type": "string",
6310
+ "enum": [
6311
+ "operational",
6312
+ "degraded",
6313
+ "outage",
6314
+ "unknown"
6315
+ ],
6316
+ "example": "operational",
6317
+ "description": "`operational`: both web services answered in the latest check. `degraded`: they answered, the slower one in 3 seconds or more. `outage`: two checks in a row failed (no answer within 10 seconds, an HTTP error or an unexpected answer); while the SRI does not answer, Flashpi keeps the documents and retries them. `unknown`: no recent check (none answered yet, or the latest is more than 5 minutes old)."
6318
+ },
6319
+ "since": {
6320
+ "type": [
6321
+ "string",
6322
+ "null"
6323
+ ],
6324
+ "format": "date-time",
6325
+ "example": "2026-11-27T19:02:11.000Z",
6326
+ "description": "Since when `status` holds; null while it is `unknown`."
6327
+ },
6328
+ "checkedAt": {
6329
+ "type": [
6330
+ "string",
6331
+ "null"
6332
+ ],
6333
+ "format": "date-time",
6334
+ "example": "2026-11-27T19:30:05.000Z",
6335
+ "description": "When the latest check finished; null before the first one."
6336
+ },
6337
+ "latencyMs": {
6338
+ "type": [
6339
+ "integer",
6340
+ "null"
6341
+ ],
6342
+ "example": 140,
6343
+ "description": "The slower web service's answer time in the latest check, in milliseconds; null when the status is `outage` or `unknown`, or when the latest check failed."
6344
+ }
6345
+ },
6346
+ "description": "Availability of one SRI environment's web services, as Flashpi checks them every minute from its servers: the reception service's WSDL and a query of the authorization service that creates nothing.",
6347
+ "required": [
6348
+ "status",
6349
+ "since",
6350
+ "checkedAt",
6351
+ "latencyMs"
6352
+ ]
6353
+ },
6354
+ "SriStatus": {
6355
+ "type": "object",
6356
+ "properties": {
6357
+ "test": {
6358
+ "$ref": "#/components/schemas/SriEnvironmentStatus"
6359
+ },
6360
+ "production": {
6361
+ "$ref": "#/components/schemas/SriEnvironmentStatus"
6362
+ }
6363
+ },
6364
+ "description": "Availability of the SRI per environment: `test` is the pruebas environment (documents of test keys), `production` the production one (documents of live keys).",
6365
+ "required": [
6366
+ "test",
6367
+ "production"
6368
+ ]
6369
+ },
6305
6370
  "Status": {
6306
6371
  "type": "object",
6307
6372
  "properties": {
@@ -6311,12 +6376,21 @@
6311
6376
  "operational"
6312
6377
  ],
6313
6378
  "example": "operational",
6314
- "description": "Overall status of Flashpi."
6379
+ "description": "Overall status of Flashpi: `operational` whenever the API answers."
6380
+ },
6381
+ "sri": {
6382
+ "description": "Availability of the SRI's web services per environment.",
6383
+ "allOf": [
6384
+ {
6385
+ "$ref": "#/components/schemas/SriStatus"
6386
+ }
6387
+ ]
6315
6388
  }
6316
6389
  },
6317
- "description": "Public status of the Flashpi API. Components and SRI notices are on the status page, https://flashpi.com.ec/status.",
6390
+ "description": "Public status of the Flashpi API and of the SRI. The status page, https://flashpi.com.ec/status, also shows the console, the docs and the notices.",
6318
6391
  "required": [
6319
- "status"
6392
+ "status",
6393
+ "sri"
6320
6394
  ]
6321
6395
  },
6322
6396
  "ErrorCode": {
@@ -6375,6 +6449,8 @@
6375
6449
  "sandbox_not_enabled",
6376
6450
  "demo_issuer_quota_exceeded",
6377
6451
  "demo_issuer_unavailable",
6452
+ "insufficient_credits",
6453
+ "credits_frozen",
6378
6454
  "account_suspended"
6379
6455
  ],
6380
6456
  "description": "Stable machine-readable error code, the same in every language. Branch on it, never on `type`, `title` or `detail`. New codes may be added: handle an unknown one by its HTTP status."
@@ -7450,13 +7526,31 @@
7450
7526
  "null"
7451
7527
  ],
7452
7528
  "example": "SUPERMERCADOS LA PRADERA S.A.",
7453
- "description": "Organization (O): usually the company of a legal representative."
7529
+ "description": "Organization (O) as the certificate's subject states it. Some CAs put their own name there: show companyName as the company."
7530
+ },
7531
+ "companyName": {
7532
+ "type": [
7533
+ "string",
7534
+ "null"
7535
+ ],
7536
+ "example": "SUPERMERCADOS LA PRADERA S.A.",
7537
+ "description": "The company (razón social) the certificate states: where the issuing CA keeps it (its own field on older certificates, else the subject's O), never the CA's own name. Null for a natural person or when it is not known."
7538
+ },
7539
+ "jobTitle": {
7540
+ "type": [
7541
+ "string",
7542
+ "null"
7543
+ ],
7544
+ "example": "REPRESENTANTE LEGAL",
7545
+ "description": "The holder's job title (cargo), when the certificate states it."
7454
7546
  }
7455
7547
  },
7456
7548
  "description": "The certificate holder's names.",
7457
7549
  "required": [
7458
7550
  "commonName",
7459
- "organization"
7551
+ "organization",
7552
+ "companyName",
7553
+ "jobTitle"
7460
7554
  ]
7461
7555
  },
7462
7556
  "IssuerOnboardingIdentification": {
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "flashpi"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "The official Python SDK for Flashpi, the electronic invoicing API for Ecuador's SRI."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,3 +1,3 @@
1
1
  """The version of this package, updated by release-please on every release."""
2
2
 
3
- VERSION = "0.2.1" # x-release-please-version
3
+ VERSION = "0.2.3" # x-release-please-version
@@ -43,6 +43,11 @@ class IssuerOnboardings(SyncAPIResource):
43
43
  `verifying` until it is `ready` (Flashpi reads the holder, RUC and SRI data) or `rejected`,
44
44
  review the prefill, then complete it.
45
45
 
46
+ `onboarding["certificate"]["holder"]` has the holder's name (`commonName`), the company the
47
+ certificate states (`companyName`) and the holder's job title (`jobTitle`). Show
48
+ `companyName` as the company: `organization` is the subject's raw O, which some CAs fill with
49
+ their own name.
50
+
46
51
  Needs an account-scoped API key with read_write access.
47
52
  """
48
53
 
@@ -1,4 +1,4 @@
1
- """The API's own status. It needs no API key."""
1
+ """The status of the API and of the SRI. It needs no API key."""
2
2
 
3
3
  from functools import cached_property
4
4
  from typing import Unpack
@@ -10,10 +10,12 @@ from flashpi.types import Status
10
10
 
11
11
 
12
12
  class StatusResource(SyncAPIResource):
13
- """The API's own status (Node: `Status`, exported as `StatusResource`)."""
13
+ """The status of the API and of the SRI (Node: `Status`, exported as `StatusResource`)."""
14
14
 
15
15
  def get(self, **options: Unpack[RequestOptions]) -> Status:
16
- """Whether Flashpi is operational."""
16
+ """Whether Flashpi is operational, and the availability of the SRI's web services in each
17
+ environment (`sri["test"]` for test keys, `sri["production"]` for live keys), which Flashpi
18
+ checks every minute: `operational`, `degraded`, `outage` or `unknown`."""
17
19
  return self._request(RequestSpec[Status](method="GET", path="/v1/status", options=options))
18
20
 
19
21
  @cached_property
@@ -28,10 +30,12 @@ class StatusResourceWithResponse:
28
30
 
29
31
 
30
32
  class AsyncStatusResource(AsyncAPIResource):
31
- """The API's own status, for `AsyncFlashpi`."""
33
+ """The status of the API and of the SRI, for `AsyncFlashpi`."""
32
34
 
33
35
  async def get(self, **options: Unpack[RequestOptions]) -> Status:
34
- """Whether Flashpi is operational."""
36
+ """Whether Flashpi is operational, and the availability of the SRI's web services in each
37
+ environment (`sri["test"]` for test keys, `sri["production"]` for live keys), which Flashpi
38
+ checks every minute: `operational`, `degraded`, `outage` or `unknown`."""
35
39
  return await self._request(
36
40
  RequestSpec[Status](method="GET", path="/v1/status", options=options)
37
41
  )
@@ -89,6 +89,8 @@ from ._generated import (
89
89
  ProblemDetails,
90
90
  RotateWebhookEndpointSecret,
91
91
  SendDocumentEmail,
92
+ SriEnvironmentStatus,
93
+ SriStatus,
92
94
  Status,
93
95
  SupportingDocument,
94
96
  SupportingDocumentTax,
@@ -306,6 +308,8 @@ __all__ = [
306
308
  "ProblemDetails",
307
309
  "RotateWebhookEndpointSecret",
308
310
  "SendDocumentEmail",
311
+ "SriEnvironmentStatus",
312
+ "SriStatus",
309
313
  "Status",
310
314
  "SupportingDocument",
311
315
  "SupportingDocumentTax",
@@ -1779,6 +1779,8 @@ ErrorCode: TypeAlias = Literal[
1779
1779
  "sandbox_not_enabled",
1780
1780
  "demo_issuer_quota_exceeded",
1781
1781
  "demo_issuer_unavailable",
1782
+ "insufficient_credits",
1783
+ "credits_frozen",
1782
1784
  "account_suspended",
1783
1785
  ]
1784
1786
  """Stable machine-readable error code, the same in every language. Branch on it, never on `type`,
@@ -2007,7 +2009,16 @@ class IssuerOnboardingHolder(TypedDict):
2007
2009
  """Common name (CN): the holder's name."""
2008
2010
 
2009
2011
  organization: str | None
2010
- """Organization (O): usually the company of a legal representative."""
2012
+ """Organization (O) as the certificate's subject states it. Some CAs put their own name
2013
+ there: show companyName as the company."""
2014
+
2015
+ companyName: str | None
2016
+ """The company (razón social) the certificate states: where the issuing CA keeps it (its own
2017
+ field on older certificates, else the subject's O), never the CA's own name. Null for a
2018
+ natural person or when it is not known."""
2019
+
2020
+ jobTitle: str | None
2021
+ """The holder's job title (cargo), when the certificate states it."""
2011
2022
 
2012
2023
 
2013
2024
  IssuerOnboardingIdentificationRucSource: TypeAlias = Literal["certificate", "cedula"]
@@ -2360,16 +2371,59 @@ class SendDocumentEmail(TypedDict):
2360
2371
  """No options yet: send an empty object or no body."""
2361
2372
 
2362
2373
 
2374
+ SriEnvironmentStatusStatus: TypeAlias = Literal["operational", "degraded", "outage", "unknown"]
2375
+ """`operational`: both web services answered in the latest check. `degraded`: they answered, the
2376
+ slower one in 3 seconds or more. `outage`: two checks in a row failed (no answer within 10
2377
+ seconds, an HTTP error or an unexpected answer); while the SRI does not answer, Flashpi keeps
2378
+ the documents and retries them. `unknown`: no recent check (none answered yet, or the latest
2379
+ is more than 5 minutes old)."""
2380
+
2381
+
2382
+ class SriEnvironmentStatus(TypedDict):
2383
+ """Availability of one SRI environment's web services, as Flashpi checks them every minute
2384
+ from its servers: the reception service's WSDL and a query of the authorization service
2385
+ that creates nothing."""
2386
+
2387
+ status: SriEnvironmentStatusStatus
2388
+ """`operational`: both web services answered in the latest check. `degraded`: they answered,
2389
+ the slower one in 3 seconds or more. `outage`: two checks in a row failed (no answer
2390
+ within 10 seconds, an HTTP error or an unexpected answer); while the SRI does not answer,
2391
+ Flashpi keeps the documents and retries them. `unknown`: no recent check (none answered
2392
+ yet, or the latest is more than 5 minutes old)."""
2393
+
2394
+ since: str | None
2395
+ """Since when `status` holds; null while it is `unknown`. Format: date-time."""
2396
+
2397
+ checkedAt: str | None
2398
+ """When the latest check finished; null before the first one. Format: date-time."""
2399
+
2400
+ latencyMs: int | None
2401
+ """The slower web service's answer time in the latest check, in milliseconds; null when the
2402
+ status is `outage` or `unknown`, or when the latest check failed."""
2403
+
2404
+
2405
+ class SriStatus(TypedDict):
2406
+ """Availability of the SRI per environment: `test` is the pruebas environment (documents of
2407
+ test keys), `production` the production one (documents of live keys)."""
2408
+
2409
+ test: SriEnvironmentStatus
2410
+
2411
+ production: SriEnvironmentStatus
2412
+
2413
+
2363
2414
  StatusStatus: TypeAlias = Literal["operational"]
2364
- """Overall status of Flashpi."""
2415
+ """Overall status of Flashpi: `operational` whenever the API answers."""
2365
2416
 
2366
2417
 
2367
2418
  class Status(TypedDict):
2368
- """Public status of the Flashpi API. Components and SRI notices are on the status page,
2369
- https://flashpi.com.ec/status."""
2419
+ """Public status of the Flashpi API and of the SRI. The status page,
2420
+ https://flashpi.com.ec/status, also shows the console, the docs and the notices."""
2370
2421
 
2371
2422
  status: StatusStatus
2372
- """Overall status of Flashpi."""
2423
+ """Overall status of Flashpi: `operational` whenever the API answers."""
2424
+
2425
+ sri: SriStatus
2426
+ """Availability of the SRI's web services per environment."""
2373
2427
 
2374
2428
 
2375
2429
  class UpdateEstablishment(TypedDict):
@@ -13,7 +13,8 @@ from flashpi import AsyncFlashpi
13
13
  async def main() -> None:
14
14
  async with AsyncFlashpi() as flashpi:
15
15
  status = await flashpi.status.get()
16
- print(status["status"])
16
+ # "operational", and the production SRI: operational, degraded, outage or unknown
17
+ print(status["status"], status["sri"]["production"]["status"])
17
18
 
18
19
  async for document in flashpi.documents.list({"status": "authorized"}):
19
20
  print(document["accessKey"])
@@ -13,7 +13,8 @@ from flashpi import AsyncFlashpi
13
13
  async def main() -> None:
14
14
  async with AsyncFlashpi() as flashpi:
15
15
  status = await flashpi.status.get()
16
- print(status["status"])
16
+ # "operational", y el SRI de producción: operational, degraded, outage o unknown
17
+ print(status["status"], status["sri"]["production"]["status"])
17
18
 
18
19
  async for document in flashpi.documents.list({"status": "authorized"}):
19
20
  print(document["accessKey"])
@@ -22,7 +22,7 @@ from collections.abc import Iterator, Mapping
22
22
  import pytest
23
23
 
24
24
  from flashpi import AsyncFlashpi, ConflictError, Flashpi, NotFoundError, UnprocessableEntityError
25
- from flashpi.types import CreateInvoice, Document
25
+ from flashpi.types import CreateInvoice, Document, Status
26
26
 
27
27
  API_KEY = os.environ.get("FLASHPI_TEST_API_KEY", "")
28
28
  ISSUER_ID = os.environ.get("FLASHPI_DEMO_ISSUER_ID", "")
@@ -92,13 +92,21 @@ def invoice() -> Document:
92
92
  return issued[0]
93
93
 
94
94
 
95
+ def check_status(status: Status) -> None:
96
+ """Flashpi is operational, and it reports the SRI of both environments."""
97
+ assert status["status"] == "operational"
98
+ assert set(status["sri"]) == {"test", "production"}
99
+ for sri in (status["sri"]["test"], status["sri"]["production"]):
100
+ assert sri["status"] in ("operational", "degraded", "outage", "unknown")
101
+
102
+
95
103
  def test_reads_the_api_status(flashpi: Flashpi) -> None:
96
- assert flashpi.status.get() == {"status": "operational"}
104
+ check_status(flashpi.status.get())
97
105
 
98
106
 
99
107
  async def test_reads_the_api_status_on_the_async_client() -> None:
100
108
  async with AsyncFlashpi(checked_key(), base_url=BASE_URL) as client:
101
- assert await client.status.get() == {"status": "operational"}
109
+ check_status(await client.status.get())
102
110
 
103
111
 
104
112
  def test_rejects_an_invalid_invoice_with_field_errors_in_spanish(flashpi: Flashpi) -> None:
@@ -302,9 +302,24 @@ async def test_sends_its_operation(make: MakeApi, case: Case) -> None:
302
302
  assert ("idempotency-key" in request.headers) == (case.method == "POST")
303
303
 
304
304
 
305
- async def test_returns_the_api_status(make: MakeApi) -> None:
306
- api = make(json_response({"status": "operational"}))
307
- assert await api.op("status.get") == {"status": "operational"}
305
+ async def test_returns_the_api_status_with_the_sri_of_each_environment(make: MakeApi) -> None:
306
+ test = {
307
+ "status": "operational",
308
+ "since": "2026-11-27T19:02:11.000Z",
309
+ "checkedAt": "2026-11-27T19:30:05.000Z",
310
+ "latencyMs": 140,
311
+ }
312
+ production = {"status": "unknown", "since": None, "checkedAt": None, "latencyMs": None}
313
+ api = make(
314
+ json_response({"status": "operational", "sri": {"test": test, "production": production}})
315
+ )
316
+ status = await api.op("status.get")
317
+ assert status["sri"] == {"test": test, "production": production}
318
+ assert (status["sri"]["test"]["latencyMs"], status["sri"]["production"]["status"]) == (
319
+ 140,
320
+ "unknown",
321
+ )
322
+ assert api.sent[0].url.path == "/v1/status"
308
323
 
309
324
 
310
325
  async def test_walks_every_event_across_pages_with_the_same_filters(make: MakeApi) -> None:
@@ -897,6 +912,44 @@ class TestIssuerOnboardings:
897
912
  await api.op("issuer_onboardings.create", {"file": P12})
898
913
  assert api.sent == []
899
914
 
915
+ @pytest.mark.parametrize(
916
+ ("name", "args", "status_code"),
917
+ [
918
+ ("create", ({"file": P12, "password": "x"},), 202),
919
+ ("get", (ONBOARDING,), 200),
920
+ ],
921
+ )
922
+ async def test_reads_the_company_and_job_title_of_the_holder(
923
+ self, make: MakeApi, name: str, args: tuple[Any, ...], status_code: int
924
+ ) -> None:
925
+ holder = {
926
+ "commonName": "MARIA PEREZ",
927
+ "organization": "SECURITY DATA S.A.",
928
+ "companyName": "SUPERMERCADOS LA PRADERA S.A.",
929
+ "jobTitle": "REPRESENTANTE LEGAL",
930
+ }
931
+ api = make(
932
+ json_response({"id": ONBOARDING, "certificate": {"holder": holder}}, status_code)
933
+ )
934
+ onboarding = await api.op(f"issuer_onboardings.{name}", *args)
935
+ read = onboarding["certificate"]["holder"]
936
+ assert (read["companyName"], read["jobTitle"]) == (
937
+ "SUPERMERCADOS LA PRADERA S.A.",
938
+ "REPRESENTANTE LEGAL",
939
+ )
940
+ assert read["organization"] == "SECURITY DATA S.A."
941
+
942
+ async def test_reads_a_holder_with_no_company_or_job_title(self, make: MakeApi) -> None:
943
+ holder = {
944
+ "commonName": "MARIA PEREZ",
945
+ "organization": None,
946
+ "companyName": None,
947
+ "jobTitle": None,
948
+ }
949
+ api = make(json_response({"id": ONBOARDING, "certificate": {"holder": holder}}))
950
+ onboarding = await api.op("issuer_onboardings.get", ONBOARDING)
951
+ assert onboarding["certificate"]["holder"] == holder
952
+
900
953
  @pytest.mark.parametrize(
901
954
  ("name", "args"),
902
955
  [
@@ -45,6 +45,7 @@ class TestErrors:
45
45
  (400, "malformed_json", BadRequestError),
46
46
  (401, "invalid_api_key", AuthenticationError),
47
47
  (403, "key_read_only", PermissionDeniedError),
48
+ (403, "credits_frozen", PermissionDeniedError),
48
49
  (404, "not_found", NotFoundError),
49
50
  (409, "sequential_already_used", ConflictError),
50
51
  (413, "payload_too_large", APIError),
@@ -211,6 +212,15 @@ class TestRetries:
211
212
  await api.call("issue", {})
212
213
  assert len(api.sent) == 1
213
214
 
215
+ async def test_does_not_retry_a_402_without_credits(self, make: MakeApi) -> None:
216
+ api = make(problem(402, "insufficient_credits"))
217
+ with pytest.raises(APIError) as caught:
218
+ await api.call("issue", {})
219
+ assert type(caught.value) is APIError
220
+ assert caught.value.status == 402
221
+ assert caught.value.code == "insufficient_credits"
222
+ assert len(api.sent) == 1
223
+
214
224
  async def test_does_not_retry_a_501(self, make: MakeApi) -> None:
215
225
  api = make(httpx.Response(501))
216
226
  with pytest.raises(InternalServerError):
@@ -22,12 +22,21 @@ from flashpi.types import (
22
22
  EventType,
23
23
  FieldError,
24
24
  FieldErrorCode,
25
+ IssuerOnboardingHolder,
25
26
  Problem,
27
+ SriEnvironmentStatus,
28
+ SriStatus,
29
+ Status,
26
30
  ThinWebhookEvent,
27
31
  WebhookEndpointVerificationEventData,
28
32
  WebhookEvent,
29
33
  )
30
- from flashpi.types._generated import CertificateWarningCode, DocumentFailureCode, EventThinType
34
+ from flashpi.types._generated import (
35
+ CertificateWarningCode,
36
+ DocumentFailureCode,
37
+ EventThinType,
38
+ SriEnvironmentStatusStatus,
39
+ )
31
40
 
32
41
  ROOT = Path(__file__).resolve().parent.parent
33
42
  CONTRACT: dict[str, Any] = json.loads((ROOT / "openapi" / "openapi.json").read_text("utf-8"))
@@ -86,6 +95,22 @@ def test_a_certificate_always_carries_its_warnings() -> None:
86
95
  assert CertificateWarning.__required_keys__ == {"code", "message"}
87
96
 
88
97
 
98
+ def test_an_onboarding_holder_always_carries_its_company_and_job_title() -> None:
99
+ assert IssuerOnboardingHolder.__required_keys__ == {
100
+ "commonName",
101
+ "organization",
102
+ "companyName",
103
+ "jobTitle",
104
+ }
105
+
106
+
107
+ def test_the_status_always_carries_the_sri_of_each_environment() -> None:
108
+ assert Status.__required_keys__ == {"status", "sri"}
109
+ assert SriStatus.__required_keys__ == {"test", "production"}
110
+ assert SriEnvironmentStatus.__required_keys__ == {"status", "since", "checkedAt", "latencyMs"}
111
+ assert get_args(SriEnvironmentStatusStatus) == ("operational", "degraded", "outage", "unknown")
112
+
113
+
89
114
  def test_every_public_name_is_exported() -> None:
90
115
  for name in flashpi.types.__all__:
91
116
  assert getattr(flashpi.types, name) is not None
@@ -127,6 +152,28 @@ def reads_certificate_warnings(certificate: Certificate) -> list[str]:
127
152
  return [f"{warning['code']}: {warning['message']}" for warning in certificate["warnings"]]
128
153
 
129
154
 
155
+ def names_the_company_of_a_holder(holder: IssuerOnboardingHolder) -> str | None:
156
+ assert_type(holder["organization"], str | None)
157
+ assert_type(holder["companyName"], str | None)
158
+ assert_type(holder["jobTitle"], str | None)
159
+ company = holder["companyName"]
160
+ return f"{company} ({holder['jobTitle']})" if company and holder["jobTitle"] else company
161
+
162
+
163
+ def reads_the_sri_status(status: Status) -> dict[str, str]:
164
+ assert_type(status["sri"], SriStatus)
165
+ readings: dict[str, str] = {}
166
+ for name, sri in (("test", status["sri"]["test"]), ("production", status["sri"]["production"])):
167
+ assert_type(sri, SriEnvironmentStatus)
168
+ assert_type(sri["status"], SriEnvironmentStatusStatus)
169
+ assert_type(sri["since"], str | None)
170
+ assert_type(sri["checkedAt"], str | None)
171
+ assert_type(sri["latencyMs"], int | None)
172
+ latency = "" if sri["latencyMs"] is None else f" {sri['latencyMs']} ms"
173
+ readings[name] = sri["status"] + latency
174
+ return readings
175
+
176
+
130
177
  def keeps_field_error_codes_open(error: FieldError, problem: Problem) -> None:
131
178
  assert_type(error["code"], ApiFieldErrorCode)
132
179
  code: ApiFieldErrorCode = "a_code_added_later"
@@ -164,4 +211,28 @@ def test_the_static_checks_run() -> None:
164
211
  '{"id": "1", "status": "accepted", "warnings": [{"code": "ruc_mismatch", "message": "M"}]}'
165
212
  )
166
213
  assert reads_certificate_warnings(certificate) == ["ruc_mismatch: M"]
214
+ holder: IssuerOnboardingHolder = {
215
+ "commonName": "MARIA PEREZ",
216
+ "organization": "SECURITY DATA S.A.",
217
+ "companyName": "SUPERMERCADOS LA PRADERA S.A.",
218
+ "jobTitle": "REPRESENTANTE LEGAL",
219
+ }
220
+ assert names_the_company_of_a_holder(holder) == (
221
+ "SUPERMERCADOS LA PRADERA S.A. (REPRESENTANTE LEGAL)"
222
+ )
223
+ person: IssuerOnboardingHolder = {
224
+ "commonName": "MARIA PEREZ",
225
+ "organization": None,
226
+ "companyName": None,
227
+ "jobTitle": None,
228
+ }
229
+ assert names_the_company_of_a_holder(person) is None
230
+ status: Status = json.loads(
231
+ '{"status": "operational", "sri": {'
232
+ '"test": {"status": "degraded", "since": "2026-11-27T19:02:11.000Z",'
233
+ ' "checkedAt": "2026-11-27T19:30:05.000Z", "latencyMs": 3140},'
234
+ ' "production": {"status": "unknown", "since": null, "checkedAt": null,'
235
+ ' "latencyMs": null}}}'
236
+ )
237
+ assert reads_the_sri_status(status) == {"test": "degraded 3140 ms", "production": "unknown"}
167
238
  assert xml["kind"] is None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes