536 lines
14 KiB
JSON
536 lines
14 KiB
JSON
{
|
|
"active": false,
|
|
"connections": {
|
|
"HTTP Request1": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Split Response Into Orders",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Schedule Trigger": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "HTTP Request1",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"IF": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Postgres1",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Split Response Into Orders": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Upsert Customer",
|
|
"type": "main",
|
|
"index": 0
|
|
},
|
|
{
|
|
"node": "Merge",
|
|
"type": "main",
|
|
"index": 1
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Postgres": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Set Platform Ids",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Crypto": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Code",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Upsert Customer": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Merge",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Merge": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Crypto",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Code": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Postgres",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Set Platform Ids": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "IF",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"createdAt": "2023-12-11T17:25:14.909Z",
|
|
"id": "55eZFqIMkqfMEtaC",
|
|
"meta": null,
|
|
"name": "Billbee Aufträge -> Data Warehouse",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"url": "https://app.billbee.io/api/v1/orders",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpBasicAuth",
|
|
"sendQuery": true,
|
|
"queryParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "minOrderDate",
|
|
"value": "={{ $today.minus(1 $day) }}"
|
|
},
|
|
{
|
|
"name": "pageSize",
|
|
"value": "250"
|
|
}
|
|
]
|
|
},
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "X-Billbee-Api-Key",
|
|
"value": "2855BE2C-1D67-4AB0-9DEB-3073E6D27B1C"
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "34781fe0-a66e-43a6-a616-45a1ad27f2e8",
|
|
"name": "HTTP Request1",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.1,
|
|
"position": [
|
|
-260,
|
|
-1340
|
|
],
|
|
"credentials": {
|
|
"httpBasicAuth": {
|
|
"id": "xANPcw3p1Nh0wF9J",
|
|
"name": "Billbee Basic"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"rule": {
|
|
"interval": [
|
|
{
|
|
"triggerAtMinute": 5
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"id": "28e8e58e-aea3-4c88-b174-7f4a51c425bd",
|
|
"name": "Schedule Trigger",
|
|
"type": "n8n-nodes-base.scheduleTrigger",
|
|
"typeVersion": 1.1,
|
|
"position": [
|
|
-520,
|
|
-1340
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"schema": {
|
|
"__rl": true,
|
|
"mode": "list",
|
|
"value": "public"
|
|
},
|
|
"table": {
|
|
"__rl": true,
|
|
"value": "fact_order_details",
|
|
"mode": "list",
|
|
"cachedResultName": "fact_order_details"
|
|
},
|
|
"columns": {
|
|
"mappingMode": "defineBelow",
|
|
"value": {
|
|
"product_id": "={{ $json.Product.EAN }}",
|
|
"quantity": "={{ $json.Quantity }}",
|
|
"price_each": "={{ $json.TotalPrice / $json.Quantity}}"
|
|
},
|
|
"matchingColumns": [],
|
|
"schema": [
|
|
{
|
|
"id": "order_detail_id",
|
|
"displayName": "order_detail_id",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true
|
|
},
|
|
{
|
|
"id": "order_id",
|
|
"displayName": "order_id",
|
|
"required": true,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true
|
|
},
|
|
{
|
|
"id": "product_id",
|
|
"displayName": "product_id",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "string",
|
|
"canBeUsedToMatch": true
|
|
},
|
|
{
|
|
"id": "quantity",
|
|
"displayName": "quantity",
|
|
"required": true,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true
|
|
},
|
|
{
|
|
"id": "price_each",
|
|
"displayName": "price_each",
|
|
"required": true,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "dab64316-4942-4207-b75a-dcd78704ab05",
|
|
"name": "Postgres1",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.3,
|
|
"position": [
|
|
2020,
|
|
-1320
|
|
],
|
|
"credentials": {
|
|
"postgres": {
|
|
"id": "JW5wwsSY4obQbCBb",
|
|
"name": "Postgres - warehouse"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "upsert",
|
|
"schema": {
|
|
"__rl": true,
|
|
"mode": "list",
|
|
"value": "public"
|
|
},
|
|
"table": {
|
|
"__rl": true,
|
|
"value": "dim_customers",
|
|
"mode": "list",
|
|
"cachedResultName": "dim_customers"
|
|
},
|
|
"columns": {
|
|
"mappingMode": "defineBelow",
|
|
"value": {
|
|
"customer_id": "={{ $json.Customer.Number }}",
|
|
"customer_country": "={{ $json.ShippingAddress.CountryISO2 }}"
|
|
},
|
|
"matchingColumns": [
|
|
"customer_id"
|
|
],
|
|
"schema": [
|
|
{
|
|
"id": "customer_id",
|
|
"displayName": "customer_id",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true,
|
|
"removed": false
|
|
},
|
|
{
|
|
"id": "customer_country",
|
|
"displayName": "customer_country",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "string",
|
|
"canBeUsedToMatch": false
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "6bd22bb9-e978-436e-bfa0-5f7579dec8d0",
|
|
"name": "Upsert Customer",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.3,
|
|
"position": [
|
|
300,
|
|
-1480
|
|
],
|
|
"credentials": {
|
|
"postgres": {
|
|
"id": "JW5wwsSY4obQbCBb",
|
|
"name": "Postgres - warehouse"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"boolean": [
|
|
{
|
|
"value1": "={{ $json.Product.EAN }}",
|
|
"operation": "notEqual",
|
|
"value2": "={{ null }}"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"id": "7991fd99-8f2d-4911-bc42-98b1c78269b3",
|
|
"name": "IF",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
1760,
|
|
-1300
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"fieldToSplitOut": "Data",
|
|
"options": {}
|
|
},
|
|
"id": "f951938c-ca90-4f33-9dce-099084407196",
|
|
"name": "Split Response Into Orders",
|
|
"type": "n8n-nodes-base.itemLists",
|
|
"typeVersion": 3,
|
|
"position": [
|
|
40,
|
|
-1480
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "upsert",
|
|
"schema": {
|
|
"__rl": true,
|
|
"mode": "list",
|
|
"value": "public"
|
|
},
|
|
"table": {
|
|
"__rl": true,
|
|
"value": "dim_orders",
|
|
"mode": "list",
|
|
"cachedResultName": "dim_orders"
|
|
},
|
|
"columns": {
|
|
"mappingMode": "defineBelow",
|
|
"value": {
|
|
"order_id": "={{ $json.order_hash }}",
|
|
"order_ref": "={{ $json.OrderNumber }}",
|
|
"order_date": "={{ $json.CreatedAt.toDate().format(\"yyyyMMdd\") }}",
|
|
"customer_id": "={{ $json.Customer.Number }}",
|
|
"platform_id": "={{ \nswitch ($json[\"ApiAccountName\"]) {\n case 'Otto':\n $json.platform = 6;\n default:\n $json.platform = 1;\n}\n}}"
|
|
},
|
|
"matchingColumns": [],
|
|
"schema": [
|
|
{
|
|
"id": "order_id",
|
|
"displayName": "order_id",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": true
|
|
},
|
|
{
|
|
"id": "order_ref",
|
|
"displayName": "order_ref",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "string",
|
|
"canBeUsedToMatch": false
|
|
},
|
|
{
|
|
"id": "order_date",
|
|
"displayName": "order_date",
|
|
"required": true,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": false
|
|
},
|
|
{
|
|
"id": "customer_id",
|
|
"displayName": "customer_id",
|
|
"required": true,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": false
|
|
},
|
|
{
|
|
"id": "platform_id",
|
|
"displayName": "platform_id",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "number",
|
|
"canBeUsedToMatch": false
|
|
},
|
|
{
|
|
"id": "md5_hash",
|
|
"displayName": "md5_hash",
|
|
"required": false,
|
|
"defaultMatch": false,
|
|
"display": true,
|
|
"type": "string",
|
|
"canBeUsedToMatch": false
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "716963ce-227c-470b-83d5-85c4af9442f3",
|
|
"name": "Postgres",
|
|
"type": "n8n-nodes-base.postgres",
|
|
"typeVersion": 2.3,
|
|
"position": [
|
|
1120,
|
|
-1320
|
|
],
|
|
"credentials": {
|
|
"postgres": {
|
|
"id": "JW5wwsSY4obQbCBb",
|
|
"name": "Postgres - warehouse"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"value": "={{ $json.OrderNumber.concat($json.CreatedAt.toDate().format(\"yyyy-MM-d\")) }}",
|
|
"dataPropertyName": "=order_hash",
|
|
"encoding": "base64"
|
|
},
|
|
"id": "67fd82c6-055a-41d7-bc5e-ca727b0f9777",
|
|
"name": "Crypto",
|
|
"type": "n8n-nodes-base.crypto",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
700,
|
|
-1320
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"mode": "chooseBranch",
|
|
"output": "input2"
|
|
},
|
|
"id": "8490a7f7-6f11-487b-8f81-4c97f56c638b",
|
|
"name": "Merge",
|
|
"type": "n8n-nodes-base.merge",
|
|
"typeVersion": 2.1,
|
|
"position": [
|
|
500,
|
|
-1320
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"language": "python",
|
|
"pythonCode": "# Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor item in _input.all():\n\tmatch item.json.Seller.BillbeeShopName:\n\t\tcase 'eBay':\n item.json.platform = 12\n\t\tcase 'lana-kk':\n item.json.platform = 1\n\t\tcase 'Amazon':\n item.json.platform = 2\n\t\tcase 'Weltkarten24':\n item.json.platform = 3\n\t\tcase 'KAUFLAND':\n item.json.platform = 5\n\t\tcase 'Wayfair':\n item.json.platform = 4\n\t\tcase 'Böttcher AG':\n item.json.platform = 7\n\t\tcase 'Juramondo':\n item.json.platform = 9\n\t\tcase 'wild.lanakk.com':\n item.json.platform = 8\n\t\tcase 'Etsy':\n item.json.platform = 10\n\t\tcase 'Otto':\n item.json.platform = 6\n\t\tcase 'weltkarte-kinder':\n item.json.platform = 11\n\t\tcase _:\n item.json.platform = 1\nreturn _input.all()\n"
|
|
},
|
|
"id": "2006b054-3147-4f8a-b8d1-6ce19554dfde",
|
|
"name": "Code",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
920,
|
|
-1320
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"fieldToSplitOut": "OrderItems",
|
|
"options": {}
|
|
},
|
|
"id": "48b91734-2dec-494e-8a8b-d260e5a5ff40",
|
|
"name": "Set Platform Ids",
|
|
"type": "n8n-nodes-base.itemLists",
|
|
"typeVersion": 3,
|
|
"position": [
|
|
1320,
|
|
-1320
|
|
]
|
|
}
|
|
],
|
|
"pinData": {},
|
|
"settings": {
|
|
"executionOrder": "v1"
|
|
},
|
|
"staticData": null,
|
|
"tags": [],
|
|
"triggerCount": 0,
|
|
"updatedAt": "2023-12-12T09:52:19.000Z",
|
|
"versionId": "0e731bc6-faf1-4e5e-a83e-f8dabe7f704d"
|
|
} |