mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
🐛 Fix Stripe pagination (#2402)
* Fix Stripe pagination * Fix displayOptions for type
This commit is contained in:
parent
aaa39876f9
commit
a3bfdd3805
|
@ -255,7 +255,7 @@ export class Stripe implements INodeType {
|
||||||
// charge: getAll
|
// charge: getAll
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
responseData = await handleListing.call(this, resource);
|
responseData = await handleListing.call(this, resource, i);
|
||||||
|
|
||||||
} else if (operation === 'update') {
|
} else if (operation === 'update') {
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ export class Stripe implements INodeType {
|
||||||
// coupon: getAll
|
// coupon: getAll
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
responseData = await handleListing.call(this, resource);
|
responseData = await handleListing.call(this, resource, i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ export class Stripe implements INodeType {
|
||||||
qs.email = filters.email;
|
qs.email = filters.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await handleListing.call(this, resource, qs);
|
responseData = await handleListing.call(this, resource, i, qs);
|
||||||
|
|
||||||
} else if (operation === 'update') {
|
} else if (operation === 'update') {
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,16 @@ export const tokenFields = [
|
||||||
value: 'cardToken',
|
value: 'cardToken',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'token',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Card Number',
|
displayName: 'Card Number',
|
||||||
|
|
|
@ -154,19 +154,25 @@ export async function loadResource(
|
||||||
export async function handleListing(
|
export async function handleListing(
|
||||||
this: IExecuteFunctions,
|
this: IExecuteFunctions,
|
||||||
resource: string,
|
resource: string,
|
||||||
|
i: number,
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
) {
|
) {
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
let responseData;
|
let responseData;
|
||||||
|
|
||||||
responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, qs, {});
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
responseData = responseData.data;
|
const limit = this.getNodeParameter('limit', i, 0) as number;
|
||||||
|
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
do {
|
||||||
|
responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, {}, qs);
|
||||||
|
returnData.push(...responseData.data);
|
||||||
|
|
||||||
if (!returnAll) {
|
if (!returnAll && returnData.length >= limit) {
|
||||||
const limit = this.getNodeParameter('limit', 0) as number;
|
return returnData.slice(0, limit);
|
||||||
responseData = responseData.slice(0, limit);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return responseData;
|
qs.starting_after = returnData[returnData.length - 1].id;
|
||||||
|
} while (responseData.has_more);
|
||||||
|
|
||||||
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue