fix pagination

This commit is contained in:
shraddha shaligram 2020-06-23 20:29:47 -07:00
parent 83828a19ab
commit 69a1f8af00
6 changed files with 55 additions and 47 deletions

View file

@ -1,14 +1,7 @@
import { ICredentialType, NodePropertyTypes } from 'n8n-workflow';
const userScopes = [
'meeting:read',
'meeting:write',
'user:read',
'user:write',
'user_profile',
'webinar:read',
'webinar:write'
];
import {
ICredentialType,
NodePropertyTypes,
} from 'n8n-workflow';
export class ZoomOAuth2Api implements ICredentialType {
name = 'zoomOAuth2Api';
@ -27,7 +20,6 @@ export class ZoomOAuth2Api implements ICredentialType {
type: 'hidden' as NodePropertyTypes,
default: 'https://zoom.us/oauth/token'
},
{
displayName: 'Scope',
name: 'scope',

View file

@ -75,6 +75,7 @@ export async function zoomApiRequestAllItems(
// tslint:disable-line:no-any
const returnData: IDataObject[] = [];
let responseData;
query.page_number = 0;
do {
responseData = await zoomApiRequest.call(
this,
@ -83,14 +84,21 @@ export async function zoomApiRequestAllItems(
body,
query
);
query.page_number = responseData['page_number'];
query.page_number++;
returnData.push.apply(returnData, responseData[propertyName]);
// zoom free plan rate limit is 1 request/second
// TODO just wait when the plan is free
await wait();
} while (
responseData['page_number'] !== undefined &&
responseData['page_number'] !== ''
responseData.page_count !== responseData.page_number
);
return returnData;
}
function wait() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 1000);
});
}

View file

@ -39,7 +39,7 @@ export const meetingOperations = [
name: 'Update',
value: 'update',
description: 'Update a meeting',
}
},
],
default: 'create',
description: 'The operation to perform.',
@ -69,7 +69,7 @@ export const meetingFields = [
description: 'User ID or email address of user.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -83,7 +83,7 @@ export const meetingFields = [
resource: [
'meeting',
],
}
},
},
options: [
{
@ -209,7 +209,7 @@ export const meetingFields = [
],
default: 2,
description: 'Meeting type.'
description: 'Meeting type.',
},
{
displayName: 'Muting before entry',
@ -219,7 +219,7 @@ export const meetingFields = [
description: 'Mute participants upon entry.',
},
{
displayName: 'Participant Video',
displayName: 'Participant video',
name: 'participant_video',
type: 'boolean',
default: false,
@ -308,7 +308,7 @@ export const meetingFields = [
description: 'Meeting ID.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -398,13 +398,13 @@ export const meetingFields = [
},
typeOptions: {
minValue: 1,
maxValue: 300
maxValue: 300,
},
default: 30,
description: 'How many results to return.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -456,7 +456,7 @@ export const meetingFields = [
displayOptions: {
show: {
operation: [
'delete'
'delete',
],
resource: [
'meeting',
@ -521,7 +521,7 @@ export const meetingFields = [
description: 'Meeting ID.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -667,7 +667,7 @@ export const meetingFields = [
],
default: 2,
description: 'Meeting type.'
description: 'Meeting type.',
},
{
displayName: 'Muting before entry',

View file

@ -95,7 +95,7 @@ export const meetingRegistrantFields = [
description: 'First Name.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -109,7 +109,7 @@ export const meetingRegistrantFields = [
resource: [
'meetingRegistrants',
],
}
},
},
options: [
{
@ -202,7 +202,7 @@ export const meetingRegistrantFields = [
},
],
default: '',
description: 'Meeting type.'
description: 'Meeting type.',
},
{
displayName: 'Role in purchase process',
@ -228,7 +228,7 @@ export const meetingRegistrantFields = [
],
default: '',
description: 'Role in purchase process.'
description: 'Role in purchase process.',
},
{
displayName: 'State',
@ -304,13 +304,13 @@ export const meetingRegistrantFields = [
},
typeOptions: {
minValue: 1,
maxValue: 300
maxValue: 300,
},
default: 30,
description: 'How many results to return.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -324,7 +324,7 @@ export const meetingRegistrantFields = [
resource: [
'meetingRegistrants',
],
}
},
},
options: [
{
@ -412,7 +412,7 @@ export const meetingRegistrantFields = [
description: `Registrant Status.`,
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',

View file

@ -69,7 +69,7 @@ export const webinarFields = [
description: 'User ID or email address of user.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -263,7 +263,7 @@ export const webinarFields = [
},
],
default: 5,
description: 'Webinar type.'
description: 'Webinar type.',
},
],
@ -290,7 +290,7 @@ export const webinarFields = [
description: 'Webinar ID.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -380,7 +380,7 @@ export const webinarFields = [
},
typeOptions: {
minValue: 1,
maxValue: 300
maxValue: 300,
},
default: 30,
description: 'How many results to return.',
@ -397,7 +397,7 @@ export const webinarFields = [
displayOptions: {
show: {
operation: [
'delete'
'delete',
],
resource: [
'webinarId',
@ -456,7 +456,7 @@ export const webinarFields = [
description: 'User ID or email address of user.',
},
{
displayName: 'Additional settings',
displayName: 'Additional fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
@ -470,7 +470,7 @@ export const webinarFields = [
resource: [
'webinar',
],
}
},
},
options: [
{

View file

@ -203,13 +203,21 @@ export class Zoom implements INodeType {
//https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings
const userId = this.getNodeParameter('userId', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const additionalFields = this.getNodeParameter(
'additionalFields',
i
) as IDataObject;
if (additionalFields.type) {
qs.type = additionalFields.type as string;
}
if (returnAll) {
responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/users/${userId}/meetings`, {}, qs);
responseData = await zoomApiRequestAllItems.call(this, 'meetings', 'GET', `/users/${userId}/meetings`, {}, qs);
} else {
const limit = this.getNodeParameter('limit', i) as number;
qs.page_size = limit;
qs.page_size = this.getNodeParameter('limit', i) as number;;
responseData = await zoomApiRequest.call(this, 'GET', `/users/${userId}/meetings`, {}, qs);
responseData = responseData.results;
}
}