{
  "info": {
    "name": "Telematics Box Orders — Admin",
    "description": "Superadmin platform surface for the consolidated telematics screen (/commandes-telematique): Commandes (Accept/Reject) and Catalogue produits. Lifecycle is automated — admins only accept or reject newly submitted orders; the detail view is read-only. Base URL points to dev2.dadycar.fr. Run 'Auth — Login' first to populate {{token}} (requires a superadministrator account).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
  },
  "variable": [
    { "key": "base_url", "value": "https://dev2.dadycar.fr" },
    { "key": "token", "value": "" },
    { "key": "order_id", "value": "1" },
    { "key": "product_id", "value": "1" },
    { "key": "discount_id", "value": "1" }
  ],
  "item": [
    {
      "name": "Auth",
      "item": [
        {
          "name": "Auth — Login (sets {{token}})",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "let json = pm.response.json();",
                  "let token = json.token || json.data?.token || json.access_token || json.data?.access_token;",
                  "if (token) { pm.collectionVariables.set('token', token); }"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"superadmin@dadycar.fr\",\n  \"password\": \"password\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/auth/login",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "auth", "login"]
            }
          }
        }
      ]
    },
    {
      "name": "Orders",
      "description": "Admin Accept / Reject only — every other lifecycle transition is automated and not exposed on the admin surface.",
      "item": [
        {
          "name": "Stats",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-box-orders/stats",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-box-orders", "stats"]
            },
            "description": "Returns { total, en_attente, en_cours, installes }."
          }
        },
        {
          "name": "Index (cross-company)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-box-orders?per_page=15",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-box-orders"],
              "query": [
                { "key": "per_page", "value": "15" },
                { "key": "company_id", "value": "", "disabled": true },
                { "key": "status", "value": "", "disabled": true },
                { "key": "search", "value": "", "disabled": true },
                { "key": "date_from", "value": "", "disabled": true },
                { "key": "date_to", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Show (read-only detail)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-box-orders/{{order_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-box-orders", "{{order_id}}"]
            }
          }
        },
        {
          "name": "Accept (submitted → in_progress)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-box-orders/{{order_id}}/accept",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-box-orders", "{{order_id}}", "accept"]
            },
            "description": "Only valid while status = submitted (can_accept). Otherwise 422 { status:false, message }."
          }
        },
        {
          "name": "Reject (submitted → rejected)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": { "mode": "raw", "raw": "{\n  \"reason\": \"Hors zone de couverture\"\n}" },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-box-orders/{{order_id}}/reject",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-box-orders", "{{order_id}}", "reject"]
            },
            "description": "Only valid while status = submitted (can_reject). Body: { reason } (optional)."
          }
        }
      ]
    },
    {
      "name": "Catalog — Products",
      "description": "Catalogue produits. Products are the box catalog reshaped (sku = code) with category, free-form needs_covered strings, and key/value specifications.",
      "item": [
        {
          "name": "Stats",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/stats",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "stats"]
            },
            "description": "Returns { products, active, out_of_stock, stock_value } (stock_value = Σ price × stock_quantity)."
          }
        },
        {
          "name": "Needs — Suggestions",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/needs-suggestions",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "needs-suggestions"]
            },
            "description": "Master suggestion list (FR label strings) for the needs toggle pills."
          }
        },
        {
          "name": "Products — List",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/products?per_page=15",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "products"],
              "query": [
                { "key": "per_page", "value": "15" },
                { "key": "search", "value": "", "disabled": true },
                { "key": "category", "value": "boitier", "disabled": true }
              ]
            },
            "description": "Filters: search (sku/name/description), category (boitier|module|capteur|accessoire), plus pagination."
          }
        },
        {
          "name": "Product — Show",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/products/{{product_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "products", "{{product_id}}"]
            }
          }
        },
        {
          "name": "Product — Create",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sku\": \"TLT-FMC650\",\n  \"category\": \"boitier\",\n  \"name\": \"Teltonika FMC650\",\n  \"description\": \"Boîtier filaire 4G LTE Cat 4 haut débit.\",\n  \"price\": 95,\n  \"stock_quantity\": 25,\n  \"is_active\": true,\n  \"needs_covered\": [\n    \"Géolocalisation temps réel\",\n    \"Éco-conduite\"\n  ],\n  \"specifications\": [\n    { \"key\": \"Connectivité\", \"value\": \"4G LTE Cat 4\" },\n    { \"key\": \"Alimentation\", \"value\": \"Filaire 10–30V\" },\n    { \"key\": \"Garantie\", \"value\": \"24 mois\" }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/products",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "products"]
            }
          }
        },
        {
          "name": "Product — Update",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sku\": \"obd\",\n  \"category\": \"boitier\",\n  \"name\": \"Teltonika FMC003\",\n  \"description\": \"Boîtier OBD-II 4G plug & play.\",\n  \"price\": 64,\n  \"stock_quantity\": 120,\n  \"is_active\": true,\n  \"needs_covered\": [\n    \"Géolocalisation temps réel\",\n    \"Odomètre exact\",\n    \"Éco-conduite\"\n  ],\n  \"specifications\": [\n    { \"key\": \"Connectivité\", \"value\": \"4G LTE Cat 1\" },\n    { \"key\": \"GNSS\", \"value\": \"GPS, GLONASS, Galileo\" }\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/products/{{product_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "products", "{{product_id}}"]
            }
          }
        },
        {
          "name": "Product — Delete",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-catalog/products/{{product_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-catalog", "products", "{{product_id}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Pricing Settings (retained — not used by the new admin UI)",
      "description": "These endpoints still exist and back server-side price computation, but the new admin prototype no longer manages pricing. Kept here for completeness.",
      "item": [
        {
          "name": "Settings — Show",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-settings",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-settings"]
            }
          }
        },
        {
          "name": "Settings — Update",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"subscription_per_box\": 9,\n  \"delivery_per_site\": 12,\n  \"vat_rate\": 20,\n  \"reference_prefix\": \"TLM\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-settings",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-settings"]
            }
          }
        },
        {
          "name": "Volume Discount — Create",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"min_units\": 100,\n  \"discount_type\": \"percent\",\n  \"discount_value\": 5,\n  \"is_active\": true,\n  \"sort_order\": 1\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-settings/volume-discounts",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-settings", "volume-discounts"]
            }
          }
        },
        {
          "name": "Volume Discount — Update",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"min_units\": 50,\n  \"discount_type\": \"fixed\",\n  \"discount_value\": 150,\n  \"is_active\": true,\n  \"sort_order\": 0\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-settings/volume-discounts/{{discount_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-settings", "volume-discounts", "{{discount_id}}"]
            }
          }
        },
        {
          "name": "Volume Discount — Delete",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/admin/telematics-settings/volume-discounts/{{discount_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "admin", "telematics-settings", "volume-discounts", "{{discount_id}}"]
            }
          }
        }
      ]
    }
  ]
}
