{
  "info": {
    "_postman_id": "7c67b6e0-35a8-4e25-92e8-1962d4e1f50a",
    "name": "YEP API Core",
    "description": "Coleccion para probar los endpoints de auth, health y notifications del backend YEP API Core.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "GET /health",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/health",
              "host": ["{{baseUrl}}"],
              "path": ["health"]
            }
          }
        },
        {
          "name": "GET /",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/",
              "host": ["{{baseUrl}}"],
              "path": [""]
            }
          }
        }
      ]
    },
    {
      "name": "Auth",
      "item": [
        {
          "name": "POST /auth/register",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.accessToken) {",
                  "  pm.collectionVariables.set('accessToken', json.accessToken);",
                  "}",
                  "if (json.user && json.user.id) {",
                  "  pm.collectionVariables.set('userId', json.user.id);",
                  "}",
                  "if (json.user && json.user.accountId) {",
                  "  pm.collectionVariables.set('accountId', json.user.accountId);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"accountName\": \"Tienda Don Pedro\",\n  \"firstName\": \"Pedro\",\n  \"lastName\": \"Ramirez\",\n  \"email\": \"{{email}}\",\n  \"password\": \"{{password}}\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/auth/register",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "register"]
            }
          }
        },
        {
          "name": "POST /auth/login",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.accessToken) {",
                  "  pm.collectionVariables.set('accessToken', json.accessToken);",
                  "}",
                  "if (json.user && json.user.id) {",
                  "  pm.collectionVariables.set('userId', json.user.id);",
                  "}",
                  "if (json.user && json.user.accountId) {",
                  "  pm.collectionVariables.set('accountId', json.user.accountId);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"{{email}}\",\n  \"password\": \"{{password}}\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/auth/login",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "login"]
            }
          }
        },
        {
          "name": "GET /auth/me",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/auth/me",
              "host": ["{{baseUrl}}"],
              "path": ["auth", "me"]
            }
          }
        }
      ]
    },
    {
      "name": "Notifications",
      "item": [
        {
          "name": "POST /notifications/receive",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.id) {",
                  "  pm.collectionVariables.set('notificationId', json.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"id\": 1,\n  \"notification\": {\n    \"title\": \"Pago recibido\",\n    \"message\": \"Transferencia por $50.000\",\n    \"source\": \"mobile\"\n  }\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/notifications/receive",
              "host": ["{{baseUrl}}"],
              "path": ["notifications", "receive"]
            }
          }
        },
        {
          "name": "GET /notifications",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/notifications",
              "host": ["{{baseUrl}}"],
              "path": ["notifications"]
            }
          }
        },
        {
          "name": "GET /notifications/:id",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{accessToken}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/notifications/{{notificationId}}",
              "host": ["{{baseUrl}}"],
              "path": ["notifications", "{{notificationId}}"]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://yep-api-core-env.eba-535xtwxk.us-east-1.elasticbeanstalk.com"
    },
    {
      "key": "email",
      "value": "pedro@example.com"
    },
    {
      "key": "password",
      "value": "secret123"
    },
    {
      "key": "accessToken",
      "value": ""
    },
    {
      "key": "userId",
      "value": ""
    },
    {
      "key": "accountId",
      "value": ""
    },
    {
      "key": "notificationId",
      "value": ""
    }
  ]
}
