{
  "info": {
    "_postman_id": "f2a6c6b1-6f3f-4d8a-9b0e-1c1c8a1a0a01",
    "name": "Sitepat Turboly Webhooks (DEV)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Service Reservation Webhook",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const secret = pm.environment.get('webhookSecret');",
              "const body = pm.request.body && pm.request.body.raw ? pm.request.body.raw : '';",
              "const sig = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);",
              "pm.variables.set('computedSignature', sig);",
              "pm.variables.set('timestamp', new Date().toISOString());"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Turboly-Secret", "value": "{{webhookSecret}}" },
          { "key": "X-Turboly-Signature", "value": "sha256={{computedSignature}}" },
          { "key": "X-Timestamp", "value": "{{timestamp}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event\": \"service_reservation.confirmed\",\n  \"reservation\": {\n    \"id\": 12345,\n    \"status\": \"confirmed\",\n    \"customer_id\": 2,\n    \"vehicle_id\": 759675,\n    \"store_id\": 3385,\n    \"scheduled_at\": \"2025-10-29T08:00:00Z\",\n    \"notes\": \"example\"\n  }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/webhooks/turboly/service/reservations",
          "host": ["{{baseUrl}}"],
          "path": ["api","v1","webhooks","turboly","service","reservations"]
        }
      }
    },
    {
      "name": "Service Order Webhook",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const secret = pm.environment.get('webhookSecret');",
              "const body = pm.request.body && pm.request.body.raw ? pm.request.body.raw : '';",
              "const sig = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);",
              "pm.variables.set('computedSignature', sig);",
              "pm.variables.set('timestamp', new Date().toISOString());"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Turboly-Secret", "value": "{{webhookSecret}}" },
          { "key": "X-Turboly-Signature", "value": "sha256={{computedSignature}}" },
          { "key": "X-Timestamp", "value": "{{timestamp}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event\": \"service_order.approved\",\n  \"service_order\": {\n    \"id\": 55555,\n    \"reservation_id\": 12345,\n    \"status\": \"approved\",\n    \"customer_id\": 2,\n    \"store_id\": 3385,\n    \"updated_at\": \"2025-10-29T09:00:00Z\"\n  }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/webhooks/turboly/service/orders",
          "host": ["{{baseUrl}}"],
          "path": ["api","v1","webhooks","turboly","service","orders"]
        }
      }
    },
    {
      "name": "Work Order Webhook",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const secret = pm.environment.get('webhookSecret');",
              "const body = pm.request.body && pm.request.body.raw ? pm.request.body.raw : '';",
              "const sig = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);",
              "pm.variables.set('computedSignature', sig);",
              "pm.variables.set('timestamp', new Date().toISOString());"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Turboly-Secret", "value": "{{webhookSecret}}" },
          { "key": "X-Turboly-Signature", "value": "sha256={{computedSignature}}" },
          { "key": "X-Timestamp", "value": "{{timestamp}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event\": \"work_order.status_changed\",\n  \"work_order\": {\n    \"id\": 77777,\n    \"service_order_id\": 55555,\n    \"status\": \"in_progress\",\n    \"completed_tasks\": [\n      {\n        \"task_id\": 1,\n        \"status\": \"done\",\n        \"completed_at\": \"2025-10-29T09:30:00Z\"\n      }\n    ]\n  }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/webhooks/turboly/service/work-orders",
          "host": ["{{baseUrl}}"],
          "path": ["api","v1","webhooks","turboly","service","work-orders"]
        }
      }
    },
    {
      "name": "Service Invoice Webhook",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const secret = pm.environment.get('webhookSecret');",
              "const body = pm.request.body && pm.request.body.raw ? pm.request.body.raw : '';",
              "const sig = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);",
              "pm.variables.set('computedSignature', sig);",
              "pm.variables.set('timestamp', new Date().toISOString());"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Turboly-Secret", "value": "{{webhookSecret}}" },
          { "key": "X-Turboly-Signature", "value": "sha256={{computedSignature}}" },
          { "key": "X-Timestamp", "value": "{{timestamp}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event\": \"service_invoice.completed\",\n  \"service_invoice\": {\n    \"id\": 99999,\n    \"service_order_id\": 55555,\n    \"amount\": 250000,\n    \"status\": \"completed\",\n    \"completed_at\": \"2025-10-29T10:00:00Z\"\n  }\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/webhooks/turboly/service/invoices",
          "host": ["{{baseUrl}}"],
          "path": ["api","v1","webhooks","turboly","service","invoices"]
        }
      }
    }
  ]
}
