Extended Hubspot

This commit is contained in:
ricardo
2020-04-17 17:42:41 -04:00
parent 6b729b9ba7
commit 000921b796
6 changed files with 3141 additions and 35 deletions

View File

@@ -4,9 +4,9 @@ import {
import {
IExecuteFunctions,
IExecuteSingleFunctions,
IHookFunctions,
ILoadOptionsFunctions,
IExecuteSingleFunctions,
} from 'n8n-core';
import {
@@ -31,11 +31,10 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
try {
return await this.helpers.request!(options);
} catch (error) {
if (error.response && error.response.body && error.response.body.errors) {
// Try to return the error prettier
const errorMessages = error.response.body.errors.map((e: IDataObject) => e.message);
throw new Error(`Hubspot error response [${error.statusCode}]: ${errorMessages.join(' | ')}`);
const errorMessages = error.response.body.errors;
throw new Error(`Hubspot error response [${error.statusCode}]: ${errorMessages.join('|')}`);
}
throw error;
@@ -54,6 +53,7 @@ export async function hubspotApiRequestAllItems(this: IHookFunctions | IExecuteF
query.limit = query.limit || 250;
query.count = 100;
body.limit = body.limit || 100;
do {
responseData = await hubspotApiRequest.call(this, method, endpoint, body, query);