UNPKG

@progtechbr/n8n-nodes-rdsme

Version:

Send events through API to RD Station Marketing para Ecommerce

189 lines (184 loc) 4.15 kB
import type { INodeProperties } from 'n8n-workflow'; const lineItemsInputMode: INodeProperties[] = [ { displayName: 'Product Items Input Mode', name: 'lineItemsMode', type: 'options', displayOptions: { show: { operation: ['newEcommerceEvent'], resource: ['ecommerceEvents'], }, hide: { eventType: [ 'ecommerceOrderCancelled', 'ecommerceOrderRefunded', 'ecommerceOrderFulfilled', 'ecommerceShipmentDelivered', ], }, }, options: [ { name: 'Manual (UI)', value: 'ui', }, { name: 'Expression (JSON)', value: 'json', }, ], default: 'ui', description: 'Choose how to provide the product items', noDataExpression: true, required: true, }, ]; const lineItemsUi: INodeProperties[] = [ { displayName: 'Product Items (Manual Insertion)', name: 'lineItemsUi', type: 'fixedCollection', typeOptions: { multipleValues: true, }, placeholder: 'Add a new product', default: {}, description: 'List of products involved in the checkout', displayOptions: { show: { operation: ['newEcommerceEvent'], resource: ['ecommerceEvents'], lineItemsMode: ['ui'], }, hide: { eventType: [ 'ecommerceOrderCancelled', 'ecommerceOrderRefunded', 'ecommerceOrderFulfilled', 'ecommerceShipmentDelivered', ], }, }, options: [ { displayName: 'Product', name: 'productItems', // eslint-disable-next-line n8n-nodes-base/node-param-fixed-collection-type-unsorted-items values: [ { displayName: 'Product ID', name: 'productId', type: 'string', default: '', description: 'Product identifier', required: true, }, { displayName: 'Product Name/Title', name: 'productTitle', type: 'string', default: '', description: 'Name or title of the product', required: true, }, { displayName: 'Product URL', name: 'productUrl', type: 'string', default: '', description: 'Product URL - HTTP or HTTPS address', }, { displayName: 'Variant ID', name: 'variantId', type: 'string', default: '', description: 'Variant identifier', }, { displayName: 'Variant Name/Title', name: 'variantTitle', type: 'string', default: '', description: 'Name or title of the variant', }, { displayName: 'SKU', name: 'sku', type: 'string', default: '', description: 'SKU of the product or variant', }, { displayName: 'Price', name: 'price', type: 'number', default: 0, typeOptions: { minValue: 0, }, description: 'Price of the product', required: true, }, { displayName: 'Quantity', name: 'quantity', type: 'number', default: 0, typeOptions: { minValue: 0, }, description: 'Quantity of the product', required: true, }, { displayName: 'Image URL', name: 'imageUrl', type: 'string', default: '', description: 'Image URL - HTTP or HTTPS address', }, { displayName: 'Categories', name: 'categories', type: 'string', default: '', description: 'Categories - Separated by comma and maximum 10 items', }, ], }, ], required: true, }, ]; const lineItemsJson: INodeProperties[] = [ { displayName: 'Product Items (Json)', name: 'lineItemsJson', type: 'json', default: '', description: 'Provide an array of objects like: [{"product_id": "123", "product_title": "Product Title", "price": 10, "quantity": 1}]', displayOptions: { show: { operation: ['newEcommerceEvent'], resource: ['ecommerceEvents'], lineItemsMode: ['json'], }, hide: { eventType: [ 'ecommerceOrderCancelled', 'ecommerceOrderRefunded', 'ecommerceOrderFulfilled', 'ecommerceShipmentDelivered', ], }, }, required: true, }, ]; export const ecommerceLineItems: INodeProperties[] = [ ...lineItemsInputMode, ...lineItemsUi, ...lineItemsJson, ];