{
  "info": {
    "name": "ecommerce.sa Commerce API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "REST + GraphQL for the ecommerce.sa Commerce OS."
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:8080" },
    { "key": "tenant", "value": "demo" },
    { "key": "token", "value": "ecsa_xxx" }
  ],
  "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }] },
  "item": [
    {
      "name": "Storefront",
      "item": [
        { "name": "Tenant info", "request": { "method": "GET", "url": "{{baseUrl}}/api/me?tenant={{tenant}}", "auth": { "type": "noauth" } } },
        { "name": "List products", "request": { "method": "GET", "url": "{{baseUrl}}/api/products?tenant={{tenant}}", "auth": { "type": "noauth" } } },
        { "name": "Checkout", "request": { "method": "POST", "auth": { "type": "noauth" },
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "url": "{{baseUrl}}/api/checkout?tenant={{tenant}}",
          "body": { "mode": "raw", "raw": "{\n  \"items\": [{ \"variant_id\": \"VARIANT_ID\", \"quantity\": 1 }],\n  \"method\": \"mada\",\n  \"customer\": { \"name\": \"Sam\", \"phone\": \"0500000000\" }\n}" } } }
      ]
    },
    {
      "name": "Admin (Bearer)",
      "item": [
        { "name": "Me", "request": { "method": "GET", "url": "{{baseUrl}}/api/admin/me" } },
        { "name": "List products", "request": { "method": "GET", "url": "{{baseUrl}}/api/admin/products" } },
        { "name": "Create product", "request": { "method": "POST",
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "url": "{{baseUrl}}/api/admin/products",
          "body": { "mode": "raw", "raw": "{\n  \"name\": \"New product\",\n  \"price\": 14900,\n  \"status\": \"active\"\n}" } } },
        { "name": "Orders", "request": { "method": "GET", "url": "{{baseUrl}}/api/admin/orders" } },
        { "name": "KPIs", "request": { "method": "GET", "url": "{{baseUrl}}/api/admin/analytics/kpis" } },
        { "name": "GraphQL", "request": { "method": "POST",
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "url": "{{baseUrl}}/api/admin/graphql",
          "body": { "mode": "raw", "raw": "{\n  \"query\": \"{ products(limit: 5) { id name price } }\"\n}" } } }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        { "name": "Inbound (provider → us)", "request": { "method": "POST", "auth": { "type": "noauth" },
          "header": [{ "key": "Content-Type", "value": "application/json" }, { "key": "X-Signature", "value": "sha256=<hmac>" }],
          "url": "{{baseUrl}}/api/webhooks/in/{{tenant}}/moyasar",
          "body": { "mode": "raw", "raw": "{\n  \"event\": \"payment.paid\",\n  \"intent_id\": \"pi_1\"\n}" } } }
      ]
    }
  ]
}
