{
  "name": "Fluxo A - Pull API (Polling)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "id": "schedule-trigger-1"
    },
    {
      "parameters": {
        "url": "http://localhost:5000/api/pedidos",
        "method": "GET",
        "options": {}
      },
      "name": "HTTP Request - Consultar API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        450,
        300
      ],
      "id": "http-request-1"
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.length }}",
              "operation": "larger",
              "value2": 0
            }
          ]
        }
      },
      "name": "IF - Tem Pedidos?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "id": "if-node-1"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": "SEU_GOOGLE_SHEET_ID",
        "sheetName": "Pedidos",
        "columns": {
          "mappings": [
            {
              "column": "Cliente",
              "value": "={{ $json.cliente }}"
            },
            {
              "column": "Pedido",
              "value": "={{ $json.pedido }}"
            },
            {
              "column": "Status",
              "value": "={{ $json.status }}"
            },
            {
              "column": "Data/Hora",
              "value": "={{ $json.data_hora }}"
            },
            {
              "column": "Tipo Fluxo",
              "value": "Pull/API"
            }
          ]
        }
      },
      "name": "Google Sheets - Salvar",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        850,
        200
      ],
      "id": "google-sheets-1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "message": "=Polling executado \u00e0s {{ $now.toFormat('HH:mm:ss') }} - Nenhum pedido encontrado (execu\u00e7\u00e3o vazia)"
      },
      "name": "Log - Execu\u00e7\u00e3o Vazia",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        850,
        400
      ],
      "id": "noop-1"
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request - Consultar API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Consultar API": {
      "main": [
        [
          {
            "node": "IF - Tem Pedidos?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Tem Pedidos?": {
      "main": [
        [
          {
            "node": "Google Sheets - Salvar",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log - Execu\u00e7\u00e3o Vazia",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}