{
  "info": {
    "name": "Gear — Vehicle Search & Booking",
    "description": "Vehicle listing, availability, pricing (checkout), and location APIs.\n\nSet collection variables:\n- `baseUrl` — e.g. https://your-domain.com\n- `apiPrefix` — e.g. /Gear/api\n- `authToken` — from User Login\n- `carId` — MongoDB car _id",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://your-domain.com" },
    { "key": "apiPrefix", "value": "/Gear/api" },
    { "key": "authToken", "value": "" },
    { "key": "carId", "value": "" }
  ],
  "item": [
    {
      "name": "Auth (get token)",
      "item": [
        {
          "name": "User Login",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\",\n  \"deviceToken\": \"optional-fcm-token\"\n}"
            },
            "url": "{{baseUrl}}{{apiPrefix}}/login"
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const j = pm.response.json();",
                  "if (j.data && j.data.auth_token) {",
                  "  pm.collectionVariables.set('authToken', j.data.auth_token);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Public — Vehicle listing (Web)",
      "item": [
        {
          "name": "GET getCars (search & filters)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}", "description": "Optional — sets is_favourite when logged in" }
            ],
            "url": {
              "raw": "{{baseUrl}}{{apiPrefix}}/getCars?page=1&limit=12&lat=25.2048&lng=55.2708&location=Dubai&search=camry&from_date=2026-10-10&to_date=2026-10-12&from_time=10:00&to_time=18:00&min_price=100&max_price=500&car_type_id=&car_type_ids=TYPE_ID_1,TYPE_ID_2&brand_id=&min_rating=4&sort_by=recommended&featured=false",
              "host": ["{{baseUrl}}{{apiPrefix}}"],
              "path": ["getCars"],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "limit", "value": "12", "description": "max 50" },
                { "key": "lat", "value": "25.2048", "description": "User latitude — enables distance sort & 100km radius" },
                { "key": "lng", "value": "55.2708" },
                { "key": "location", "value": "Dubai", "description": "Regex match on car.location" },
                { "key": "search", "value": "camry", "description": "title / title_ar / description" },
                { "key": "from_date", "value": "2026-10-10", "description": "YYYY-MM-DD — availability filter" },
                { "key": "to_date", "value": "2026-10-12" },
                { "key": "from_time", "value": "10:00" },
                { "key": "to_time", "value": "18:00" },
                { "key": "min_price", "value": "100" },
                { "key": "max_price", "value": "500" },
                { "key": "car_type_id", "value": "", "disabled": true },
                { "key": "car_type_ids", "value": "TYPE_ID_1,TYPE_ID_2", "description": "Comma-separated ObjectIds" },
                { "key": "brand_id", "value": "" },
                { "key": "min_rating", "value": "4" },
                { "key": "sort_by", "value": "recommended", "description": "recommended | price_low | price_high | rating | distance | newest" },
                { "key": "featured", "value": "false", "description": "true | 1 | yes | on" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "App — Vehicle listing (Authenticated)",
      "item": [
        {
          "name": "GET getAvailableCars",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}" },
              { "key": "language", "value": "en" }
            ],
            "url": {
              "raw": "{{baseUrl}}{{apiPrefix}}/getAvailableCars?page=1&from_date=2026-10-10&to_date=2026-10-12&from_time=10:00&to_time=18:00&lat=25.2048&lng=55.2708&min_price=100&max_price=500&car_type_id=&brand_id=",
              "host": ["{{baseUrl}}{{apiPrefix}}"],
              "path": ["getAvailableCars"],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "from_date", "value": "2026-10-10", "description": "Required for availability gate" },
                { "key": "to_date", "value": "2026-10-12" },
                { "key": "from_time", "value": "10:00" },
                { "key": "to_time", "value": "18:00" },
                { "key": "lat", "value": "25.2048", "description": "If lat>0, sort by distance, ~100km radius" },
                { "key": "lng", "value": "55.2708" },
                { "key": "min_price", "value": "100", "description": "Both min and max required to apply price filter" },
                { "key": "max_price", "value": "500" },
                { "key": "car_type_id", "value": "" },
                { "key": "brand_id", "value": "" }
              ]
            }
          }
        },
        {
          "name": "GET getCarDetails",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}" },
              { "key": "language", "value": "en" }
            ],
            "url": {
              "raw": "{{baseUrl}}{{apiPrefix}}/getCarDetails?car_id={{carId}}",
              "host": ["{{baseUrl}}{{apiPrefix}}"],
              "path": ["getCarDetails"],
              "query": [{ "key": "car_id", "value": "{{carId}}" }]
            }
          }
        },
        {
          "name": "GET getDropdownData (filters catalog)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Authorization", "value": "Bearer {{authToken}}" }],
            "url": "{{baseUrl}}{{apiPrefix}}/getDropdownData"
          }
        }
      ]
    },
    {
      "name": "Availability",
      "item": [
        {
          "name": "POST checkIsCarAvailable",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"car_id\": \"{{carId}}\",\n  \"start_date\": \"2026-10-10\",\n  \"start_time\": \"10:00\",\n  \"end_date\": \"2026-10-12\",\n  \"end_time\": \"18:00\"\n}"
            },
            "url": "{{baseUrl}}{{apiPrefix}}/checkIsCarAvailable"
          }
        }
      ]
    },
    {
      "name": "Pricing",
      "item": [
        {
          "name": "POST checkout (rental total calculation)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"car_id\": \"{{carId}}\",\n  \"start_date\": \"2026-10-10\",\n  \"start_time\": \"10:00\",\n  \"end_date\": \"2026-10-12\",\n  \"end_time\": \"18:00\",\n  \"promo_code\": \"SAVE10\"\n}"
            },
            "url": "{{baseUrl}}{{apiPrefix}}/checkout"
          }
        }
      ]
    },
    {
      "name": "Locations",
      "item": [
        {
          "name": "GET getDefaultLocations (grouped pickup areas)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{authToken}}" },
              { "key": "language", "value": "en" }
            ],
            "url": "{{baseUrl}}{{apiPrefix}}/getDefaultLocations"
          }
        }
      ]
    }
  ]
}
