{
  "platformVersion": "15.12.0",
  "creates": {
    "render_report": {
      "display": {
        "description": "Genera un reporte PDF o Excel desde datos JSON",
        "label": "Generar Reporte",
        "hidden": false
      },
      "key": "render_report",
      "noun": "Reporte",
      "operation": {
        "inputFields": [
          {
            "key": "template", "label": "Plantilla", "type": "string", "required": true,
            "choices": {
              "factura": "Factura",
              "cotizacion": "Cotizacion",
              "recibo": "Recibo",
              "nota-venta": "Nota de Venta",
              "reporte-financiero": "Reporte Financiero",
              "inventario": "Inventario",
              "nomina": "Nomina"
            },
            "helpText": "Selecciona la plantilla para tu reporte"
          },
          {
            "key": "format", "label": "Formato", "type": "string", "required": true, "default": "pdf",
            "choices": { "pdf": "PDF", "xlsx": "Excel (.xlsx)", "csv": "CSV" }
          },
          { "key": "empresa_nombre", "label": "Nombre Empresa", "type": "string", "required": true, "helpText": "Nombre de tu empresa o negocio" },
          { "key": "empresa_rfc", "label": "RFC / NIT / RUC", "type": "string", "required": false, "helpText": "Identificacion fiscal de la empresa" },
          { "key": "cliente_nombre", "label": "Nombre Cliente", "type": "string", "required": true },
          { "key": "cliente_email", "label": "Email Cliente", "type": "string", "required": false },
          { "key": "items", "label": "Items (JSON array)", "type": "text", "required": true, "helpText": "Array JSON con los items: [{\"descripcion\": \"...\", \"cantidad\": 1, \"precio\": 100}]" },
          { "key": "moneda", "label": "Moneda", "type": "string", "required": false, "default": "MXN", "helpText": "Codigo de moneda (MXN, USD, EUR, COP, etc.)" }
        ],
        "perform": {
          "url": "https://reportia.4l3.org/v1/render",
          "method": "POST",
          "headers": {
            "Authorization": "Bearer {{bundle.authData.apiKey}}",
            "Content-Type": "application/json"
          },
          "body": {
            "template": "{{bundle.inputData.template}}",
            "format": "{{bundle.inputData.format}}",
            "data": {
              "empresa": {
                "nombre": "{{bundle.inputData.empresa_nombre}}",
                "rfc": "{{bundle.inputData.empresa_rfc}}"
              },
              "cliente": {
                "nombre": "{{bundle.inputData.cliente_nombre}}",
                "email": "{{bundle.inputData.cliente_email}}"
              },
              "items": "{{bundle.inputData.items}}",
              "moneda": "{{bundle.inputData.moneda}}"
            }
          }
        },
        "sample": {
          "download_url": "https://reportia.4l3.org/download/abc123.pdf",
          "format": "pdf",
          "template": "factura",
          "pages": 1
        }
      }
    }
  },
  "authentication": {
    "type": "custom",
    "fields": [
      { "key": "apiKey", "label": "API Key", "type": "string", "required": true, "helpText": "Tu API key de Reportia. Obtenla en reportia.4l3.org/portal" }
    ],
    "test": {
      "url": "https://reportia.4l3.org/v1/builder/me",
      "method": "GET",
      "headers": {
        "Authorization": "Bearer {{bundle.authData.apiKey}}"
      }
    }
  },
  "version": "1.0.0",
  "title": "Reportia",
  "description": "Genera reportes PDF, Excel y CSV profesionales desde datos JSON. Facturas, cotizaciones, inventarios y mas."
}
