# Boleta Mensual(Obtener Proceso de Descarga (1)) - [obtener]

### 🧾 Descripción

*Este servicio permite **buscar y obtener información detallada de una denuncia** registrada en el ERP, usando un **código aleatorio** generado para consulta pública.*

La función:

- Busca la denuncia usando el campo `codigo_aleatorio`.
- Retorna información clave como:
    
    
    - estado de la denuncia,
    - fecha de creación,
    - fecha de atención,
    - fecha de proceso,
    - respuesta,
    - y un archivo asociado (si existe).
- Construye la URL completa del archivo para ser descargado por el cliente.

Es un servicio de consulta directa, sin dependencias entre módulos.

---

# 🚀 Endpoint

### **POST /obtener**

### 📥 Request Body

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22codigo%22%3A-%22abc1234"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"codigo"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"ABC12345"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# 🔐 Seguridad

No requiere token especial más allá del utilizado internamente por `apiService()` o `ServiceErp()`.  
La autenticación se maneja dentro del sistema ERP.

---

# 🧠 Flujo del Servicio (resumen real)

1. Recibe el parámetro: `<span class="hljs-attr">codigo</span> = <span class="hljs-variable">$request</span>->codigo`
2. Construye un request hacia el ERP: `GET Denuncias?fields=[...]&filters=<span class="hljs-string">[["codigo_aleatorio","=",codigo]]</span>`

Campos obtenidos:

- name
- creation
- estado\_denuncias
- fecha\_atendido
- fecha\_proceso
- archivo\_denuncia
- respuesta\_de\_denuncia\_atendido

3. Si no existe la denuncia → se responde:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No se encontró la denuncia"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>4. Si existe y tiene archivo, se concatena la URL base:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-archivo_denuncia-%3D-b"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`<span class="hljs-attr">archivo_denuncia</span> = BASE_CAPACITACION . archivo_denuncia`</div></div>5. Se devuelve la **primera denuncia encontrada**, ya que el código es único.

---

# 📤 Response 200 – Ejemplo

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-true%2C-%22"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Encontrado"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>    <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"DEN-00045"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"creation"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-15 09:12:20"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"estado_denuncias"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Atendido"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"fecha_atendido"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-20"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"fecha_proceso"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"2025-01-18"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"archivo_denuncia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"https://servidor.com/files/denuncias/archivo.pdf"</span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">"respuesta_de_denuncia_atendido"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Se revisó la información y se procedió..."</span>  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# ❗ Posibles Errores

### 1. No se encuentra la denuncia

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C--1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No se encontró la denuncia"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 2. Error del ERP

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C--2"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Error message from ERP"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>### 3. Código vacío o inválido

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22success%22%3A-false%2C--3"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"success"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"message"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No se encontró la denuncia"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# 📚 Schemas Usados

### **Denuncias (GET)**

Campos usados:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22name%22%3A-%22string%22%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"creation"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"datetime"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"estado_denuncias"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"fecha_atendido"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"date"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"fecha_proceso"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"date"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"archivo_denuncia"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string|null"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"respuesta_de_denuncia_atendido"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string|null"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>---

# 🗃 Lógica del Servicio (Pseudo-código)

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-codigo-%3D-request.cod"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 30.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 30.6px;"><td style="height: 30.6px;">`codigo = request.codigobody = {    limit = None    fields = [name, creation, estado_denuncias, fecha_atendido, fecha_proceso, archivo_denuncia, respuesta...]    filters = [["codigo_aleatorio", "=", codigo]]}response = GET Denuncias using ServiceErpif !response.valor or response.response is empty:    return error "No se encontró la denuncia"denuncia = response.response[0]if denuncia.archivo_denuncia != "":    denuncia.archivo_denuncia = BASE_CAPACITACION + denuncia.archivo_denunciareturn success with denuncia`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>