{
  "name": "ofn hook v0.24.0 beta",
  "nodes": [
    {
      "parameters": {},
      "id": "a9f63be4-fd47-4585-a180-9e8c8047b58d",
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -840,
        940
      ]
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "name": "Time trigger",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        -840,
        780
      ],
      "id": "67a5f6a6-5740-4abf-a3d4-a165bb50f893"
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "={{$node[\"Config\"].json[\"ofnInstanceRootUrl\"]}}/api/v0/orders",
        "options": {
          "splitIntoItems": false
        },
        "queryParametersUi": {
          "parameter": [
            {
              "name": "q[updated_at_gt]",
              "value": "={{$json[\"pollingLastUpdateSince\"]}}"
            },
            {
              "name": "q[sorts]",
              "value": "updated_at desc"
            }
          ]
        }
      },
      "name": "Get orders",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -40,
        780
      ],
      "id": "8d4bbcb6-99b5-4dd6-81f5-a43a2494e6d0",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "={{$item(0).$node[\"Config\"].json[\"ofnInstanceRootUrl\"]}}/api/v0//orders/{{$node[\"Keep new\"].json[\"gid\"]}}",
        "options": {}
      },
      "name": "Get order",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -580,
        1260
      ],
      "id": "0c1aee57-efb7-4a7e-b49d-6e40e73cc228",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "removeKeyMatches",
        "propertyName1": "key",
        "propertyName2": "key"
      },
      "name": "Keep new",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        940,
        680
      ],
      "id": "0223e821-3cd0-4781-af7c-2fbbfffad8a7"
    },
    {
      "parameters": {
        "functionCode": "return items.reduce((acc,val) => acc = acc.concat(val.json.orders),[]).map(item => {\n  return {\n    json: item\n  }\n})\n"
      },
      "name": "Order list",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        120,
        780
      ],
      "id": "2e18faca-3a83-4ad3-8d5a-2b3765b65fa7"
    },
    {
      "parameters": {
        "mode": "passThrough"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        380,
        1280
      ],
      "id": "1e22fd4e-8be3-44a7-9c1f-b9468704a0ee"
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "={{$json.variant.product.getUrl}}",
        "options": {}
      },
      "name": "Get product",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        40,
        1460
      ],
      "id": "31dfa3d0-ddc6-4cf7-a3ba-95f71e16c05b",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "function slugify(string) {\n  const a = '\u00e0\u00e1\u00e2\u00e4\u00e6\u00e3\u00e5\u0101\u0103\u0105\u00e7\u0107\u010d\u0111\u010f\u00e8\u00e9\u00ea\u00eb\u0113\u0117\u0119\u011b\u011f\u01f5\u1e27\u00ee\u00ef\u00ed\u012b\u012f\u00ec\u0131\u0130\u0142\u1e3f\u00f1\u0144\u01f9\u0148\u00f4\u00f6\u00f2\u00f3\u0153\u00f8\u014d\u00f5\u0151\u1e55\u0155\u0159\u00df\u015b\u0161\u015f\u0219\u0165\u021b\u00fb\u00fc\u00f9\u00fa\u016b\u01d8\u016f\u0171\u0173\u1e83\u1e8d\u00ff\u00fd\u017e\u017a\u017c\u00b7/_,:;'\n  const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'\n  const p = new RegExp(a.split('').join('|'), 'g')\n\n  return string.toString().toLowerCase()\n    .replace(/\\s+/g, '-') // Replace spaces with -\n    .replace(/\\.+/g, '-') // Replace . with -\n    .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters\n    .replace(/&/g, '-and-') // Replace & with 'and'\n    .replace(/[^\\w\\-]+/g, '') // Remove all non-word characters\n    .replace(/\\-\\-+/g, '-') // Replace multiple - with single -\n    .replace(/^-+/, '') // Trim - from start of text\n    .replace(/-+$/, '') // Trim - from end of text\n}\n\nconst ofnInstanceRootUrl = $item(0).$node[\"Config\"].json[\"ofnInstanceRootUrl\"]\n\nitem.variant.product = {\n  getUrl: ofnInstanceRootUrl + \"/api/v0/products/bulk_products?q[name_eq]=\" + encodeURIComponent(item.variant.product_name)  // + slugify(item.variant.product_name)\n}\n\nreturn item;"
      },
      "name": "Enrich line item",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        -140,
        1460
      ],
      "id": "4601e3d3-eb26-4230-b928-17babfd9f29f"
    },
    {
      "parameters": {
        "fieldToSplitOut": "line_items",
        "options": {}
      },
      "name": "Line items",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        -300,
        1460
      ],
      "id": "72931782-d174-45b4-a739-ae39ec30c3d1"
    },
    {
      "parameters": {
        "functionCode": "const variantId = $node[\"Enrich line item\"].json.variant.id\n\nfor(p of item.products){\n  for(v of p.variants){\n    if(v.id == variantId)\n    return p\n  }\n}"
      },
      "name": "Find OFN product",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        200,
        1460
      ],
      "id": "fcb03c9e-e5dd-40ed-9833-53cf09a2c339"
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "ofnInstanceRootUrl",
              "value": "https://openfoodnetwork.be"
            },
            {
              "name": "googleSpreadsheetId",
              "value": "1v_Cq9HG6sWcn8nFSauZrNYxgNm7NDiTjGke1nz5T1ps"
            },
            {
              "name": "hmacPrivateKey",
              "value": "secret_fnejznfz189210"
            },
            {
              "name": "sendWebRequestSource",
              "value": "database"
            },
            {
              "name": "sendWebRequestPath",
              "value": "/data/webhook_request.json"
            }
          ],
          "number": [
            {
              "name": "sendWebRequestWorkflowId",
              "value": 19
            },
            {
              "name": "pollingLastMinutesNumber",
              "value": 60
            },
            {
              "name": "pruneRevisionWhenOver",
              "value": 500
            },
            {
              "name": "pruneRevisionQuantity",
              "value": 10
            }
          ]
        },
        "options": {}
      },
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -620,
        780
      ],
      "id": "3fffdae9-74f1-463d-b589-7511f3e08780"
    },
    {
      "parameters": {
        "content": "You need to create google api user and give it access to the spreadsheet.",
        "height": 100,
        "width": 180
      },
      "name": "Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -20,
        620
      ],
      "id": "2876e046-86dc-4074-8f42-be1a171f52e2"
    },
    {
      "parameters": {
        "content": "different time trigger per resource, add resource type in google sheet"
      },
      "name": "Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        580
      ],
      "id": "de200d2d-1a07-4545-a134-a7fa9067ab6e"
    },
    {
      "parameters": {
        "sheetId": "={{$node[\"Config\"].parameter[\"values\"][\"string\"][1][\"value\"]}}",
        "range": "hooks_active_full!A:K",
        "options": {}
      },
      "name": "Get hooks",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        200,
        1080
      ],
      "id": "eefaaf5f-843d-428b-a716-ee45ae1f0044",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "function unflatten(data) {\n  var result = {}\n  for (var i in data) {\n    var keys = i.split('.')\n    keys.reduce(function(r, e, j) {\n      return r[e] || (r[e] = isNaN(Number(keys[j + 1])) ? (keys.length - 1 == j ? data[i] : {}) : [])\n    }, result)\n  }\n  return result\n}\n\nObject.keys(item).forEach((k) => (item[k] == null || item[k] == \"\") && delete item[k]);\n\nreturn {\n  hook: unflatten(item)\n} "
      },
      "name": "Unflatten hooks",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        420,
        1080
      ],
      "id": "a02807ff-5e56-4228-b531-be584691d33a"
    },
    {
      "parameters": {
        "sheetId": "1v_Cq9HG6sWcn8nFSauZrNYxgNm7NDiTjGke1nz5T1ps",
        "range": "revisions!A:D",
        "options": {}
      },
      "name": "Revisions",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        560,
        840
      ],
      "alwaysOutputData": true,
      "id": "b99873eb-983f-42a4-9144-e658aef16741",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "For later n8n updates, hide HMAC secret ",
        "height": 200
      },
      "name": "Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        260,
        420
      ],
      "id": "2bc2da63-6e49-409b-9f74-1cfcfe9b3b40"
    },
    {
      "parameters": {
        "action": "hmac",
        "type": "SHA256",
        "value": "={{JSON.stringify($json[\"event\"])}}",
        "dataPropertyName": "hmac",
        "secret": "={{$json[\"hook\"][\"endpoint\"][\"secret\"]}}"
      },
      "name": "Add HMAC",
      "type": "n8n-nodes-base.crypto",
      "typeVersion": 1,
      "position": [
        1780,
        1320
      ],
      "id": "44b3f732-2e62-4673-8d7b-6d0bba9ddf58"
    },
    {
      "parameters": {
        "value": "={{JSON.stringify($json)}}",
        "dataPropertyName": "md5"
      },
      "name": "Add md5",
      "type": "n8n-nodes-base.crypto",
      "typeVersion": 1,
      "position": [
        320,
        660
      ],
      "id": "872d8ce9-64ac-4470-bad3-529fc1d8df1c"
    },
    {
      "parameters": {
        "functionCode": "const revision = {\n  resource: \"order\",\n  gid: item.number,\n  hash: item.md5,\n  status: item.state,\n  shipment_status: item.shipment_state\n}\n\nrevision.key = revision.resource + \"-\" + revision.gid + \"-\" + revision.hash\n\nreturn revision"
      },
      "name": "Revision",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        500,
        660
      ],
      "id": "efa36b28-a8bf-46fd-bbf5-f9a3591ae58e"
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "1v_Cq9HG6sWcn8nFSauZrNYxgNm7NDiTjGke1nz5T1ps",
        "range": "revisions!A:G",
        "options": {
          "valueInputMode": "RAW"
        }
      },
      "name": "Append revisions",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1100,
        840
      ],
      "alwaysOutputData": false,
      "id": "a3d85222-ee94-4ad9-890b-c99a3807a643",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "return {}"
      },
      "name": "Stub empty",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        760,
        840
      ],
      "id": "71058106-fdc0-4848-8458-c381134df88e",
      "disabled": true
    },
    {
      "parameters": {
        "content": "No totally correct to do md5 on partial order ..."
      },
      "name": "Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        900,
        400
      ],
      "id": "3016dd23-b54a-4715-9f01-f918ec34d41b"
    },
    {
      "parameters": {
        "content": "External system should handle the fact to get several times the same request"
      },
      "name": "Note5",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -80,
        420
      ],
      "id": "3ce1399e-9117-43ba-a5d5-18ed6ed9a2ed"
    },
    {
      "parameters": {
        "content": "add distributor id to index"
      },
      "name": "Note7",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1340,
        260
      ],
      "id": "d08092a4-e634-4a01-aaa0-38b53fa16a34"
    },
    {
      "parameters": {
        "content": "add events info such as name, revision, ..."
      },
      "name": "Note9",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        940,
        200
      ],
      "id": "810f8ff2-862e-42f7-a6ad-2be7b4de2bed"
    },
    {
      "parameters": {
        "content": "Optimize how to find products"
      },
      "name": "Note10",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        580,
        420
      ],
      "id": "68b7d00b-b86f-42ae-91fe-29c04b24d95d"
    },
    {
      "parameters": {
        "functionCode": "const order = $node[\"Get order\"].json\nconst products = $items(\"Find OFN product\").map(p => (p.json))\n\nfunction toIsoLocalTime(value) {\n    if (value instanceof Date === false)\n        value = new Date(value);    \n    const off = value.getTimezoneOffset() * -1;\n    const del = value.getMilliseconds() ? 'Z' : '.'; // have milliseconds ?\n    value = new Date(value.getTime() + off * 60000); // add or subtract time zone\n    return value\n        .toISOString()\n        .split(del)[0]\n        + (off < 0 ? '-' : '+')\n        + ('0' + Math.abs(Math.floor(off / 60))).substr(-2)\n        + ':'\n        + ('0' + Math.abs(off % 60)).substr(-2);\n}\n\nconst mapAddresss = (orderAddress) => ({\n  id: orderAddress.id,\n  phone: orderAddress.phone,\n  first_name: orderAddress.firstname,\n  last_name: orderAddress.lastname,\n  street_address_1: orderAddress.address1,\n  street_address_2: orderAddress.address2,\n  postal_code: orderAddress.zipcode,\n  locality: orderAddress.city,\n  region: {\n    id: orderAddress.state_id,\n    name: orderAddress.state_name\n  },\n  country: {\n    id: orderAddress.country_id,\n    name: orderAddress.country_name\n  }\n})\n\nconst event = {\n  type: \"order_created_or_updated\",\n  at: (new Date()).toISOString(),\n  enterprise_id: order.distributor.id,\n  enterprise_name: order.distributor_name,\n  user_id: order.user_id,\n  user_name: order.full_name,\n  id: item.id,\n  data: {\n    id: order.id,\n    number: order.number,\n    created_at: new Date(new Date(order.created_at).getTime() - new Date(order.created_at).getTimezoneOffset() * 60000).toISOString(),\n    status: order.state,\n    payment_status: order.payment_state,\n    shipment_status: order.shipment_state,\n    total_price: order.total,\n    customer: {\n      id: order.customer_id\n    },\n    billing_address: mapAddresss(order.bill_address),\n    shipping_address: mapAddresss(order.ship_address),\n    shipping_method: {\n      id: order.shipping_method.id,\n      name: order.shipping_method.name,\n      description: order.shipping_method.description,\n      type: order.shipping_method.require_ship_address ? \"delivery\" : \"pickup\"\n    },\n    order_cycle: {\n      id: order.order_cycle.id\n    },\n    line_items: order.line_items.map(l =>{ \n      const product = products.find(p => p.name == l.variant.product_name)\n      return {\n      quantity: l.quantity,\n      variant: {\n        id: l.variant.id,\n        name: l.variant.name_to_display,\n        sku: l.variant.sku\n      },\n      product: {\n        id: product.id,\n        name: product.name,\n        category: {\n          id: product.category_id\n        },\n        producer: {\n          id: product.producer_id,\n          name: product.master.producer_name\n        }\n      }\n    }})\n  }\n  \n};\n\nreturn {\n  event: event\n}\n"
      },
      "name": "Event body",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        540,
        1280
      ],
      "id": "62741a5c-e6db-48b4-986f-e344bc4bfa15"
    },
    {
      "parameters": {
        "action": "generate",
        "dataPropertyName": "event.id"
      },
      "name": "Event id",
      "type": "n8n-nodes-base.crypto",
      "typeVersion": 1,
      "position": [
        1080,
        1280
      ],
      "id": "ba41e048-487b-4e32-abd4-bb51f99e5e62"
    },
    {
      "parameters": {
        "source": "={{$node[\"Config\"].json[\"sendWebRequestSource\"]}}",
        "workflowId": "={{$node[\"Config\"].json[\"sendWebRequestWorkflowId\"]}}",
        "workflowPath": "={{$node[\"Config\"].json[\"sendWebRequestPath\"]}}",
        "workflowUrl": "empty"
      },
      "id": "38173822-69e3-4012-b6f9-d467948e557e",
      "name": "Send web request",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        2160,
        1320
      ],
      "continueOnFail": true
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {
          "reset": false
        }
      },
      "id": "86c250ec-dfea-4e59-af55-63e1be175fc6",
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        1360,
        1280
      ]
    },
    {
      "parameters": {
        "action": "calculate",
        "value": "={{new Date()}}",
        "operation": "subtract",
        "duration": "={{$json[\"pollingLastMinutesNumber\"]}}",
        "timeUnit": "minutes",
        "dataPropertyName": "pollingLastUpdateSince",
        "options": {}
      },
      "id": "3477eb64-ab8a-4958-98a3-f90899e48422",
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        -420,
        780
      ]
    },
    {
      "parameters": {
        "value": "={{$json[\"pollingLastUpdateSince\"]}}",
        "dataPropertyName": "pollingLastUpdateSince",
        "custom": true,
        "toFormat": "YYYY-MM-DD HH:mm",
        "options": {
          "toTimezone": "Europe/Brussels"
        }
      },
      "id": "00890ab1-1498-49a5-a6fd-528bc9d80808",
      "name": "OFN now",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        -240,
        780
      ]
    },
    {
      "parameters": {
        "value": "={{new Date()}}",
        "dataPropertyName": "created_at",
        "custom": true,
        "toFormat": "YYYY-MM-DDTHH:mm",
        "options": {
          "toTimezone": "Europe/Brussels"
        }
      },
      "id": "9d4f58dc-407a-4178-ac71-f9dbc31e5064",
      "name": "Revision time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        700,
        660
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$items(\"Revisions\").length > $node[\"Config\"].json[\"pruneRevisionWhenOver\"]}}",
              "value2": true
            }
          ]
        }
      },
      "id": "f5ee5acc-9bb4-40c1-86f3-eb588cf77941",
      "name": "Prune revisions ?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1100,
        600
      ]
    },
    {
      "parameters": {
        "operation": "delete",
        "sheetId": "1v_Cq9HG6sWcn8nFSauZrNYxgNm7NDiTjGke1nz5T1ps",
        "toDelete": {
          "rows": [
            {
              "sheetId": 2038479117,
              "startIndex": 1,
              "amount": "={{$node[\"Config\"].parameter[\"values\"][\"number\"][3][\"value\"]}}"
            }
          ]
        }
      },
      "name": "Prune revisions",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1280,
        520
      ],
      "alwaysOutputData": true,
      "id": "78e52485-0a2c-4258-b936-d8b872df387a",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "const requests = []\n\nfor(var item of items){\n  const event = item.json.event\n  const hook = item.json.hook\n  \n  if(event.type != hook.event.type)\n    continue\n  \n  if(hook.enterprise?.id != null && hook.enterprise.id != event.enterprise_id)\n    continue\n\n  if(hook.filters?.status != null && hook.filters.status != event.data.status)\n    continue\n\n  if(hook.filters?.shipment_status != null && hook.filters.shipment_status != event.data.shipment_status)\n    continue\n\n  requests.push(item)\n}\n\nreturn requests;"
      },
      "id": "ae11156d-f104-48de-a478-0ccf1615fd3d",
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        920,
        1280
      ]
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "id": "1c6633ed-4e57-4834-840c-1bc1c35783ba",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        720,
        1220
      ]
    },
    {
      "parameters": {
        "functionCode": "return {\n  url: item.hook.endpoint.url,\n  hearders: {\n    \"X-OFN-HMAC-SHA256\": item.hmac\n  },\n  body: item.event\n}"
      },
      "id": "d1476337-8281-47cc-bae6-69e3c4b75c4c",
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        1980,
        1320
      ]
    },
    {
      "parameters": {
        "dataType": "string",
        "value1": "={{$json[\"hook\"][\"endpoint\"][\"type\"]}}",
        "rules": {
          "rules": [
            {
              "value2": "workflow"
            },
            {
              "value2": "web",
              "output": 1
            }
          ]
        }
      },
      "id": "9d173e03-4f90-4d41-bbfe-d0693e775b99",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        1540,
        1280
      ]
    },
    {
      "parameters": {
        "workflowId": "={{$json[\"hook\"][\"endpoint\"][\"workflow\"][\"id\"]}}"
      },
      "id": "314d37f9-1694-49d5-9727-6a403be0ca03",
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        1920,
        1020
      ]
    }
  ],
  "connections": {
    "Time trigger": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get order": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Line items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get orders": {
      "main": [
        [
          {
            "node": "Order list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep new": {
      "main": [
        [
          {
            "node": "Append revisions",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prune revisions ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order list": {
      "main": [
        [
          {
            "node": "Add md5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Event body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get product": {
      "main": [
        [
          {
            "node": "Find OFN product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich line item": {
      "main": [
        [
          {
            "node": "Get product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Line items": {
      "main": [
        [
          {
            "node": "Enrich line item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find OFN product": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Config": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get hooks": {
      "main": [
        [
          {
            "node": "Unflatten hooks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Revisions": {
      "main": [
        [
          {
            "node": "Stub empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Revision": {
      "main": [
        [
          {
            "node": "Revision time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add md5": {
      "main": [
        [
          {
            "node": "Revision",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append revisions": {
      "main": [
        [
          {
            "node": "Get order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stub empty": {
      "main": [
        [
          {
            "node": "Keep new",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Add HMAC": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event body": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Event id": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send web request": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Unflatten hooks": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "OFN now",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OFN now": {
      "main": [
        [
          {
            "node": "Get orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Revision time": {
      "main": [
        [
          {
            "node": "Keep new",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prune revisions ?": {
      "main": [
        [
          {
            "node": "Prune revisions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Event id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "Send web request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add HMAC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "timezone": "Europe/Brussels",
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "none"
  },
  "id": 16,
  "tags": []
}