{
  "name": "Regiondo Block Seats Webhook",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "block-seats",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const crypto = require('crypto');\n\n// Eure Regiondo Keys (wie im Pull-Workflow)\nconst publicKey = 'MO43f21d011626';\nconst privateKey = '43f21d0f4ba8f05b111626d551fd8509160d0';\nconst timestamp = Math.floor(Date.now() / 1000).toString();\n\n// Daten vom Webhook \u00fcbernehmen\n// Erwartet im Body z.B.: { \"eventId\": \"12345\", \"quantity\": 2, \"category\": \"Kat B\" }\nconst inputData = $input.item.json.body || {};\n\n// Query-String generieren (Hier musst du evtl. anpassen, je nachdem, was Regiondo erwartet)\n// Beispiel: event_id=12345&quantity=2\nconst queryString = `event_id=${inputData.eventId || ''}&quantity=${inputData.quantity || ''}`;\n\n// HMAC Hash erstellen\nconst stringToHash = timestamp + publicKey + queryString;\nconst hash = crypto.createHmac('sha256', privateKey).update(stringToHash).digest('hex');\n\nreturn {\n  json: {\n    ...inputData,\n    'X-API-ID': publicKey,\n    'X-API-TIME': timestamp,\n    'X-API-HASH': hash,\n    'queryString': queryString\n  }\n};"
      },
      "name": "Generate Regiondo Auth HMAC",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        400,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.regiondo.com/v1/bookings",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-ID",
              "value": "={{$json[\"X-API-ID\"]}}"
            },
            {
              "name": "X-API-TIME",
              "value": "={{$json[\"X-API-TIME\"]}}"
            },
            {
              "name": "X-API-HASH",
              "value": "={{$json[\"X-API-HASH\"]}}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "event_id",
              "value": "={{$json.eventId}}"
            },
            {
              "name": "quantity",
              "value": "={{$json.quantity}}"
            },
            {
              "name": "category",
              "value": "={{$json.category}}"
            },
            {
              "name": "notes",
              "value": "Offline Partner Booking Block"
            }
          ]
        },
        "options": {}
      },
      "name": "HTTP Regiondo Block Capacity",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        600,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Generate Regiondo Auth HMAC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Regiondo Auth HMAC": {
      "main": [
        [
          {
            "node": "HTTP Regiondo Block Capacity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "regiondo-block-seats"
}