{
  "nodes": [
    {
      "parameters": {},
      "id": "7ca90783-2e66-479d-83a7-b213bbf4b699",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1680,
        140
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "fieldToSplitOut": "data",
        "options": {}
      },
      "id": "234c4919-39dd-41f8-8d86-fb25f276a907",
      "name": "List Invoices",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -800,
        240
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2bdd8550-526c-4833-872e-b1028019a88a",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.object }}",
              "rightValue": "invoice"
            }
          ]
        },
        "options": {}
      },
      "id": "10bf4ea5-b77c-4796-9ef2-8be13a4d83f9",
      "name": "We do only Invoice Objects",
      "type": "n8n-nodes-base.if",
      "position": [
        -580,
        240
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b2927be9-2b00-4ab8-8938-56b1a0c2e134",
              "name": "year",
              "type": "number",
              "value": "={{ $now.minus(1,\"month\").format(\"yyyy\") }}"
            },
            {
              "id": "89e0c6ee-7b67-405a-b933-5a511cdea94b",
              "name": "month",
              "type": "number",
              "value": "={{ $now.minus(1,\"month\").format(\"MM\") }}"
            }
          ]
        },
        "options": {}
      },
      "id": "e501f562-ea91-4774-b23e-8d3a3ac00010",
      "name": "ENV*",
      "type": "n8n-nodes-base.set",
      "position": [
        -1460,
        240
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "url": "={{ $json.invoice_pdf }}",
        "options": {}
      },
      "id": "4ff2cc20-4bd4-48d1-b62d-fdd588a85e7f",
      "name": "Download Invoice PDF from Stripe",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        240
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months"
            }
          ]
        }
      },
      "id": "c88c3d9c-c4cd-4338-8661-99cf78837555",
      "name": "Every Month the First Day of the Month",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1680,
        340
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "url": "https://api.stripe.com/v1/invoices",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "stripeApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            },
            {
              "name": "created[gte]",
              "value": "={{ DateTime.fromISO($json.year+\"-\"+$json.month+\"-01T00:00:00\").toSeconds() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "28bb627e-b2a3-412f-bc31-a5808b896b9c",
      "name": "Get all Invoices*",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1020,
        240
      ],
      "typeVersion": 4.2,
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0fb9451f-afc1-4b70-9ec3-f3ac7187c2db",
              "name": "month",
              "type": "string",
              "value": "={{ $json.month.toString().padStart(2,\"0\") }}"
            },
            {
              "id": "eda1110d-329b-4d12-a089-253ac189aea4",
              "name": "year",
              "type": "number",
              "value": "={{ parseInt($json.year) }}"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "66e8f518-44ca-4ed0-be72-77af45047293",
      "name": "Clean and Escape ENV",
      "type": "n8n-nodes-base.set",
      "position": [
        -1240,
        240
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {
          "includeBinaries": true
        }
      },
      "id": "e3d3285b-f584-4056-a127-2a4e9cc40b69",
      "name": "All into one Item (include Binary)",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -140,
        240
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "compress",
        "binaryPropertyName": "={{ Object.keys($binary).join(',') }}",
        "fileName": "=s3-export.zip"
      },
      "id": "39748c61-24c4-489c-94c1-899f8a2df9f7",
      "name": "Compress all of them to a ZIP",
      "type": "n8n-nodes-base.compression",
      "position": [
        80,
        240
      ],
      "typeVersion": 1.1
    }
  ],
  "connections": {
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "ENV*",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Invoices": {
      "main": [
        [
          {
            "node": "We do only Invoice Objects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "We do only Invoice Objects": {
      "main": [
        [
          {
            "node": "Download Invoice PDF from Stripe",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "ENV*": {
      "main": [
        [
          {
            "node": "Clean and Escape ENV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Invoice PDF from Stripe": {
      "main": [
        [
          {
            "node": "All into one Item (include Binary)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Month the First Day of the Month": {
      "main": [
        [
          {
            "node": "ENV*",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all Invoices*": {
      "main": [
        [
          {
            "node": "List Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean and Escape ENV": {
      "main": [
        [
          {
            "node": "Get all Invoices*",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All into one Item (include Binary)": {
      "main": [
        [
          {
            "node": "Compress all of them to a ZIP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}