{
  "info": {
    "name": "AutoHub - Super Admin (Full)",
    "description": "جميع APIs السوبر أدمن مع كل المفاتيح جاهزة. شغّل Login أولاً ثم باقي الطلبات.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "http://127.0.0.1:8000" },
    { "key": "token", "value": "" },

    { "key": "_searchText", "value": "customer" },
    { "key": "_orderStatus", "value": "pending" },
    { "key": "_orderId", "value": "1" },
    { "key": "_driverId", "value": "1" },
    { "key": "_customerId", "value": "1" },
    { "key": "_storeId", "value": "1" },
    { "key": "_productId", "value": "1" },
    { "key": "_promotionId", "value": "1" },
    { "key": "_roleId", "value": "1" },
    { "key": "_targetSuperAdminUserId", "value": "1" },
    { "key": "_permissionId1", "value": "1" },
    { "key": "_permissionId2", "value": "2" },
    { "key": "_permissionId3", "value": "3" },
    { "key": "_storeIdFilterPromotions", "value": "1" },
    { "key": "_driversActiveOnly", "value": "1" }
  ],
  "item": [
    {
      "name": "0 - Auth (Super Admin)",
      "item": [
        {
          "name": "Login Super Admin",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "var j = {}; try { j = pm.response.json(); } catch (e) {}",
                  "if (j && j.data && j.data.token) { pm.collectionVariables.set('token', j.data.token); }"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"super_admin\",\n  \"password\": \"password\",\n  \"user_type\": \"super_admin\",\n  \"guest_token\": null\n}"
            },
            "url": "{{baseUrl}}/api/auth/login"
          }
        }
      ]
    },
    {
      "name": "1 - Orders",
      "item": [
        {
          "name": "Orders By Status (last 10 each)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/orders/by-status-latest"
          }
        },
        {
          "name": "List Orders",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/orders?search={{_searchText}}&status={{_orderStatus}}",
              "host": ["{{baseUrl}}"],
              "path": ["api", "super_admin", "orders"],
              "query": [
                { "key": "search", "value": "{{_searchText}}", "description": "بحث: رقم الطلب (أرقام فقط) أو جزء من username/phone" },
                { "key": "status", "value": "{{_orderStatus}}", "description": "pending|driver_accept|store_accept|packing|out_for_delivery|rejected|completed أو فارغ" }
              ]
            }
          }
        },
        {
          "name": "Order Details",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/orders/{{_orderId}}"
          }
        },
        {
          "name": "Redispatch Order",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"driver_id\": {{_driverId}}\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/orders/{{_orderId}}/redispatch"
          }
        }
      ]
    },
    {
      "name": "2 - Customers",
      "item": [
        {
          "name": "List Customers",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/customers?search={{_searchText}}",
              "query": [
                { "key": "search", "value": "{{_searchText}}", "description": "username / phone / email" }
              ]
            }
          }
        },
        {
          "name": "Customer Details",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/customers/{{_customerId}}"
          }
        },
        {
          "name": "Customer Orders History",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/customers/{{_customerId}}/orders"
          }
        },
        {
          "name": "Update Customer",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"customer_1\",\n  \"phone\": \"520000001\",\n  \"email\": \"customer_1@example.com\",\n  \"birthday\": \"1995-06-15\",\n  \"gender\": \"male\",\n  \"customer_status\": \"active\"\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/customers/{{_customerId}}"
          }
        }
      ]
    },
    {
      "name": "3 - Merchants (Stores)",
      "item": [
        {
          "name": "List Stores",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/merchants/stores?search={{_searchText}}",
              "query": [
                { "key": "search", "value": "{{_searchText}}", "description": "اسم متجر / مدينة / username أو phone المالك" }
              ]
            }
          }
        },
        {
          "name": "Create Store",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"New Merchant Store\",\n  \"owner_username\": \"new_store_owner\",\n  \"owner_password\": \"password\",\n  \"owner_phone\": \"599888777\",\n  \"owner_email\": \"new_owner@example.com\",\n  \"logo\": \"https://picsum.photos/seed/store_logo/200/200\",\n  \"cover_image\": \"https://picsum.photos/seed/store_cover/900/300\",\n  \"description\": \"وصف المتجر\",\n  \"city\": \"Riyadh\",\n  \"open_until\": \"11 PM\",\n  \"is_active\": true,\n  \"location\": \"Riyadh - District\",\n  \"location_lat\": 24.7136,\n  \"location_lng\": 46.6753,\n  \"address_details\": \"Building 1 - Floor 2\",\n  \"contact_email\": \"contact@store.example.com\",\n  \"contact_phone\": \"501234567\",\n  \"operating_from\": \"09:00\",\n  \"operating_to\": \"22:30\",\n  \"off_days\": [\"Friday\", \"Saturday\"],\n  \"is_open_24_hours\": false,\n  \"support_phone\": \"800123456\",\n  \"about_text\": \"نبذة عن المتجر\",\n  \"terms_text\": \"الشروط والأحكام\",\n  \"specialization_brand_ids\": [1, 2, 3],\n  \"auto_accept_orders\": false\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores"
          }
        },
        {
          "name": "Show Store",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}"
          }
        },
        {
          "name": "Update Store",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Store Name Updated\",\n  \"logo\": \"https://picsum.photos/seed/logo2/200/200\",\n  \"cover_image\": \"https://picsum.photos/seed/cover2/900/300\",\n  \"description\": \"وصف محدّث\",\n  \"city\": \"Jeddah\",\n  \"open_until\": \"12 AM\",\n  \"is_active\": true,\n  \"location\": \"Jeddah - Area\",\n  \"location_lat\": 21.4858,\n  \"location_lng\": 39.1925,\n  \"address_details\": \"عنوان تفصيلي\",\n  \"contact_email\": \"newcontact@store.example.com\",\n  \"contact_phone\": \"502222333\",\n  \"support_phone\": \"800999888\",\n  \"about_text\": \"عن المتجر\",\n  \"terms_text\": \"الشروط\",\n  \"specialization_brand_ids\": [1, 2]\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}"
          }
        },
        {
          "name": "Update Store Hours",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"operating_from\": \"08:30\",\n  \"operating_to\": \"23:45\",\n  \"off_days\": [\"Friday\"],\n  \"is_open_24_hours\": false\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/hours"
          }
        },
        {
          "name": "Update Auto Accept",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"auto_accept_orders\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/auto-accept"
          }
        },
        {
          "name": "Update Owner Credentials",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"store_owner_updated\",\n  \"password\": \"newpassword123\"\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/owner-credentials"
          }
        },
        {
          "name": "List Store Products",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/products?search={{_searchText}}",
              "query": [
                { "key": "search", "value": "{{_searchText}}", "description": "بحث على name / name_ar / name_en" }
              ]
            }
          }
        },
        {
          "name": "Update Store Product",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Product display name\",\n  \"name_ar\": \"اسم المنتج بالعربي\",\n  \"name_en\": \"Product Name EN\",\n  \"description\": \"وصف قصير\",\n  \"description_ar\": \"وصف عربي\",\n  \"description_en\": \"English description\",\n  \"status\": true,\n  \"quantity\": 25,\n  \"price\": 149.99,\n  \"queue\": 5,\n  \"tags\": [\"oil\", \"filter\", \"oem\"],\n  \"features\": [{\"key\": \"warranty\", \"value\": \"1 year\"}, {\"key\": \"origin\", \"value\": \"Germany\"}],\n  \"category_ids\": [1, 2],\n  \"dynamic_label_ids\": [1, 2],\n  \"image_urls\": [\n    \"https://example.com/product/1.jpg\",\n    \"https://example.com/product/2.jpg\"\n  ],\n  \"options\": [\n    { \"option_name\": \"Size\", \"option_value\": \"L\" },\n    { \"option_name\": \"Color\", \"option_value\": \"Black\" }\n  ],\n  \"vehicle_fits\": [\n    {\n      \"vehicle_make\": \"Toyota\",\n      \"vehicle_model\": \"Camry\",\n      \"vehicle_trim\": \"LE\",\n      \"year_from\": 2019,\n      \"year_to\": 2024\n    }\n  ]\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/products/{{_productId}}"
          }
        },
        {
          "name": "List Store Orders",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/merchants/stores/{{_storeId}}/orders"
          }
        }
      ]
    },
    {
      "name": "4 - Promotions (Vouchers)",
      "item": [
        {
          "name": "List Promotions",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/promotions?store_id={{_storeIdFilterPromotions}}",
              "query": [
                { "key": "store_id", "value": "{{_storeIdFilterPromotions}}", "description": "اختياري: تصفية حسب المتجر" }
              ]
            }
          }
        },
        {
          "name": "Create Promotion",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"store_id\": {{_storeId}},\n  \"voucher_value\": 50.5,\n  \"apply_on\": \"store\",\n  \"category_id\": null,\n  \"product_id\": null,\n  \"starts_at\": \"2026-03-01 00:00:00\",\n  \"ends_at\": \"2026-12-31 23:59:59\",\n  \"covered_by\": \"store\",\n  \"is_active\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/promotions"
          }
        },
        {
          "name": "Create Promotion (category + item examples)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"store_id\": {{_storeId}},\n  \"voucher_value\": 20,\n  \"apply_on\": \"category\",\n  \"category_id\": 1,\n  \"product_id\": null,\n  \"starts_at\": \"2026-04-01 00:00:00\",\n  \"ends_at\": \"2026-06-30 23:59:59\",\n  \"covered_by\": \"company\",\n  \"is_active\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/promotions"
          }
        },
        {
          "name": "Create Promotion (item)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"store_id\": {{_storeId}},\n  \"voucher_value\": 5,\n  \"apply_on\": \"item\",\n  \"category_id\": null,\n  \"product_id\": {{_productId}},\n  \"starts_at\": \"2026-05-01 10:00:00\",\n  \"ends_at\": \"2026-05-31 23:00:00\",\n  \"covered_by\": \"store\",\n  \"is_active\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/promotions"
          }
        },
        {
          "name": "Update Promotion",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"voucher_value\": 99.99,\n  \"apply_on\": \"store\",\n  \"category_id\": null,\n  \"product_id\": null,\n  \"starts_at\": \"2026-01-01 00:00:00\",\n  \"ends_at\": \"2027-01-01 00:00:00\",\n  \"covered_by\": \"company\",\n  \"is_active\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/promotions/{{_promotionId}}"
          }
        },
        {
          "name": "Delete Promotion",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/promotions/{{_promotionId}}"
          }
        }
      ]
    },
    {
      "name": "5 - Roles",
      "item": [
        {
          "name": "Permissions Tree",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/roles/permissions-tree"
          }
        },
        {
          "name": "List Roles",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/roles"
          }
        },
        {
          "name": "Create Role",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Operations Manager\"\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/roles"
          }
        },
        {
          "name": "Assign Role To Super Admin User",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"role_id\": {{_roleId}},\n  \"user_id\": {{_targetSuperAdminUserId}}\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/roles/assign"
          }
        },
        {
          "name": "Sync Role Permissions",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"permission_ids\": [{{_permissionId1}}, {{_permissionId2}}, {{_permissionId3}}]\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/roles/{{_roleId}}/permissions"
          }
        }
      ]
    },
    {
      "name": "6 - Drivers",
      "item": [
        {
          "name": "List Drivers",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/super_admin/drivers?active_only={{_driversActiveOnly}}",
              "query": [
                { "key": "active_only", "value": "{{_driversActiveOnly}}", "description": "أي قيمة truthy (مثلاً 1) تفلتر النشطين فقط" }
              ]
            }
          }
        },
        {
          "name": "Create Driver",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Driver Full Name\",\n  \"phone\": \"511000111\",\n  \"email\": \"driver@example.com\",\n  \"is_active\": true\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/drivers"
          }
        },
        {
          "name": "Update Driver",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Driver Name Updated\",\n  \"phone\": \"522000333\",\n  \"email\": \"driver_updated@example.com\",\n  \"is_active\": false\n}"
            },
            "url": "{{baseUrl}}/api/super_admin/drivers/{{_driverId}}"
          }
        },
        {
          "name": "Delete Driver",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Authorization", "value": "Bearer {{token}}" }
            ],
            "url": "{{baseUrl}}/api/super_admin/drivers/{{_driverId}}"
          }
        }
      ]
    }
  ]
}
