{
    "info": {
        "_postman_id": "abian-gestion-api",
        "name": "AbianGest Node API",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "item": [
        {
            "name": "Login (Get Token)",
            "event": [
                {
                    "listen": "test",
                    "script": {
                        "exec": [
                            "var jsonData = pm.response.json();",
                            "if (jsonData.success && jsonData.token) {",
                            "    pm.environment.set(\"token\", jsonData.token);",
                            "    console.log(\"Token saved:\", jsonData.token);",
                            "} else {",
                            "    console.error(\"Login failed or unexpected format\");",
                            "}"
                        ],
                        "type": "text/javascript"
                    }
                }
            ],
            "request": {
                "method": "POST",
                "header": [],
                "body": {
                    "mode": "urlencoded",
                    "urlencoded": [
                        {
                            "key": "usuario",
                            "value": "TU_USUARIO",
                            "type": "text",
                            "description": "DNI del usuario"
                        },
                        {
                            "key": "contrasena",
                            "value": "TU_CONTRASEÑA",
                            "type": "text"
                        }
                    ]
                },
                "url": {
                    "raw": "https://node.gestion.abianservice.com/login",
                    "protocol": "https",
                    "host": [
                        "node",
                        "gestion",
                        "abianservice",
                        "com"
                    ],
                    "path": [
                        "login"
                    ]
                }
            },
            "response": []
        },
        {
            "name": "Get Profile (Protected)",
            "request": {
                "method": "POST",
                "header": [
                    {
                        "key": "Authorization",
                        "value": "Bearer {{token}}",
                        "type": "text"
                    }
                ],
                "body": {
                    "mode": "urlencoded",
                    "urlencoded": [
                        {
                            "key": "id_proveedor",
                            "value": "ID_DE_PRUEBA",
                            "type": "text"
                        }
                    ]
                },
                "url": {
                    "raw": "https://node.gestion.abianservice.com/get_profile",
                    "protocol": "https",
                    "host": [
                        "node",
                        "gestion",
                        "abianservice",
                        "com"
                    ],
                    "path": [
                        "get_profile"
                    ]
                }
            },
            "response": []
        },
        {
            "name": "Change Password (Protected)",
            "request": {
                "method": "POST",
                "header": [
                    {
                        "key": "Authorization",
                        "value": "Bearer {{token}}",
                        "type": "text"
                    }
                ],
                "body": {
                    "mode": "urlencoded",
                    "urlencoded": [
                        {
                            "key": "usuario",
                            "value": "DNI_USUARIO",
                            "type": "text"
                        },
                        {
                            "key": "password",
                            "value": "NUEVA_CONTRASEÑA",
                            "type": "text"
                        }
                    ]
                },
                "url": {
                    "raw": "https://node.gestion.abianservice.com/change_password",
                    "protocol": "https",
                    "host": [
                        "node",
                        "gestion",
                        "abianservice",
                        "com"
                    ],
                    "path": [
                        "change_password"
                    ]
                }
            },
            "response": []
        }
    ],
    "variable": [
        {
            "key": "token",
            "value": ""
        }
    ]
}