mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
First try to get custom properties to work with v1
This commit is contained in:
parent
6e81abef3c
commit
9bd5d4bec1
|
@ -2,6 +2,29 @@
|
||||||
|
|
||||||
This list shows all the versions which include breaking changes and how to upgrade
|
This list shows all the versions which include breaking changes and how to upgrade
|
||||||
|
|
||||||
|
## 0.20.0
|
||||||
|
|
||||||
|
### What changed?
|
||||||
|
|
||||||
|
The node "ActiveCampaign" had to be changed to use v1 of their API. That API is sadly
|
||||||
|
quite bad but at least it is feature complete which their v3 sadly is not.
|
||||||
|
|
||||||
|
### When is action necessary?
|
||||||
|
|
||||||
|
If a "ActiveCampaign" node gets used in any workflow.
|
||||||
|
|
||||||
|
### How to upgrade:
|
||||||
|
|
||||||
|
After upgrading open all workflows which contain a "Read File From Url" node.
|
||||||
|
They will have a "?" as icon as they are not known anymore. Create a new
|
||||||
|
"HTTP Request" node to replace the old one and add the same URL as the previous
|
||||||
|
node had (in case you do not know it anymore you can select the old node, copy
|
||||||
|
it and paste it in a text-editor, it will display all the data the node
|
||||||
|
contained). Then set the "Response Format" to "File". Everything will then
|
||||||
|
function again like before.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 0.19.0
|
## 0.19.0
|
||||||
|
|
||||||
### What changed?
|
### What changed?
|
||||||
|
@ -11,7 +34,7 @@ The node "Read File From Url" got removed as its functionality got added to
|
||||||
|
|
||||||
### When is action necessary?
|
### When is action necessary?
|
||||||
|
|
||||||
If the "Read File From Url" gets used in any workflow.
|
If the "Read File From Url" node gets used in any workflow.
|
||||||
|
|
||||||
### How to upgrade:
|
### How to upgrade:
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
"test:e2e": "vue-cli-service test:e2e",
|
"test:e2e": "vue-cli-service test:e2e",
|
||||||
"test:unit": "vue-cli-service test:unit"
|
"test:unit": "vue-cli-service test:unit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@beyonk/google-fonts-webpack-plugin": "^1.2.3",
|
"@beyonk/google-fonts-webpack-plugin": "^1.2.3",
|
||||||
"@fortawesome/fontawesome-svg-core": "^1.2.19",
|
"@fortawesome/fontawesome-svg-core": "^1.2.19",
|
||||||
|
|
|
@ -183,14 +183,14 @@ export class ActiveCampaign implements INodeType {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'First Name',
|
displayName: 'First Name',
|
||||||
name: 'firstName',
|
name: 'first_name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The first name of the contact to create',
|
description: 'The first name of the contact to create',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Last Name',
|
displayName: 'Last Name',
|
||||||
name: 'lastName',
|
name: 'last_name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The last name of the contact to create',
|
description: 'The last name of the contact to create',
|
||||||
|
@ -282,50 +282,68 @@ export class ActiveCampaign implements INodeType {
|
||||||
description: 'ID of the contact to get.',
|
description: 'ID of the contact to get.',
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// TODO: Does not work as expted so remove for now
|
||||||
// contact:getAll
|
// // ----------------------------------
|
||||||
// ----------------------------------
|
// // contact:getAll
|
||||||
{
|
// // ----------------------------------
|
||||||
displayName: 'Return All',
|
// {
|
||||||
name: 'returnAll',
|
// displayName: 'Full User Data',
|
||||||
type: 'boolean',
|
// name: 'fullUserData',
|
||||||
displayOptions: {
|
// type: 'boolean',
|
||||||
show: {
|
// displayOptions: {
|
||||||
operation: [
|
// show: {
|
||||||
'getAll',
|
// operation: [
|
||||||
],
|
// 'getAll',
|
||||||
resource: [
|
// ],
|
||||||
'contact',
|
// resource: [
|
||||||
],
|
// 'contact',
|
||||||
},
|
// ],
|
||||||
},
|
// },
|
||||||
default: false,
|
// },
|
||||||
description: 'If all results should be returned or only up to a given limit.',
|
// default: false,
|
||||||
},
|
// description: 'If all data of the user should be returned or an abbreviated version.',
|
||||||
{
|
// },
|
||||||
displayName: 'Limit',
|
// {
|
||||||
name: 'limit',
|
// displayName: 'Return All',
|
||||||
type: 'number',
|
// name: 'returnAll',
|
||||||
displayOptions: {
|
// type: 'boolean',
|
||||||
show: {
|
// displayOptions: {
|
||||||
operation: [
|
// show: {
|
||||||
'getAll',
|
// operation: [
|
||||||
],
|
// 'getAll',
|
||||||
resource: [
|
// ],
|
||||||
'contact',
|
// resource: [
|
||||||
],
|
// 'contact',
|
||||||
returnAll: [
|
// ],
|
||||||
false,
|
// },
|
||||||
],
|
// },
|
||||||
},
|
// default: false,
|
||||||
},
|
// description: 'If all results should be returned or only results of a given page.',
|
||||||
typeOptions: {
|
// },
|
||||||
minValue: 1,
|
// {
|
||||||
maxValue: 500,
|
// displayName: 'Page',
|
||||||
},
|
// name: 'page',
|
||||||
default: 100,
|
// type: 'number',
|
||||||
description: 'How many results to return.',
|
// displayOptions: {
|
||||||
},
|
// show: {
|
||||||
|
// operation: [
|
||||||
|
// 'getAll',
|
||||||
|
// ],
|
||||||
|
// resource: [
|
||||||
|
// 'contact',
|
||||||
|
// ],
|
||||||
|
// returnAll: [
|
||||||
|
// false,
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// typeOptions: {
|
||||||
|
// minValue: 1,
|
||||||
|
// maxValue: 500,
|
||||||
|
// },
|
||||||
|
// default: 1,
|
||||||
|
// description: 'Maximum 20 results per page get returned. Set which page to return.',
|
||||||
|
// },
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// contact:update
|
// contact:update
|
||||||
|
@ -375,14 +393,14 @@ export class ActiveCampaign implements INodeType {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'First Name',
|
displayName: 'First Name',
|
||||||
name: 'firstName',
|
name: 'first_name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'First name of the contact',
|
description: 'First name of the contact',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Last Name',
|
displayName: 'Last Name',
|
||||||
name: 'lastName',
|
name: 'last_name',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Last name of the contact',
|
description: 'Last name of the contact',
|
||||||
|
@ -447,17 +465,16 @@ export class ActiveCampaign implements INodeType {
|
||||||
let qs: IDataObject;
|
let qs: IDataObject;
|
||||||
|
|
||||||
let requestMethod: string;
|
let requestMethod: string;
|
||||||
let endpoint: string;
|
const endpoint = '/admin/api.php';
|
||||||
let returnAll = false;
|
let returnAll = false;
|
||||||
let dataKey: string | undefined;
|
let dataKeys: string[] | undefined;
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
dataKey = undefined;
|
|
||||||
resource = this.getNodeParameter('resource', 0) as string;
|
resource = this.getNodeParameter('resource', 0) as string;
|
||||||
operation = this.getNodeParameter('operation', 0) as string;
|
operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
dataKeys = undefined;
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
endpoint = '';
|
|
||||||
body = {} as IDataObject;
|
body = {} as IDataObject;
|
||||||
qs = {} as IDataObject;
|
qs = {} as IDataObject;
|
||||||
|
|
||||||
|
@ -471,27 +488,27 @@ export class ActiveCampaign implements INodeType {
|
||||||
|
|
||||||
const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean;
|
const updateIfExists = this.getNodeParameter('updateIfExists', i) as boolean;
|
||||||
if (updateIfExists === true) {
|
if (updateIfExists === true) {
|
||||||
endpoint = '/api/3/contact/sync';
|
qs.api_action = 'contact_sync';
|
||||||
} else {
|
} else {
|
||||||
endpoint = '/api/3/contacts';
|
qs.api_action = 'contact_add';
|
||||||
}
|
}
|
||||||
|
|
||||||
dataKey = 'contact';
|
dataKeys = ['subscriber_id'];
|
||||||
body.contact = {
|
|
||||||
email: this.getNodeParameter('email', i) as string,
|
body.email = this.getNodeParameter('email', i) as string;
|
||||||
} as IDataObject;
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
addAdditionalFields(body.contact as IDataObject, additionalFields);
|
addAdditionalFields(body as IDataObject, additionalFields);
|
||||||
|
|
||||||
} else if (operation === 'delete') {
|
} else if (operation === 'delete') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// contact:delete
|
// contact:delete
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'DELETE';
|
requestMethod = 'GET';
|
||||||
|
qs.api_action = 'contact_delete';
|
||||||
|
|
||||||
const contactId = this.getNodeParameter('contactId', i) as number;
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
||||||
endpoint = `/api/3/contacts/${contactId}`;
|
qs.id = contactId;
|
||||||
|
|
||||||
} else if (operation === 'get') {
|
} else if (operation === 'get') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -499,39 +516,45 @@ export class ActiveCampaign implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
|
qs.api_action = 'contact_view';
|
||||||
|
|
||||||
const contactId = this.getNodeParameter('contactId', i) as number;
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
||||||
endpoint = `/api/3/contacts/${contactId}`;
|
qs.id = contactId;
|
||||||
|
|
||||||
} else if (operation === 'getAll') {
|
// TODO: Does not work as expted so remove for now
|
||||||
// ----------------------------------
|
// } else if (operation === 'getAll') {
|
||||||
// persons:getAll
|
// // ----------------------------------
|
||||||
// ----------------------------------
|
// // contact:getAll
|
||||||
|
// // ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
// requestMethod = 'GET';
|
||||||
|
// qs.api_action = 'contact_list';
|
||||||
|
// qs.ids = 'ALL';
|
||||||
|
|
||||||
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
// returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
if (returnAll === false) {
|
// if (returnAll === false) {
|
||||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
// qs.page = this.getNodeParameter('page', i) as number;
|
||||||
}
|
// }
|
||||||
|
|
||||||
dataKey = 'contacts';
|
// const fullUserData = this.getNodeParameter('fullUserData', i) as boolean;
|
||||||
endpoint = `/api/3/contacts`;
|
// qs.full = fullUserData === true ? 1 : 0;
|
||||||
|
|
||||||
} else if (operation === 'update') {
|
} else if (operation === 'update') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// contact:update
|
// contact:update
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'PUT';
|
requestMethod = 'POST';
|
||||||
|
|
||||||
const contactId = this.getNodeParameter('contactId', i) as number;
|
const contactId = this.getNodeParameter('contactId', i) as number;
|
||||||
endpoint = `/api/3/contacts/${contactId}`;
|
qs.api_action = 'contact_edit';
|
||||||
|
qs.overwrite = 0;
|
||||||
|
|
||||||
dataKey = 'contact';
|
dataKeys = ['subscriber_id'];
|
||||||
body.contact = {} as IDataObject;
|
|
||||||
|
body.id = contactId;
|
||||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
addAdditionalFields(body.contact as IDataObject, updateFields);
|
addAdditionalFields(body as IDataObject, updateFields);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -540,9 +563,9 @@ export class ActiveCampaign implements INodeType {
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
if (returnAll === true) {
|
if (returnAll === true) {
|
||||||
responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey);
|
responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKeys);
|
||||||
} else {
|
} else {
|
||||||
responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey);
|
responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(responseData)) {
|
if (Array.isArray(responseData)) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { OptionsWithUri } from 'request';
|
||||||
* @param {object} body
|
* @param {object} body
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise<any> { // tslint:disable-line:no-any
|
export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKeys?: string[]): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = this.getCredentials('activeCampaignApi');
|
const credentials = this.getCredentials('activeCampaignApi');
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
|
@ -29,10 +29,10 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
||||||
query = {};
|
query = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query.api_key = credentials.apiKey;
|
||||||
|
query.api_output = 'json';
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
|
||||||
'Api-Token': credentials.apiKey,
|
|
||||||
},
|
|
||||||
method,
|
method,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: `${credentials.apiUrl}${endpoint}`,
|
uri: `${credentials.apiUrl}${endpoint}`,
|
||||||
|
@ -40,22 +40,27 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Object.keys(body).length !== 0) {
|
if (Object.keys(body).length !== 0) {
|
||||||
options.body = body;
|
options.form = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const returnData: IDataObject = {};
|
||||||
try {
|
try {
|
||||||
const responseData = await this.helpers.request(options);
|
const responseData = await this.helpers.request(options);
|
||||||
|
|
||||||
if (responseData.success === false) {
|
if (responseData.result_code === 0) {
|
||||||
throw new Error(`ActiveCampaign error response: ${responseData.error} (${responseData.error_info})`);
|
throw new Error(`ActiveCampaign error response: ${responseData.result_message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataKey === undefined) {
|
if (dataKeys === undefined) {
|
||||||
return responseData;
|
return responseData;
|
||||||
} else {
|
|
||||||
return responseData[dataKey] as IDataObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const dataKey of dataKeys) {
|
||||||
|
returnData[dataKey] = responseData[dataKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnData;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 403) {
|
if (error.statusCode === 403) {
|
||||||
// Return a clear error
|
// Return a clear error
|
||||||
|
@ -81,7 +86,7 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu
|
||||||
* @param {IDataObject} [query]
|
* @param {IDataObject} [query]
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise<any> { // tslint:disable-line:no-any
|
export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKeys?: string[]): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
if (query === undefined) {
|
if (query === undefined) {
|
||||||
query = {};
|
query = {};
|
||||||
|
@ -95,15 +100,10 @@ export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IE
|
||||||
|
|
||||||
let itemsReceived = 0;
|
let itemsReceived = 0;
|
||||||
do {
|
do {
|
||||||
responseData = await activeCampaignApiRequest.call(this, method, endpoint, body, query);
|
responseData = await activeCampaignApiRequest.call(this, method, endpoint, body, query, dataKeys);
|
||||||
|
|
||||||
if (dataKey === undefined) {
|
|
||||||
returnData.push.apply(returnData, responseData);
|
returnData.push.apply(returnData, responseData);
|
||||||
itemsReceived += returnData.length;
|
itemsReceived += returnData.length;
|
||||||
} else {
|
|
||||||
returnData.push.apply(returnData, responseData[dataKey]);
|
|
||||||
itemsReceived += responseData[dataKey].length;
|
|
||||||
}
|
|
||||||
|
|
||||||
query.offset = itemsReceived;
|
query.offset = itemsReceived;
|
||||||
} while (
|
} while (
|
||||||
|
|
Loading…
Reference in a new issue