{
  "info": {
    "name": "Flight Crew Management API",
    "description": "Complete test collection for Slipstream Mobile Flight Crew Assignment System - 7 Endpoints",
    "version": "1.1.0",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "1. Get Available Crew",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{base_url}}/flight/crews/available.php?crew_role=&exclude_flight_id=&limit=50",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "available.php"],
          "query": [
            {
              "key": "crew_role",
              "value": "",
              "description": "Optional: pilot, cabin_crew"
            },
            {
              "key": "exclude_flight_id",
              "value": "",
              "description": "Optional: Exclude users already assigned to this flight"
            },
            {
              "key": "limit",
              "value": "50",
              "description": "Optional: Number of results (default 50)"
            }
          ]
        },
        "description": "Get list of users available for crew assignment, optionally filtered by role and flight"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/flight/crews/available.php",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "available.php"]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"available_crews\": [\n    {\n      \"user_id\": 10,\n      \"first_name\": \"John\",\n      \"last_name\": \"Smith\",\n      \"email\": \"john.smith@airarabia.com\",\n      \"role\": \"pilot\",\n      \"current_status\": \"available\"\n    }\n  ],\n  \"total\": 1\n}\n"
        }
      ]
    },
    {
      "name": "2. Search Crew Members (Autocomplete)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{base_url}}/flight/crews/search.php?q=Ali&crew_role=cabin_crew&exclude_flight_id=&limit=15",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "search.php"],
          "query": [
            {
              "key": "q",
              "value": "Ali",
              "description": "Required: Search query (1+ character, searches name and email)"
            },
            {
              "key": "crew_role",
              "value": "cabin_crew",
              "description": "Required: Filter by role: pilot or cabin_crew"
            },
            {
              "key": "exclude_flight_id",
              "value": "",
              "description": "Optional: Exclude users already assigned to this flight"
            },
            {
              "key": "limit",
              "value": "15",
              "description": "Optional: Max results (default 15, max 100)"
            }
          ]
        },
        "description": "Real-time search for crew members by name or email with role filtering"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/flight/crews/search.php?q=Ali&crew_role=cabin_crew",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "search.php"],
              "query": [
                {
                  "key": "q",
                  "value": "Ali"
                },
                {
                  "key": "crew_role",
                  "value": "cabin_crew"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"results\": [\n    {\n      \"user_id\": 57,\n      \"display_name\": \"Ali Ali\",\n      \"email\": \"cabin1@airarabia.com\",\n      \"role\": \"cabin\"\n    },\n    {\n      \"user_id\": 60,\n      \"display_name\": \"Hassan Hassan\",\n      \"email\": \"cabin2@airarabia.com\",\n      \"role\": \"cabin\"\n    }\n  ],\n  \"total\": 2\n}\n"
        }
      ]
    },
    {
      "name": "3. Assign Crew to Flight",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"flight_id\": {{flight_id}},\n  \"user_id\": 10,\n  \"crew_role\": \"cabin_supervisor\",\n  \"notes\": \"Timekeeper for this flight\"\n}"
        },
        "url": {
          "raw": "{{base_url}}/flight/crews/assign.php",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "assign.php"]
        },
        "description": "Assign a crew member to a flight with specific role"
      },
      "response": [
        {
          "name": "Success 201",
          "originalRequest": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"flight_id\": 1,\n  \"user_id\": 10,\n  \"crew_role\": \"cabin_supervisor\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/flight/crews/assign.php",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "assign.php"]
            }
          },
          "status": "Created",
          "code": 201,
          "body": "{\n  \"success\": true,\n  \"message\": \"Crew assigned successfully\",\n  \"crew\": {\n    \"flight_crew_id\": 1001,\n    \"flight_id\": 1,\n    \"user_id\": 10,\n    \"user_name\": \"John Smith\",\n    \"crew_role\": \"cabin_supervisor\",\n    \"assigned_at\": \"2026-05-15 08:00:00\",\n    \"is_active\": 1\n  }\n}\n"
        }
      ]
    },
    {
      "name": "4. Get Flight Crew Roster",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{base_url}}/flight/crews/list.php?flight_id={{flight_id}}&include_inactive=false",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "list.php"],
          "query": [
            {
              "key": "flight_id",
              "value": "{{flight_id}}",
              "description": "Required: Flight ID"
            },
            {
              "key": "include_inactive",
              "value": "false",
              "description": "Optional: Include removed crew (default false)"
            }
          ]
        },
        "description": "Get all crew members assigned to a flight"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/flight/crews/list.php?flight_id=1",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "list.php"],
              "query": [
                {
                  "key": "flight_id",
                  "value": "1"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"flight_id\": 1,\n  \"crews\": [\n    {\n      \"flight_crew_id\": 1001,\n      \"flight_id\": 1,\n      \"user_id\": 10,\n      \"user_name\": \"John Smith\",\n      \"crew_role\": \"cabin_supervisor\",\n      \"assigned_at\": \"2026-05-15 08:00:00\",\n      \"is_active\": 1,\n      \"notes\": null\n    }\n  ],\n  \"total_active\": 1,\n  \"total_all\": 1\n}\n"
        }
      ]
    },
    {
      "name": "5. Update Crew Notes",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"notes\": \"Responsible for timekeeper and cabin requests\"\n}"
        },
        "url": {
          "raw": "{{base_url}}/flight/crews/notes.php?flight_crew_id=1001",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "notes.php"],
          "query": [
            {
              "key": "flight_crew_id",
              "value": "1001",
              "description": "Required: Flight crew assignment ID"
            }
          ]
        },
        "description": "Update notes for a crew assignment"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "PUT",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"notes\": \"Test notes\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/flight/crews/notes.php?flight_crew_id=1001",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "notes.php"],
              "query": [
                {
                  "key": "flight_crew_id",
                  "value": "1001"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"message\": \"Notes updated successfully\",\n  \"flight_crew_id\": 1001,\n  \"notes\": \"Test notes\"\n}\n"
        }
      ]
    },
    {
      "name": "6. Remove Crew from Flight",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{base_url}}/flight/crews/remove.php?flight_crew_id=1001&reason=Schedule+change",
          "host": ["{{base_url}}"],
          "path": ["flight", "crews", "remove.php"],
          "query": [
            {
              "key": "flight_crew_id",
              "value": "1001",
              "description": "Required: Flight crew assignment ID"
            },
            {
              "key": "reason",
              "value": "Schedule+change",
              "description": "Optional: Reason for removal"
            }
          ]
        },
        "description": "Remove a crew member from a flight (soft delete)"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "DELETE",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/flight/crews/remove.php?flight_crew_id=1001",
              "host": ["{{base_url}}"],
              "path": ["flight", "crews", "remove.php"],
              "query": [
                {
                  "key": "flight_crew_id",
                  "value": "1001"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"message\": \"Crew member removed from flight\",\n  \"flight_crew_id\": 1001,\n  \"removed_at\": \"2026-05-15 10:30:00\"\n}\n"
        }
      ]
    },
    {
      "name": "7. Get User's Assigned Flights",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{jwt_token}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{base_url}}/user/assigned-flights.php?status=&include_inactive=false",
          "host": ["{{base_url}}"],
          "path": ["user", "assigned-flights.php"],
          "query": [
            {
              "key": "status",
              "value": "",
              "description": "Optional: Filter by status (scheduled, in_progress, completed)"
            },
            {
              "key": "include_inactive",
              "value": "false",
              "description": "Optional: Include inactive assignments (default false)"
            }
          ]
        },
        "description": "Get all flights assigned to current user (from JWT token)"
      },
      "response": [
        {
          "name": "Success 200",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{jwt_token}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/user/assigned-flights.php",
              "host": ["{{base_url}}"],
              "path": ["user", "assigned-flights.php"]
            }
          },
          "status": "OK",
          "code": 200,
          "body": "{\n  \"success\": true,\n  \"user_id\": 10,\n  \"assigned_flights\": [\n    {\n      \"flight_id\": 1,\n      \"flight_number\": \"3O-456\",\n      \"departure\": \"GMMN\",\n      \"arrival\": \"LFPG\",\n      \"scheduled_departure\": \"2026-05-15 10:00:00\",\n      \"my_crew_role\": \"cabin_supervisor\",\n      \"flight_status\": \"scheduled\",\n      \"assigned_at\": \"2026-05-15 08:00:00\"\n    }\n  ],\n  \"total\": 1\n}\n"
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost/slipstream",
      "type": "string"
    },
    {
      "key": "jwt_token",
      "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "type": "string",
      "description": "JWT token from login endpoint - valid for 24 hours"
    },
    {
      "key": "flight_id",
      "value": "1",
      "type": "string",
      "description": "Sample flight ID - change to test with different flights"
    },
    {
      "key": "user_id",
      "value": "10",
      "type": "string",
      "description": "Sample user ID - change to assign different users"
    }
  ]
}
