{
  "info": {
    "name": "Commandes — Fleet",
    "description": "Vehicle order wizard (Collaborateur → Policy → Véhicules → Livraison → Soumettre) + multi-step approval workflow. Base URL: dev2.dadycar.fr. Set {{token}} to a valid bearer; {{commande_id}}, {{collaborator_id}}, {{approver_id}}, {{site_id}} per environment.",
    "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": "commande_id", "value": "1" },
    { "key": "collaborator_id", "value": "1" },
    { "key": "car_policy_id", "value": "1" },
    { "key": "approver_id", "value": "1" },
    { "key": "site_id", "value": "1" },
    { "key": "instance_id", "value": "012ae3b3-0000-0000-ffff-ffffffffffff" }
  ],
  "item": [
    {
      "name": "List & Detail",
      "item": [
        {
          "name": "Commandes — List",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/list?per_page=10&sort_by=date&sort_dir=desc",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "list"],
              "query": [
                { "key": "per_page", "value": "10" },
                { "key": "sort_by", "value": "date" },
                { "key": "sort_dir", "value": "desc" },
                { "key": "status_filter", "value": "pending_approval", "disabled": true },
                { "key": "search_query", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Commandes — KPIs",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/kpis",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "kpis"]
            }
          }
        },
        {
          "name": "Commandes — Export CSV",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/export",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "export"]
            }
          }
        },
        {
          "name": "Commande — Detail (Vue d'ensemble)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/show/{{commande_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "show", "{{commande_id}}"]
            }
          }
        },
        {
          "name": "Commande — Historique (Timeline)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/history",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "history"],
              "query": [
                { "key": "event_type_filter", "value": "approved", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Commande — Historique PDF",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/history/pdf",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "history", "pdf"]
            }
          }
        },
        {
          "name": "Commande — PDF",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/pdf",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "pdf"]
            }
          }
        }
      ]
    },
    {
      "name": "Filter / Wizard Options",
      "item": [
        {
          "name": "Options — Statuses",
          "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/fleet/commandes/options/statuses", "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "options", "statuses"] } }
        },
        {
          "name": "Options — Colors (Livraison wizard)",
          "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/fleet/commandes/options/colors", "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "options", "colors"] } }
        },
        {
          "name": "Options — Delivery Sites",
          "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/fleet/commandes/options/delivery-sites", "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "options", "delivery-sites"] } }
        },
        {
          "name": "Options — Sorts",
          "request": { "method": "GET", "header": [{ "key": "Accept", "value": "application/json" }],
            "url": { "raw": "{{base_url}}/api/v1/fleet/commandes/options/sorts", "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "options", "sorts"] } }
        }
      ]
    },
    {
      "name": "Wizard",
      "item": [
        {
          "name": "Step 1 — Collaborators search (active policy)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/collaborators?search=",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "collaborators"],
              "query": [{ "key": "search", "value": "" }]
            }
          }
        },
        {
          "name": "Step 1 — Create draft (collaborator + policy)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"collaborator_id\": {{collaborator_id}},\n  \"car_policy_id\": {{car_policy_id}}\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/store",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "store"]
            }
          }
        },
        {
          "name": "Step 2 — Applicable Policy (read-only)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/applicable-policy",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "applicable-policy"]
            }
          }
        },
        {
          "name": "Step 2 — Derogation toggle",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"is_derogation\": true,\n  \"derogation_reason\": \"Besoin d'un véhicule avec grande autonomie pour les déplacements terrain\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/derogation",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "derogation"]
            }
          }
        },
        {
          "name": "Step 3 — Catalogue (compliant vs policy)",
          "request": {
            "method": "GET",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/catalogue-vehicles?per_page=12&compliant_only=true",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "catalogue-vehicles"],
              "query": [
                { "key": "per_page", "value": "12" },
                { "key": "compliant_only", "value": "true" },
                { "key": "search", "value": "", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Step 3 — Set vehicles (target + alternatives)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"vehicles\": [\n    {\"jato_instance_id\": \"{{instance_id}}\", \"label\": \"Tesla Model 3 Long Range\", \"role\": \"target\", \"tco\": 926, \"co2\": 0, \"price\": 52990, \"is_policy_compliant\": true},\n    {\"jato_instance_id\": \"012ae3b3-0000-0000-ffff-fffffffffffe\", \"label\": \"Peugeot e-208 GT\", \"role\": \"alternative\", \"tco\": 712, \"co2\": 0, \"price\": 36490, \"is_policy_compliant\": true}\n  ]\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/vehicles",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "vehicles"]
            }
          }
        },
        {
          "name": "Step 4 — Delivery (date / site / coloris / commentaire)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"delivery_date\": \"2026-09-01\",\n  \"delivery_site_id\": {{site_id}},\n  \"delivery_address\": null,\n  \"color\": \"Gris Métallisé\",\n  \"lessor_comment\": \"Préférer livraison matin\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/delivery",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "delivery"]
            }
          }
        },
        {
          "name": "Step 5 — Submit (start workflow)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/submit",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "submit"]
            }
          }
        }
      ]
    },
    {
      "name": "Workflow Actions",
      "item": [
        {
          "name": "Approve current step",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"comment\": \"OK pour validation\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/approve",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "approve"]
            }
          }
        },
        {
          "name": "Refuse current step",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"comment\": \"Budget dépassé\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/refuse",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "refuse"]
            }
          }
        },
        {
          "name": "Reassign current step",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" },
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"approver_id\": {{approver_id}}\n}"
            },
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/reassign",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "reassign"]
            }
          }
        },
        {
          "name": "Launch AO (approved commandes only — bridge to AO flow)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/launch-ao",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "launch-ao"]
            }
          }
        },
        {
          "name": "Cancel commande",
          "request": {
            "method": "POST",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/{{commande_id}}/cancel",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "{{commande_id}}", "cancel"]
            }
          }
        },
        {
          "name": "Delete commande",
          "request": {
            "method": "DELETE",
            "header": [{ "key": "Accept", "value": "application/json" }],
            "url": {
              "raw": "{{base_url}}/api/v1/fleet/commandes/delete/{{commande_id}}",
              "host": ["{{base_url}}"],
              "path": ["api", "v1", "fleet", "commandes", "delete", "{{commande_id}}"]
            }
          }
        }
      ]
    }
  ]
}
