{
  "name": "Roteador de Webhooks",
  "nodes": [
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000001",
      "name": "Receber Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "router",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000002",
      "name": "Roteador por Tipo",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "rules",
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.tipo }}",
                    "rightValue": "pedido",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "pedido"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.tipo }}",
                    "rightValue": "pagamento",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "pagamento"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "loose"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.tipo }}",
                    "rightValue": "cancelamento",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "cancelamento"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000003",
      "name": "Processar Pedido",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        120
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.sistema-pedidos.com/v1/pedidos",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.body) }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000004",
      "name": "Processar Pagamento",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.financeiro.com/v1/pagamentos",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.body) }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000005",
      "name": "Processar Cancelamento",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        480
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.sistema-pedidos.com/v1/cancelamentos",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.body) }}",
        "options": {}
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0007-0007-0007-000000000006",
      "name": "Responder OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        960,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ received: true, tipo: $json.body.tipo, processado_em: new Date().toISOString() }) }}",
        "options": {
          "responseCode": 200
        }
      }
    }
  ],
  "connections": {
    "Receber Webhook": {
      "main": [
        [
          {
            "node": "Roteador por Tipo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Roteador por Tipo": {
      "main": [
        [
          {
            "node": "Processar Pedido",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Processar Pagamento",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Processar Cancelamento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processar Pedido": {
      "main": [
        [
          {
            "node": "Responder OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processar Pagamento": {
      "main": [
        [
          {
            "node": "Responder OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processar Cancelamento": {
      "main": [
        [
          {
            "node": "Responder OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "a7b8c9d0-0007-0007-0007-000000000000",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}