mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -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
|
||||
// ----------------------------------
|
||||
|
||||
responseData = await handleListing.call(this, resource);
|
||||
responseData = await handleListing.call(this, resource, i);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
|
@ -313,7 +313,7 @@ export class Stripe implements INodeType {
|
|||
// 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;
|
||||
}
|
||||
|
||||
responseData = await handleListing.call(this, resource, qs);
|
||||
responseData = await handleListing.call(this, resource, i, qs);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
|
|
|
@ -43,6 +43,16 @@ export const tokenFields = [
|
|||
value: 'cardToken',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'token',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Card Number',
|
||||
|
|
|
@ -154,19 +154,25 @@ export async function loadResource(
|
|||
export async function handleListing(
|
||||
this: IExecuteFunctions,
|
||||
resource: string,
|
||||
i: number,
|
||||
qs: IDataObject = {},
|
||||
) {
|
||||
const returnData: IDataObject[] = [];
|
||||
let responseData;
|
||||
|
||||
responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, qs, {});
|
||||
responseData = responseData.data;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
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) {
|
||||
const limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
if (!returnAll && returnData.length >= limit) {
|
||||
return returnData.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