{
  "info": {
    "name": "Django Core Base API",
    "description": "Colección de llamadas para Django Core Base (auth JWT + promociones + automatizados).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "django-core-base-collection"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:8000",
      "type": "string"
    },
    {
      "key": "access_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "refresh_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "username",
      "value": "admin",
      "type": "string"
    },
    {
      "key": "password",
      "value": "admin",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Auth",
      "item": [
        {
          "name": "Obtener Token (Login)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "    const json = pm.response.json();",
                  "    if (json.access) pm.collectionVariables.set('access_token', json.access);",
                  "    if (json.refresh) pm.collectionVariables.set('refresh_token', json.refresh);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"{{username}}\",\n  \"password\": \"{{password}}\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/token/",
              "host": ["{{base_url}}"],
              "path": ["api", "token", ""]
            }
          }
        }
      ]
    },
    {
      "name": "Promociones",
      "item": [
        {
          "name": "Obtener Promoción",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{access_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"id\": 1,\n  \"activo\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/promociones/obtener/",
              "host": ["{{base_url}}"],
              "path": ["api", "promociones", "obtener", ""]
            }
          }
        }
      ]
    },
    {
      "name": "Automatizados",
      "item": [
        {
          "name": "Ejecutar Automatizaciones",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{access_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"nombre\": \"Ejecución manual desde Postman\",\n  \"descripcion\": \"Test de las 3 acciones automatizadas\",\n  \"origen\": \"manual\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/automatizados/ejecutar/",
              "host": ["{{base_url}}"],
              "path": ["api", "automatizados", "ejecutar", ""]
            }
          }
        },
        {
          "name": "Historial de Ejecuciones",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{access_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"estado\": \"\",\n  \"limit\": 20\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/automatizados/historial/",
              "host": ["{{base_url}}"],
              "path": ["api", "automatizados", "historial", ""]
            }
          }
        },
        {
          "name": "Estado del Módulo",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{access_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{}"
            },
            "url": {
              "raw": "{{base_url}}/api/automatizados/estado/",
              "host": ["{{base_url}}"],
              "path": ["api", "automatizados", "estado", ""]
            }
          }
        }
      ]
    }
  ]
}
