{
  "info": {
    "_postman_id": "7a0a48ca-cc6f-4a70-bf9f-f497ceacf799",
    "name": "Restaurant POS - Staff Mobile API",
    "description": "Staff-only mobile authentication API. Run Login first; its token is saved automatically for Me and Logout.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://127.0.0.1:8000"
    },
    {
      "key": "staff_token",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "0. List Restaurants",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/staff/restaurants",
          "host": ["{{base_url}}"],
          "path": ["api", "staff", "restaurants"]
        },
        "description": "Public — no login needed. Returns the restaurants to show in the login page's dropdown, as [{id, name}]. \"id\" is exactly what Login expects as \"restaurant\". Only lists Waiter App flow restaurants that are active with an active subscription (Kiosk-flow restaurants never have staff accounts to log into)."
      }
    },
    {
      "name": "1. Staff Login",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Login succeeded', function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "if (pm.response.code === 200) {",
              "    const response = pm.response.json();",
              "    pm.collectionVariables.set('staff_token', response.token);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"restaurant\": 1,\n    \"phone\": \"9876543210\",\n    \"password\": \"password\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{base_url}}/api/staff/login",
          "host": ["{{base_url}}"],
          "path": ["api", "staff", "login"]
        },
        "description": "restaurant is the client's numeric ID (shown as \"Restaurant ID\" in their admin dashboard header, or \"Client ID\" on their Super Admin page). Replace phone and password with an active account whose role is staff at that restaurant. A successful response automatically saves the token."
      }
    },
    {
      "name": "2. Get Logged-in Staff",
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{staff_token}}",
              "type": "string"
            }
          ]
        },
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/staff/me",
          "host": ["{{base_url}}"],
          "path": ["api", "staff", "me"]
        }
      }
    },
    {
      "name": "3. Staff Logout",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "if (pm.response.code === 200) {",
              "    pm.collectionVariables.unset('staff_token');",
              "}"
            ]
          }
        }
      ],
      "request": {
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{staff_token}}",
              "type": "string"
            }
          ]
        },
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/staff/logout",
          "host": ["{{base_url}}"],
          "path": ["api", "staff", "logout"]
        }
      }
    }
  ]
}
