{
  "id": "WZbxO16fZhbMfoe5",
  "createdAt": "2023-07-20T14:17:04.623Z",
  "updatedAt": "2024-02-08T00:55:02.152Z",
  "name": "[eliminado] HS Factura",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "amount": 0.2,
        "unit": "seconds"
      },
      "id": "4d9ff3a2-72de-4172-9042-133ebb84dd97",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        600,
        640
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/objects/factura/",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "archived",
              "value": "true"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {}
      },
      "id": "9145c52c-c36f-4014-b087-ba7ebd423650",
      "name": "Hubspot request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1460,
        340
      ],
      "executeOnce": true,
      "retryOnFail": true,
      "typeVersion": 3,
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "notes": "request facturas"
    },
    {
      "parameters": {
        "fieldToSplitOut": "results",
        "options": {}
      },
      "id": "7a636024-a8d3-40ad-bb2d-209ac61318be",
      "name": "Split results1",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        -1220,
        340
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "hubspot_request_after",
              "value": "={{ $node['Hubspot request1'].json.paging.next.after }}"
            }
          ]
        },
        "options": {}
      },
      "id": "ec649629-40f4-412b-b97e-68b332912684",
      "name": "Set after",
      "type": "n8n-nodes-base.set",
      "position": [
        -680,
        340
      ],
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/objects/factura/",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "after",
              "value": "={{ $json.hubspot_request_after }}"
            },
            {
              "name": "archived",
              "value": "true"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {}
      },
      "id": "73ce5ecd-5e5f-4c1f-864c-307c7b8aeb4a",
      "name": "Hubspot request 2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -500,
        340
      ],
      "executeOnce": true,
      "retryOnFail": true,
      "typeVersion": 3,
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "notes": "request facturas"
    },
    {
      "parameters": {
        "fieldToSplitOut": "results",
        "options": {}
      },
      "id": "d5ba2eef-1496-4fdf-a39d-cec2bb514b36",
      "name": "Split results 2",
      "type": "n8n-nodes-base.itemLists",
      "position": [
        -260,
        340
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "number": [
            {
              "name": "id",
              "value": "={{ $json.id }}"
            }
          ],
          "string": [
            {
              "name": "archivedAt",
              "value": "={{ $json.archivedAt }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a8142453-aedd-4cf5-9524-9704fc2ab9d4",
      "name": "Set variables 2",
      "type": "n8n-nodes-base.set",
      "position": [
        -40,
        340
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "hubspot_request_after",
              "value": "={{ $node['Hubspot request 2'].json.paging.next.after }}"
            }
          ]
        },
        "options": {}
      },
      "id": "d87e7835-a459-4476-a77d-8042a556eefc",
      "name": "Set after 2",
      "type": "n8n-nodes-base.set",
      "position": [
        400,
        640
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "upsert",
        "table": {
          "__rl": true,
          "value": "invoices_archived",
          "mode": "list",
          "cachedResultName": "invoices_archived"
        },
        "columnToMatchOn": "id",
        "options": {}
      },
      "id": "4e0e6681-9c58-4b67-bc88-858096b0dfd9",
      "name": "Insert 1",
      "type": "n8n-nodes-base.mySql",
      "position": [
        -860,
        340
      ],
      "typeVersion": 2.1,
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$node[\"Hubspot request 2\"].json[\"paging\"] ? true : false}}",
              "value2": true
            }
          ]
        }
      },
      "id": "1616a934-7ebc-4ccc-b789-cafaf8b315a4",
      "name": "Request contains paging",
      "type": "n8n-nodes-base.if",
      "position": [
        400,
        340
      ],
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "upsert",
        "table": {
          "__rl": true,
          "value": "invoices_archived",
          "mode": "list",
          "cachedResultName": "invoices_archived"
        },
        "columnToMatchOn": "id",
        "options": {}
      },
      "id": "a728e4ae-3a50-4c08-9774-7bf744235b11",
      "name": "Insert 2",
      "type": "n8n-nodes-base.mySql",
      "position": [
        180,
        340
      ],
      "typeVersion": 2.1,
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "Can't request with empty 'after'",
        "height": 80,
        "width": 255.18336978030985
      },
      "id": "d8ad5955-8150-434e-aa3a-c6320a5f2dfe",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1300,
        200
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "number": [
            {
              "name": "id",
              "value": "={{ $json.id }}"
            }
          ],
          "string": [
            {
              "name": "archivedAt",
              "value": "={{ $json.archivedAt }}"
            }
          ]
        },
        "options": {}
      },
      "id": "e4166c97-68f4-4f01-89d3-444734cb04a1",
      "name": "Set variables 1",
      "type": "n8n-nodes-base.set",
      "position": [
        -1020,
        340
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "DELETE i \nFROM invoices i\nJOIN invoices_archived ia ON i.id = ia.id;",
        "options": {}
      },
      "id": "0c17fd72-b7b3-408e-90de-ac677cb11b8f",
      "name": "Delete archived",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 2.1,
      "position": [
        660,
        360
      ],
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "id": "53a26245-bde7-480a-bdb9-c745f4699713",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        -1660,
        340
      ]
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Hubspot request 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert 1": {
      "main": [
        [
          {
            "node": "Set after",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert 2": {
      "main": [
        [
          {
            "node": "Request contains paging",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set after": {
      "main": [
        [
          {
            "node": "Hubspot request 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set after 2": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split results1": {
      "main": [
        [
          {
            "node": "Set variables 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set variables 1": {
      "main": [
        [
          {
            "node": "Insert 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set variables 2": {
      "main": [
        [
          {
            "node": "Insert 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split results 2": {
      "main": [
        [
          {
            "node": "Set variables 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hubspot request1": {
      "main": [
        [
          {
            "node": "Split results1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hubspot request 2": {
      "main": [
        [
          {
            "node": "Split results 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request contains paging": {
      "main": [
        [
          {
            "node": "Set after 2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Delete archived",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Hubspot request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "saveDataErrorExecution": "none",
    "saveDataSuccessExecution": "none",
    "saveManualExecutions": false,
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "staticData": {
    "node:Schedule Trigger": {
      "recurrencyRules": []
    }
  },
  "versionId": "18385572-7f46-4620-8ebc-ecbedaddc230",
  "triggerCount": 1,
  "tags": [
    {
      "id": "iL2ywDmPqVO6K3AI",
      "createdAt": "2023-08-17T17:06:40.880Z",
      "updatedAt": "2023-08-17T17:06:40.880Z",
      "name": "hubspot"
    },
    {
      "id": "v25eD48xihLAmSfO",
      "createdAt": "2023-07-14T19:51:55.716Z",
      "updatedAt": "2023-07-14T19:51:55.716Z",
      "name": "bi"
    }
  ]
}