{
  "info": {
    "_postman_id": "a1b2c3d4-e5f6-4789-abcd-ef0123456789",
    "name": "GatesServer API",
    "description": "GatesServer API — example requests, responses, and error paths.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key",   "value": "x-api-key",   "type": "string" },
      { "key": "value", "value": "{{API_KEY}}", "type": "string" },
      { "key": "in",    "value": "header",      "type": "string" }
    ]
  },
  "variable": [
    { "key": "GS_HOST", "value": "http://localhost:3000", "type": "string" },
    { "key": "API_KEY", "value": "your-api-key-here",     "type": "string" }
  ],
  "item": [
    {
      "name": "Person management",
      "item": [
        {
          "name": "Create person",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"personCode\": \"EMP20260428001\",\n  \"personGivenName\": \"Mostafa\",\n  \"personFamilyName\": \"Ahmed\",\n  \"gender\": 1,\n  \"orgIndexCode\": \"ORG_TATWEER_001\",\n  \"beginTime\": \"2026-04-28T13:00:00+03:00\",\n  \"endTime\":   \"2033-04-28T13:00:00+03:00\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{GS_HOST}}/api/persons",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "persons"]
            },
            "description": "Create a new person."
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "POST",
                "header": [
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"personCode\": \"EMP20260428001\"\n}"
                },
                "url": {
                  "raw": "{{GS_HOST}}/api/persons",
                  "host": ["{{GS_HOST}}"],
                  "path": ["api", "persons"]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                { "key": "Content-Type", "value": "application/json" }
              ],
              "cookie": [],
              "body": "{\n  \"success\": true,\n  \"data\": {\n    \"code\": \"0\",\n    \"msg\": \"Success\",\n    \"data\": {\n      \"person\": { \"personId\": \"119\" }\n    }\n  }\n}"
            },
            {
              "name": "409 Duplicate personCode",
              "originalRequest": {
                "method": "POST",
                "header": [
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"personCode\": \"EMP20260428001\"\n}"
                },
                "url": {
                  "raw": "{{GS_HOST}}/api/persons",
                  "host": ["{{GS_HOST}}"],
                  "path": ["api", "persons"]
                }
              },
              "status": "Conflict",
              "code": 409,
              "_postman_previewlanguage": "json",
              "header": [
                { "key": "Content-Type", "value": "application/json" }
              ],
              "cookie": [],
              "body": "{\n  \"success\": false,\n  \"data\": {\n    \"code\": \"99999\",\n    \"msg\": \"Person with personCode 'EMP20260428001' already exists\",\n    \"errorDetails\": {\n      \"field\": \"personCode\",\n      \"constraint\": \"UNIQUE\",\n      \"suggestion\": \"Use a unique personCode or call GET /api/persons/code/{code}\"\n    }\n  }\n}"
            }
          ]
        },
        {
          "name": "Look up person by code",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{GS_HOST}}/api/persons/code/EMP20260428001",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "persons", "code", "EMP20260428001"]
            },
            "description": "Look up a person by their personCode. Use before creating to avoid duplicate errors."
          },
          "response": []
        },
        {
          "name": "Update person",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"personGivenName\": \"Mostafa\",\n  \"personFamilyName\": \"Ahmed\",\n  \"phoneNo\": \"+971500000000\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{GS_HOST}}/api/persons/119",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "persons", "119"]
            },
            "description": "Update an existing person."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Visitor management",
      "item": [
        {
          "name": "Register visitor",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"receptionistId\": 1,\n  \"visitStartTime\": \"2026-04-28T13:00:00+03:00\",\n  \"visitEndTime\":   \"2026-04-28T23:59:59+03:00\",\n  \"visitPurposeType\": 1,\n  \"visitorInfoList\": [{\n    \"VisitorInfo\": {\n      \"visitorFamilyName\": \"Guest\",\n      \"visitorGivenName\":  \"Ahmed\",\n      \"gender\": 1\n    }\n  }]\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{GS_HOST}}/api/visitors?version=1",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "visitors"],
              "query": [
                { "key": "version", "value": "1" }
              ]
            },
            "description": "Register a visitor and receive a QR code in the response."
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "POST",
                "header": [
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{}"
                },
                "url": {
                  "raw": "{{GS_HOST}}/api/visitors?version=1",
                  "host": ["{{GS_HOST}}"],
                  "path": ["api", "visitors"],
                  "query": [
                    { "key": "version", "value": "1" }
                  ]
                }
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                { "key": "Content-Type", "value": "application/json" }
              ],
              "cookie": [],
              "body": "{\n  \"success\": true,\n  \"data\": {\n    \"code\": \"0\",\n    \"msg\": \"Success\",\n    \"data\": {\n      \"visitorId\": \"2001\",\n      \"appointRecordId\": \"3001\",\n      \"qrCodeImage\": \"iVBORw0KGgoAAAANSUhEUgAAAGQAAABk...\"\n    }\n  }\n}"
            },
            {
              "name": "400 Invalid datetime range",
              "originalRequest": {
                "method": "POST",
                "header": [
                  { "key": "Content-Type", "value": "application/json" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{}"
                },
                "url": {
                  "raw": "{{GS_HOST}}/api/visitors?version=1",
                  "host": ["{{GS_HOST}}"],
                  "path": ["api", "visitors"],
                  "query": [
                    { "key": "version", "value": "1" }
                  ]
                }
              },
              "status": "Bad Request",
              "code": 400,
              "_postman_previewlanguage": "json",
              "header": [
                { "key": "Content-Type", "value": "application/json" }
              ],
              "cookie": [],
              "body": "{\n  \"success\": false,\n  \"data\": {\n    \"code\": \"40002\",\n    \"msg\": \"Validation failed: Visit datetime range is invalid\",\n    \"errorDetails\": {\n      \"field\": \"visitEndTime\",\n      \"constraint\": \"DATETIME_RANGE\",\n      \"issue\": \"visitEndTime must be after visitStartTime\",\n      \"suggestion\": \"Ensure visitEndTime is greater than visitStartTime\"\n    }\n  }\n}"
            }
          ]
        },
        {
          "name": "Get visitor QR",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "url": {
              "raw": "{{GS_HOST}}/api/visitors/2001/qr",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "visitors", "2001", "qr"]
            },
            "description": "Re-fetch a QR code for an existing visitor."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Access control",
      "item": [
        {
          "name": "Assign access level",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"privilegeGroupId\": \"5\",\n  \"type\": 1\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{GS_HOST}}/api/persons/119/access-level",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "persons", "119", "access-level"]
            },
            "description": "Grant access privileges to a person."
          },
          "response": []
        },
        {
          "name": "List access levels",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{GS_HOST}}/api/access-levels?pageNo=1&pageSize=100",
              "host": ["{{GS_HOST}}"],
              "path": ["api", "access-levels"],
              "query": [
                { "key": "pageNo",   "value": "1"   },
                { "key": "pageSize", "value": "100" }
              ]
            },
            "description": "Fetch all available access levels."
          },
          "response": []
        }
      ]
    }
  ]
}
