diff --git a/README.md b/README.md index 6075d8e..112700c 100644 --- a/README.md +++ b/README.md @@ -1,120 +1,122 @@ # EFC Microservice -Un microservicio de ejemplo desarrollado con FastAPI que permite gestionar items con operaciones CRUD completas. +Microservicio desarrollado con FastAPI y Celery para la gestión y procesamiento de pedimentos, partidas, remesas, acuses, coves y edocs en operaciones aduaneras. ## Características - API RESTful con FastAPI +- Procesamiento asíncrono de tareas con Celery y Redis +- Seguimiento de estado de tareas (submitted, processing, completed, failed) - Validación de datos con Pydantic - Documentación automática con Swagger UI -- Operaciones CRUD (Create, Read, Update, Delete) -- Filtrado por categoría -- Endpoint de health check +- Operaciones CRUD y endpoints especializados por módulo +- Integración con servicios externos (SOAP, VUCEM) +- Registro y actualización de tareas vía endpoints `/tasks/tasks/` ## Instalación 1. Crear un entorno virtual: -```bash -python -m venv venv -source venv/bin/activate # En Linux/Mac -# o -venv\Scripts\activate # En Windows -``` + ```bash + python -m venv venv + source venv/bin/activate # En Linux/Mac + # o + venv\Scripts\activate # En Windows + ``` 2. Instalar dependencias: -```bash -pip install -r requirements.txt -``` + ```bash + pip install -r requirements.txt + ``` + +3. Configurar variables de entorno en `.env` (ver ejemplo en `core/config.py`). ## Ejecutar el microservicio -```bash -python main.py -``` - -O usando uvicorn directamente: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` -El servidor estará disponible en: http://localhost:8000 +Para ejecutar los workers de Celery: +```bash +celery -A celery_app.celery_app worker --loglevel=info +``` ## Documentación API -Una vez que el servidor esté ejecutándose, puedes acceder a: - - **Swagger UI**: http://localhost:8000/docs - **ReDoc**: http://localhost:8000/redoc -## Endpoints disponibles +## Endpoints principales (`api/api_v2`) -### Endpoints básicos -- `GET /` - Mensaje de bienvenida -- `GET /health` - Health check del servicio +### Pedimentos +- `POST /api/v2/services/pedimento/` - Procesar pedimento completo +- `POST /api/v2/services/pedimento/partidas/` - Procesar partidas de pedimento +- `POST /api/v2/services/pedimento/remesas/` - Procesar remesas de pedimento -### Gestión de items -- `GET /items` - Obtener todos los items -- `GET /items/{item_id}` - Obtener un item específico -- `POST /items` - Crear un nuevo item -- `PUT /items/{item_id}` - Actualizar un item existente -- `DELETE /items/{item_id}` - Eliminar un item -- `GET /items/category/{category}` - Obtener items por categoría +### Acuses +- `POST /api/v2/services/acuse/` - Procesar acuse de pedimento +- `POST /api/v2/services/acuse/cove/` - Procesar acuse de COVE + +### Coves +- `POST /api/v2/services/cove/` - Procesar COVE + +### Edocs +- `POST /api/v2/services/edoc/` - Procesar E-Document + +### Estado de tareas +- `GET /api/v1/tasks/tasks/{task_id}/` - Consultar estado de una tarea ## Ejemplo de uso -### Crear un item +### Procesar un pedimento ```bash -curl -X POST "http://localhost:8000/items" \ +curl -X POST "http://localhost:8000/api/v2/services/pedimento/" \ -H "Content-Type: application/json" \ - -d '{ - "name": "Laptop", - "description": "Laptop para desarrollo", - "price": 1200.00, - "category": "electronics" - }' + -d '{ ... }' ``` -### Obtener todos los items +### Consultar estado de una tarea ```bash -curl -X GET "http://localhost:8000/items" -``` - -### Obtener items por categoría -```bash -curl -X GET "http://localhost:8000/items/category/electronics" +curl -X GET "http://localhost:8000/api/v1/tasks/tasks/{task_id}/" ``` ## Estructura del proyecto ``` -EFC_microservice/ -├── main.py # Aplicación principal -├── requirements.txt # Dependencias -└── README.md # Documentación +microservice/ +├── api/ +│ └── api_v2/ +│ ├── modules/ +│ │ ├── pedimentos/ +│ │ ├── partidas/ +│ │ ├── remesas/ +│ │ ├── acuses/ +│ │ ├── coves/ +│ │ └── edocs/ +│ └── tasks/ +├── core/ +│ └── config.py +├── celery_app.py +├── main.py +├── requirements.txt +└── README.md ``` -## Modelo de datos +## Modelo de datos (ejemplo pedimento) -### Item ```json { - "id": 1, - "name": "string", - "description": "string", - "price": 0.0, - "category": "string" + "pedimento_app": "string", + "organizacion_id": "string", + "partidas": [ ... ], + "remesas": [ ... ] } ``` -### ItemCreate -```json -{ - "name": "string", - "description": "string", - "price": 0.0, - "category": "string" -} -``` -# efc_microservices -# EFC_microservices -# EFC_microservices +## Notas + +- Cada endpoint retorna un `task_id` para consultar el estado de procesamiento. +- El seguimiento de tareas se realiza vía los endpoints `/tasks/tasks/`. +- Los estados posibles son: `submitted`, `processing`, `completed`, `failed`. + +--- \ No newline at end of file diff --git a/docs/Insomnia_2025-10-22.yaml b/docs/Insomnia_2025-10-22.yaml new file mode 100644 index 0000000..d4d1339 --- /dev/null +++ b/docs/Insomnia_2025-10-22.yaml @@ -0,0 +1,796 @@ +type: collection.insomnia.rest/5.0 +name: EFC +meta: + id: wrk_c24812c492ae4dc39bedaf12567ea826 + created: 1758644146195 + modified: 1758935162164 + description: "" +collection: + - url: "{{ _.API }}/services/acuse/" + name: acuse Request + meta: + id: req_7fcb66b58a7a4a9892cee798e445e28e + created: 1758644146199 + modified: 1759534626055 + isPrivate: false + description: "" + sortKey: -1758644146199 + method: POST + body: + mimeType: application/json + text: >+ + { + "edoc":{ + "id": 48708, + "numero_edocument": "0443250086CJ5" + }, + "idEDocument": "0443250086CJ5", + "pedimento": { + "id": "82c283e9-d983-4bce-8030-89e7ade1e2df", + "pedimento": "5006568", + "pedimento_app": "25-07-3785-5006568", + "aduana": "070", + "patente": "3785", + "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", + "regimen": "test", + "clave_pedimento": "test", + "numero_operacion": "test" + }, + "credencial": { + "id": "6144aa02-cedb-40cd-95e3-1d8bc1f716ec", + "user": "BUGJ6305217WA", + "password": "6zhtfyBGAwoUpR8ImK1gcZj8e5TvPID9i/r8v5jObnvF74UjodPSHZii9E107QeX", + "efirma": "JESUS1963", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8000/api/v1/token/ + name: Session + meta: + id: req_bda1bb2ea078406fa798bbcf67a3bdef + created: 1758817913368 + modified: 1758818005874 + isPrivate: false + description: "" + sortKey: -1758817913368 + method: POST + body: + mimeType: application/json + text: |- + { + "username": "krosales", + "password": "Soluciones01" + } + headers: + - name: Content-Type + value: application/json + - name: User-Agent + value: insomnia/11.6.1 + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8001/api/v2/services/cove/ + name: Cove Request + meta: + id: req_bd0368aec0b24ddb9c6867cc9cdc771b + created: 1758939234578 + modified: 1759977922951 + isPrivate: false + description: "" + sortKey: -1759009945530.5 + method: POST + body: + mimeType: application/json + text: >- + { + "cove": + { + "id": 5301, + "cove": "INTEC26906TRFP" + }, + + "pedimento": { + "id": "46ca701c-a933-455c-89d7-0ac53a0d81c4", + "pedimento": "3001008", + "pedimento_app": "23-23-1653-3001008", + "aduana": "230", + "patente": "1653", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "EXD", + "clave_pedimento": "V1", + "numero_operacion": "21423725707" + }, + "credencial": { + "id": "4db84571-8fbb-4d47-815d-28c7544652ef", + "user": "MTK861014317", + "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", + "efirma": "MTK34200", + "key": "vucem_keys/MTK861014317_clave.key", + "cer": "vucem_certs/00001000000504170472_hDcMiCu.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8001/api/v2/services/acuse/cove/ + name: Acuse Cove Request + meta: + id: req_5a99a7827c2d4f86936bd6f28adb7650 + created: 1758939244919 + modified: 1759503762463 + isPrivate: false + description: "" + sortKey: -1758644146099 + method: POST + body: + mimeType: application/json + text: >- + { + "cove": { + "id": 186044, + "cove": "COVE246FFQLS3" + }, + "pedimento": { + "id": "0731973d-3929-43f5-805b-a8680fbadd30", + "pedimento": "4001862", + "pedimento_app": "24-07-3785-4001862", + "aduana": "070", + "patente": "3785", + "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", + "regimen": "test", + "clave_pedimento": "test" + }, + "credencial": { + "id": "6144aa02-cedb-40cd-95e3-1d8bc1f716ec", + "user": "BUGJ6305217WA", + "password": "6zhtfyBGAwoUpR8ImK1gcZj8e5TvPID9i/r8v5jObnvF74UjodPSHZii9E107QeX", + "efirma": "JESUS1963", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/download/edoc/" + name: Edoc + meta: + id: req_a1e92db54db54d5da37bbf0ae1b33844 + created: 1759201977693 + modified: 1759202070523 + isPrivate: false + description: "" + sortKey: -1759201977693 + method: POST + body: + mimeType: application/json + text: >+ + { + "idEDocument": "0443250086CJ5", + "pedimento": { + "id": "82c283e9-d983-4bce-8030-89e7ade1e2df", + "pedimento": "5006568", + "pedimento_app": "25-07-3785-5006568", + "aduana": "070", + "patente": "3785", + "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", + "regimen": "test", + "clave_pedimento": "test" + }, + "credencial": { + "id": "6144aa02-cedb-40cd-95e3-1d8bc1f716ec", + "user": "BUGJ6305217WA", + "password": "6zhtfyBGAwoUpR8ImK1gcZj8e5TvPID9i/r8v5jObnvF74UjodPSHZii9E107QeX", + "efirma": "JESUS1963", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + + headers: + - name: Content-Type + value: application/json + - name: User-Agent + value: insomnia/11.6.1 + id: pair_97617cfb3949482bb3a940be2a0f5cd2 + - id: pair_7bf12502144641c782570f2e63643c7b + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/pedimento_completo/" + name: Pedimento Completo + meta: + id: req_25b081f249ea4fc2a51871716302a2f8 + created: 1759428115509 + modified: 1759717475897 + isPrivate: false + description: "" + sortKey: -1758644146149 + method: POST + body: + mimeType: application/json + text: >- + { + "pedimento": { + "id": "4d3ff490-8ded-4914-8efe-3f596797bfe9", + "pedimento": "946", + "pedimento_app": "20-16-3910-946", + "aduana": "160", + "patente": "3910", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "ITE", + "clave_pedimento": "IN", + "numero_operacion": "21612122698" + }, + "credencial": { + "id": "40d1d433-dba5-47a8-b00c-dce077c3c5cd", + "user": "TEC1406248Q2", + "password": "4Z+6Aulov0ohSWLda/INLyEm8p2xJSYK/iZnA+vjHZPDD4otHSBnr1p7GPugdwCh", + "efirma": "MTAyMFRFQ1oxNDA2", + "key": "/media/vucem_keys/TEC1406248Q2_clave.key", + "cer": "/media/vucem_certs/TEC1406248Q2_certificado.cer", + "is_active": true, + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8001/api/v2/services/partida/ + name: Partida Request + meta: + id: req_7eda4a100f8445588870efda0ceb7834 + created: 1759515456602 + modified: 1759554443705 + isPrivate: false + description: "" + sortKey: -1758644146049 + method: POST + body: + mimeType: application/json + text: >- + { + "partida": { + "id": 771282, + "numero": 2 + }, + "pedimento": { + "id": "0731973d-3929-43f5-805b-a8680fbadd30", + "pedimento": "4001862", + "pedimento_app": "24-07-3785-4001862", + "aduana": "070", + "patente": "3785", + "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", + "regimen": "test", + "clave_pedimento": "test", + "numero_operacion": "21693451590" + }, + "credencial": { + "id": "6144aa02-cedb-40cd-95e3-1d8bc1f716ec", + "user": "BUGJ6305217WA", + "password": "6zhtfyBGAwoUpR8ImK1gcZj8e5TvPID9i/r8v5jObnvF74UjodPSHZii9E107QeX", + "efirma": "JESUS1963", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/remesas/" + name: Remesa + meta: + id: req_9aa4a2f64ea140879794273056f8487d + created: 1759542990273 + modified: 1759543263710 + isPrivate: false + description: "" + sortKey: -1758644146124 + method: POST + body: + mimeType: application/json + text: >- + { + "pedimento": { + "id": "c378fb93-9de1-40ea-a33b-15e8d2d5e67b", + "pedimento": "6755", + "pedimento_app": "20-52-3147-6755", + "aduana": "520", + "patente": "3147", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "EXD", + "clave_pedimento": "RT", + "numero_operacion": "21474873210" + }, + "credencial": { + "id": "40d1d433-dba5-47a8-b00c-dce077c3c5cd", + "user": "TEC1406248Q2", + "password": "4Z+6Aulov0ohSWLda/INLyEm8p2xJSYK/iZnA+vjHZPDD4otHSBnr1p7GPugdwCh", + "efirma": "MTAyMFRFQ1oxNDA2", + "key": "/media/vucem_keys/TEC1406248Q2_clave.key", + "cer": "/media/vucem_certs/TEC1406248Q2_certificado.cer", + "is_active": true, + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8001/api/v2/services/all/coves + name: Coves Request + meta: + id: req_428212e95fa5478fb3d2c6b2756bb060 + created: 1759548103261 + modified: 1759713150167 + isPrivate: false + description: "" + sortKey: -1758913929449.25 + method: POST + body: + mimeType: application/json + text: >- + { + "coves": [ + { + "id": 5298, + "cove": "INTEC26836TRFP" + }, + { + "id": 5300, + "cove": "INTEC26728TRFP" + }, + { + "id": 5302, + "cove": "INTEC26613TRFP" + }, + { + "id": 5299, + "cove": "INTEC26575TRFP" + }, + { + "id": 5301, + "cove": "INTEC26906TRFP" + } + ], + "pedimento": { + "id": "46ca701c-a933-455c-89d7-0ac53a0d81c4", + "pedimento": "3001008", + "pedimento_app": "23-23-1653-3001008", + "aduana": "230", + "patente": "1653", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "EXD", + "clave_pedimento": "V1", + "numero_operacion": "21423725707" + }, + "credencial": { + "id": "4db84571-8fbb-4d47-815d-28c7544652ef", + "user": "MTK861014317", + "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", + "efirma": "MTK34200", + "key": "vucem_keys/MTK861014317_clave.key", + "cer": "vucem_certs/00001000000504170472_hDcMiCu.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/all/acuse/pedimento/" + name: acuses Request + meta: + id: req_8a99b139e1704385817309e76dced6a1 + created: 1759551897198 + modified: 1759551981396 + isPrivate: false + description: "" + sortKey: -1758644146174 + method: POST + body: + mimeType: application/json + text: >- + { + "edocs": [ + { + "id": 29070, + "numero_edocument": "0438200GXO8L3" + }, + { + "id": 29075, + "numero_edocument": "04282007CHFI7" + } + ], + "pedimento": { + "id": "6de61493-884a-48a5-9065-e44b1b0caef3", + "pedimento": "1000", + "pedimento_app": "20-16-3910-1000", + "aduana": "160", + "patente": "3910", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "ITE", + "clave_pedimento": "IN", + "numero_operacion": "21465264174" + }, + "credencial": { + "id": "40d1d433-dba5-47a8-b00c-dce077c3c5cd", + "user": "TEC1406248Q2", + "password": "4Z+6Aulov0ohSWLda/INLyEm8p2xJSYK/iZnA+vjHZPDD4otHSBnr1p7GPugdwCh", + "efirma": "TXM241007", + "key": "/media/vucem_keys/TEC1406248Q2_clave_vJA0zau.key", + "cer": "/media/vucem_certs/TEC1406248Q2_certificado_Du8N2Q9.cer", + "is_active": true, + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: http://192.168.1.79:8001/api/v2/services/all/acuse/cove/ + name: Acuse Coves Request + meta: + id: req_889ce00a162240d1bdaf04195d7e5ecb + created: 1759712847144 + modified: 1759712910640 + isPrivate: false + description: "" + sortKey: -1758865921408.625 + method: POST + body: + mimeType: application/json + text: >- + { + "coves": [ + { + "id": 5298, + "cove": "INTEC26836TRFP" + } + ], + "pedimento": { + "id": "46ca701c-a933-455c-89d7-0ac53a0d81c4", + "pedimento": "3001008", + "pedimento_app": "23-23-1653-3001008", + "aduana": "230", + "patente": "1653", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "EXD", + "clave_pedimento": "V1", + "numero_operacion": "21423725707" + }, + "credencial": { + "id": "4db84571-8fbb-4d47-815d-28c7544652ef", + "user": "MTK861014317", + "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", + "efirma": "MTK34200", + "key": "vucem_keys/MTK861014317_clave.key", + "cer": "vucem_certs/00001000000504170472_hDcMiCu.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/download/edoc/" + name: ED Request + meta: + id: req_2f2781a85e88448dba67e3b1f8a091d9 + created: 1759727845925 + modified: 1759729379208 + isPrivate: false + description: "" + sortKey: -1758644146186.5 + method: POST + body: + mimeType: application/json + text: >+ + { + "edoc":{ + "id": 94657, + "numero_edocument": "0192240XOKJH3" + }, + "idEDocument": "0443250086CJ5", + "pedimento": { + "id": "82c283e9-d983-4bce-8030-89e7ade1e2df", + "pedimento": "4002664", + "pedimento_app": "24-16-1788-4002664", + "aduana": "160", + "patente": "1788", + "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", + "regimen": "test", + "clave_pedimento": "test", + "numero_operacion": "test" + }, + "credencial": { + "id": "4db84571-8fbb-4d47-815d-28c7544652ef", + "user": "MTK861014317", + "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", + "efirma": "MTK34200", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true + - url: "{{ _.API }}/services/download/all/edocs/" + name: EDs Request + meta: + id: req_348a7439e2e04c67892d22a3c552d62d + created: 1759730303843 + modified: 1759731412570 + isPrivate: false + description: "" + sortKey: -1758644146180.25 + method: POST + body: + mimeType: application/json + text: >- + { + "edocs": [ + { + "id": 94656, + "numero_edocument": "0192240XONDN8" + } + ], + "idEDocument": "0443250086CJ5", + "pedimento": { + "id": "00047587-4693-4d90-9c5c-26d2a3e31afb", + "pedimento": "4002664", + "pedimento_app": "24-16-1788-4002664", + "aduana": "160", + "patente": "1788", + "organizacion": "9d705e97-d3f2-4b6c-8d92-9f1af2b2d4b4", + "regimen": "test", + "clave_pedimento": "test", + "numero_operacion": "test" + }, + "credencial": { + "id": "4db84571-8fbb-4d47-815d-28c7544652ef", + "user": "MTK861014317", + "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", + "efirma": "MTK34200", + "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", + "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", + "is_active": true, + "organizacion": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + } + headers: + - name: Content-Type + value: application/json + id: pair_224e03f3d9bd4bf59ab88ce3a55ba4c6 + - name: User-Agent + value: insomnia/11.6.1 + id: pair_bd5a1d0a2bcb4a319e54578785d34a57 + - id: pair_70cf61f736a1415ab79ac479dd84c65c + name: Authorization + value: Bearer {{ _.Token }} + description: "" + disabled: false + settings: + renderRequestBody: true + encodeUrl: true + followRedirects: global + cookies: + send: true + store: true + rebuildPath: true +cookieJar: + name: Default Jar + meta: + id: jar_eee1d3c3cdb50c20fbe2b04c3b439f4c0f262657 + created: 1758644146197 + modified: 1758644146197 +environments: + name: Base Environment + meta: + id: env_eee1d3c3cdb50c20fbe2b04c3b439f4c0f262657 + created: 1758644146196 + modified: 1759534534414 + isPrivate: false + data: + Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzU5NTM2MzIzLCJpYXQiOjE3NTk1MzQ1MjMsImp0aSI6ImI3YjAwYTAzYmRkZjQ1ZmE5Yjc4NWE4MGNiNzY4YzZjIiwidXNlcl9pZCI6IjA1MzBjYTMzLWE0MzctNGJiZC04ZTMzLWMyMjUyMDg2Nzk4MiJ9.0F8v5shDz90gdiKxRABCWv21zgnaWrZi9Tl1G3dgCjI + API: http://192.168.1.79:8001/api/v2 diff --git a/docs/postman_collection.json b/docs/postman_collection.json new file mode 100644 index 0000000..9bc8504 --- /dev/null +++ b/docs/postman_collection.json @@ -0,0 +1,124 @@ +{ + "info": { + "name": "EFC Microservice API v2", + "description": "Colección de ejemplos básicos para probar los endpoints principales de api/api_v2", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Procesar Pedimento Completo", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/pedimento_completo", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "pedimento_completo"] }, + "body": { "mode": "raw", "raw": "{\n \"pedimento\": {\n \"id\": \"PED123\",\n \"pedimento\": \"1234567\",\n \"pedimento_app\": \"1234567\",\n \"aduana\": \"640\",\n \"patente\": \"1234\",\n \"organizacion\": \"ORG1\"\n },\n \"credencial\": {\n \"user\": \"usuario\",\n \"password\": \"pass\",\n \"id\": \"CRED001\"\n }\n}" } + } + }, + { + "name": "Procesar Partida", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/partida/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "partida", ""] }, + "body": { "mode": "raw", "raw": "{\n \"partida\": {\"id\": 1, \"numero\": 1},\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Remesa", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/remesas/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "remesas", ""] }, + "body": { "mode": "raw", "raw": "{\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Acuse Individual", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/acuse/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "acuse", ""] }, + "body": { "mode": "raw", "raw": "{\n \"edoc\": {\"id\": 1, \"numero_edocument\": \"EDOC001\"},\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Acuse Masivo", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/all/acuse/pedimento/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "all", "acuse", "pedimento", ""] }, + "body": { "mode": "raw", "raw": "{\n \"edocs\": [{\"id\": 1, \"numero_edocument\": \"EDOC001\"}],\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar COVE Individual", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/cove/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "cove", ""] }, + "body": { "mode": "raw", "raw": "{\n \"cove\": {\"id\": 1, \"cove\": \"COVE001\"},\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar COVEs Masivo", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/all/coves", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "all", "coves"] }, + "body": { "mode": "raw", "raw": "{\n \"coves\": [{\"id\": 1, \"cove\": \"COVE001\"}],\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Acuse COVE Individual", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/acuse/cove/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "acuse", "cove", ""] }, + "body": { "mode": "raw", "raw": "{\n \"cove\": {\"id\": 1, \"cove\": \"COVE001\"},\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Acuse COVEs Masivo", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/all/acuse/cove/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "all", "acuse", "cove", ""] }, + "body": { "mode": "raw", "raw": "{\n \"coves\": [{\"id\": 1, \"cove\": \"COVE001\"}],\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Edoc Individual", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/download/edoc/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "download", "edoc", ""] }, + "body": { "mode": "raw", "raw": "{\n \"edoc\": {\"id\": 1, \"numero_edocument\": \"EDOC001\"},\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Procesar Edocs Masivo", + "request": { + "method": "POST", + "header": [{ "key": "Content-Type", "value": "application/json" }], + "url": { "raw": "http://localhost:8001/api/v2/services/download/all/edocs/", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "services", "download", "all", "edocs", ""] }, + "body": { "mode": "raw", "raw": "{\n \"edocs\": [{\"id\": 1, \"numero_edocument\": \"EDOC001\"}],\n \"pedimento\": {\"id\": \"PED123\", \"pedimento\": \"1234567\", \"pedimento_app\": \"1234567\", \"aduana\": \"640\", \"patente\": \"1234\", \"organizacion\": \"ORG1\"},\n \"credencial\": {\"user\": \"usuario\", \"password\": \"pass\", \"id\": \"CRED001\"}\n}" } + } + }, + { + "name": "Consultar Estado de Tarea", + "request": { + "method": "GET", + "header": [], + "url": { "raw": "http://localhost:8001/api/v2/async/task-status/{{task_id}}", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "async", "task-status", "{{task_id}}"] } + } + }, + { + "name": "Cancelar Tarea", + "request": { + "method": "DELETE", + "header": [], + "url": { "raw": "http://localhost:8001/api/v2/async/task/{{task_id}}", "protocol": "http", "host": ["localhost"], "port": "8001", "path": ["api", "v2", "async", "task", "{{task_id}}"] } + } + } + ] +} diff --git a/examples/fire_and_forget_example.py b/examples/fire_and_forget_example.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/item_service_usage.py b/examples/item_service_usage.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/soap_controller_usage.py b/examples/soap_controller_usage.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/test_extract_file.py b/examples/test_extract_file.py deleted file mode 100644 index e0978f5..0000000 --- a/examples/test_extract_file.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -from utils.peticiones import extract_pdf_bytes_from_xml - -xml_path = os.path.abspath("./test.xml") - -result = extract_pdf_bytes_from_xml(xml_path) - -if result and result["pdf_bytes"]: - with open("output_test.pdf", "wb") as f: - f.write(result["pdf_bytes"]) - print("PDF extraído y guardado como output_test.pdf") -else: - print("No se pudo extraer el PDF del XML.") diff --git a/test.json b/test.json deleted file mode 100644 index 165622e..0000000 --- a/test.json +++ /dev/null @@ -1,33 +0,0 @@ -"pedimento": { - "id": "82c283e9-d983-4bce-8030-89e7ade1e2df", - "pedimento": "4002664", - "pedimento_app": "24-16-1788-4002664", - "aduana": "160", - "patente": "1788", - "numero_operacion": "test", - "regimen": "test", - "organizacion": "4fea91c7-4a1d-40b3-a433-f0122b5ea43e", - "clave_pedimento": "test", - "fecha_pago": None, - "fecha_inicio": None, - "fecha_fin": None, - "alerta": None, - "agente_aduanal": None, - "curp_apoderado": None, - "importe_total": None, - "saldo_disponible": None, - "importe_pedimento": None, - "existe_expediente": None -}, -"credencial": { - "id": "4db84571-8fbb-4d47-815d-28c7544652ef", - "user": "MTK861014317", - "password": "+PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9", - "efirma": "MTK34200", - "key": "vucem_keys/Claveprivada_FIEL_BUGJ6305217WA_20221215_131315_oPkSEWC.key", - "cer": "vucem_certs/00001000000516774465_xSn9CUa.cer", - "is_active": True, - "organizacion": UUID("3fa85f64-5717-4562-b3fc-2c963f66afa6") -}, -"edoc": None -} \ No newline at end of file diff --git a/test.xml b/test.xml deleted file mode 100644 index 11c4012..0000000 --- a/test.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - MTK861014317 - +PNjq4gtAm7IH3tAuipUNxXO2/ivgLbNdlwjV/teOc4PocnOtX/NYUiRezhxubN9 - - - - 0192240XOKJH3 - 1 - - - \ No newline at end of file