mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(Lemlist Node): Fix pagination issues with campaigns and activities (#6734)
This commit is contained in:
parent
4098c30cb3
commit
c3e76ec697
|
@ -51,11 +51,11 @@ export async function lemlistApiRequestAllItems(
|
||||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||||
method: string,
|
method: string,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
let responseData;
|
let responseData;
|
||||||
const qs: IDataObject = {};
|
|
||||||
|
|
||||||
qs.limit = 100;
|
qs.limit = 100;
|
||||||
qs.offset = 0;
|
qs.offset = 0;
|
||||||
|
|
|
@ -123,7 +123,7 @@ export class Lemlist implements INodeType {
|
||||||
|
|
||||||
// https://developer.lemlist.com/#activities
|
// https://developer.lemlist.com/#activities
|
||||||
|
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
||||||
const qs = {} as IDataObject;
|
const qs = {} as IDataObject;
|
||||||
const filters = this.getNodeParameter('filters', i);
|
const filters = this.getNodeParameter('filters', i);
|
||||||
|
@ -132,11 +132,11 @@ export class Lemlist implements INodeType {
|
||||||
Object.assign(qs, filters);
|
Object.assign(qs, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs);
|
if (returnAll) {
|
||||||
|
responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/activities', qs);
|
||||||
if (!returnAll) {
|
} else {
|
||||||
const limit = this.getNodeParameter('limit', 0);
|
qs.limit = this.getNodeParameter('limit', i);
|
||||||
responseData = responseData.slice(0, limit);
|
responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (resource === 'campaign') {
|
} else if (resource === 'campaign') {
|
||||||
|
@ -151,13 +151,15 @@ export class Lemlist implements INodeType {
|
||||||
|
|
||||||
// https://developer.lemlist.com/#list-all-campaigns
|
// https://developer.lemlist.com/#list-all-campaigns
|
||||||
|
|
||||||
responseData = await lemlistApiRequest.call(this, 'GET', '/campaigns');
|
|
||||||
|
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
||||||
if (!returnAll) {
|
if (returnAll) {
|
||||||
const limit = this.getNodeParameter('limit', i);
|
responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/campaigns', {});
|
||||||
responseData = responseData.slice(0, limit);
|
} else {
|
||||||
|
const qs = {
|
||||||
|
limit: this.getNodeParameter('limit', i),
|
||||||
|
};
|
||||||
|
responseData = await lemlistApiRequest.call(this, 'GET', '/campaigns', {}, qs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (resource === 'lead') {
|
} else if (resource === 'lead') {
|
||||||
|
@ -277,7 +279,7 @@ export class Lemlist implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/unsubscribes');
|
responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/unsubscribes', {});
|
||||||
} else {
|
} else {
|
||||||
const qs = {
|
const qs = {
|
||||||
limit: this.getNodeParameter('limit', i),
|
limit: this.getNodeParameter('limit', i),
|
||||||
|
|
Loading…
Reference in a new issue