mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
add ecom order products option decrisption
This commit is contained in:
parent
0da9c03587
commit
9a3a0d150b
|
@ -98,13 +98,17 @@ export class ActiveCampaign implements INodeType {
|
|||
value: 'deal',
|
||||
},
|
||||
{
|
||||
name: "E-commerce Order",
|
||||
value: "ecommerceOrder",
|
||||
name: 'E-commerce Order',
|
||||
value: 'ecommerceOrder',
|
||||
},
|
||||
{
|
||||
name: "E-Commerce Customer",
|
||||
value: "ecommerceCustomer",
|
||||
name: 'E-Commerce Customer',
|
||||
value: 'ecommerceCustomer',
|
||||
},
|
||||
{
|
||||
name: 'E-commerce Order Products',
|
||||
value: 'ecomerceOrderProducts'
|
||||
}
|
||||
],
|
||||
default: 'contact',
|
||||
description: 'The resource to operate on.',
|
||||
|
@ -254,8 +258,6 @@ export class ActiveCampaign implements INodeType {
|
|||
|
||||
endpoint = '/api/3/deals';
|
||||
|
||||
dataKey = 'deal';
|
||||
|
||||
body.deal = {
|
||||
title: this.getNodeParameter('title', i) as string,
|
||||
contact: this.getNodeParameter('contact', i) as string,
|
||||
|
@ -291,8 +293,8 @@ export class ActiveCampaign implements INodeType {
|
|||
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}`;
|
||||
|
||||
dataKey = 'deal';
|
||||
body.deal = {} as IDataObject;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.deal as IDataObject, updateFields);
|
||||
|
||||
|
@ -328,7 +330,6 @@ export class ActiveCampaign implements INodeType {
|
|||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
}
|
||||
|
||||
dataKey = 'deals';
|
||||
endpoint = `/api/3/deals`;
|
||||
|
||||
} else if (operation === 'createNote') {
|
||||
|
@ -358,7 +359,6 @@ export class ActiveCampaign implements INodeType {
|
|||
const dealNoteId = this.getNodeParameter('dealNoteId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`;
|
||||
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known`);
|
||||
}
|
||||
|
@ -372,8 +372,6 @@ export class ActiveCampaign implements INodeType {
|
|||
|
||||
endpoint = '/api/3/ecomOrders';
|
||||
|
||||
dataKey = 'ecommerceOrder';
|
||||
|
||||
body.ecomOrder = {
|
||||
source: this.getNodeParameter('source', i) as string,
|
||||
email: this.getNodeParameter('email', i) as string,
|
||||
|
@ -415,7 +413,6 @@ export class ActiveCampaign implements INodeType {
|
|||
const orderId = this.getNodeParameter('orderId', i) as number;
|
||||
endpoint = `/api/3/ecomOrders/${orderId}`;
|
||||
|
||||
dataKey = 'ecommerceOrder';
|
||||
body.ecomOrder = {} as IDataObject;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
@ -453,7 +450,6 @@ export class ActiveCampaign implements INodeType {
|
|||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
}
|
||||
|
||||
dataKey = 'ecommerceOrders';
|
||||
endpoint = `/api/3/ecomOrders`;
|
||||
|
||||
} else {
|
||||
|
@ -469,8 +465,6 @@ export class ActiveCampaign implements INodeType {
|
|||
|
||||
endpoint = '/api/3/ecomCustomers';
|
||||
|
||||
dataKey = 'ecommerceCustomer';
|
||||
|
||||
body.ecomCustomer = {
|
||||
connectionid: this.getNodeParameter('connectionid', i) as string,
|
||||
externalid: this.getNodeParameter('externalid', i) as string,
|
||||
|
@ -478,14 +472,14 @@ export class ActiveCampaign implements INodeType {
|
|||
} as IDataObject;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
if (additionalFields.acceptsMarketing) {
|
||||
if (additionalFields.acceptsMarketing !== undefined) {
|
||||
if (additionalFields.acceptsMarketing == true) {
|
||||
additionalFields.acceptsMarketing = '1';
|
||||
} else {
|
||||
additionalFields.acceptsMarketing = '0';
|
||||
}
|
||||
}
|
||||
addAdditionalFields(body.ecomOrder as IDataObject, additionalFields);
|
||||
addAdditionalFields(body.ecomCustomer as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
|
@ -497,11 +491,10 @@ export class ActiveCampaign implements INodeType {
|
|||
const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number;
|
||||
endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`;
|
||||
|
||||
dataKey = 'ecommerceCustomer';
|
||||
body.ecomCustomer = {} as IDataObject;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
if (updateFields.acceptsMarketing) {
|
||||
if (updateFields.acceptsMarketing != undefined) {
|
||||
if (updateFields.acceptsMarketing == true) {
|
||||
updateFields.acceptsMarketing = '1';
|
||||
} else {
|
||||
|
@ -542,7 +535,6 @@ export class ActiveCampaign implements INodeType {
|
|||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
}
|
||||
|
||||
dataKey = 'ecommerceCustomers';
|
||||
endpoint = `/api/3/ecomCustomers`;
|
||||
|
||||
} else {
|
||||
|
@ -567,9 +559,6 @@ export class ActiveCampaign implements INodeType {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(body)
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,27 +16,27 @@ export const ecomCustomerOperations = [
|
|||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a ecommerceCustomer',
|
||||
description: 'Create a E-commerce Customer',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a ecommerceCustomer',
|
||||
description: 'Delete a E-commerce Customer',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get data of a ecommerceCustomer',
|
||||
description: 'Get data of a E-commerce Customer',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all ecommerceCustomer',
|
||||
description: 'Get data of all E-commerce Customer',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a ecommerceCustomer',
|
||||
description: 'Update a E-commerce Customer',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
import { INodeProperties } from "n8n-workflow";
|
||||
|
||||
import { allCurrencies } from './currencies';
|
||||
|
||||
export const ecomOrderProductsOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'ecommerceOrderProducts',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get data of all orders',
|
||||
},
|
||||
{
|
||||
name: 'Get by Product ID',
|
||||
value: 'getByProductId',
|
||||
description: 'Get data of a order',
|
||||
},
|
||||
{
|
||||
name: 'Get by Order ID',
|
||||
value: 'getByOrderId',
|
||||
description: 'Get data of a order',
|
||||
},
|
||||
|
||||
],
|
||||
default: 'create',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[]
|
||||
|
||||
export const ecomOrderProductsFields = [
|
||||
// ----------------------------------
|
||||
// ecommerceOrderProducts:getByOrderId
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Order ID',
|
||||
name: 'orderId',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getByOrderId',
|
||||
],
|
||||
resource: [
|
||||
'ecommerceOrderProducts',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The id of the e-commerce order.',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// ecommerceOrderProducts:getByProductId
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Product ID',
|
||||
name: 'procuctId',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getByProductId',
|
||||
],
|
||||
resource: [
|
||||
'ecommerceOrderProducts',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The id of the e-commerce order.',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// ecommerceOrderProducts:getAll
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'ecommerceOrderProducts',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'If all results should be returned or only up to a given limit.',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'ecommerceOrderProducts',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
] as INodeProperties[]
|
|
@ -105,10 +105,14 @@ export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IE
|
|||
|
||||
if (dataKey === undefined) {
|
||||
returnData.push.apply(returnData, responseData);
|
||||
itemsReceived += returnData.length;
|
||||
if (returnData != undefined) {
|
||||
itemsReceived += returnData.length;
|
||||
}
|
||||
} else {
|
||||
returnData.push.apply(returnData, responseData[dataKey]);
|
||||
itemsReceived += responseData[dataKey].length;
|
||||
if (responseData[dataKey] != undefined) {
|
||||
itemsReceived += responseData[dataKey].length;
|
||||
}
|
||||
}
|
||||
|
||||
query.offset = itemsReceived;
|
||||
|
|
Loading…
Reference in a new issue