Mattermost improvements

This commit is contained in:
ricardo
2020-04-22 12:08:53 -05:00
parent b395ac0686
commit 3596807630
2 changed files with 242 additions and 6 deletions

View File

@@ -4,8 +4,13 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';
import { OptionsWithUri } from 'request';
import { IDataObject } from 'n8n-workflow';
import {
OptionsWithUri,
} from 'request';
import {
IDataObject,
} from 'n8n-workflow';
export interface IAttachment {
fields: {
@@ -65,3 +70,22 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
throw error;
}
}
export async function apiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = [];
let responseData;
query.page = 0;
query.per_page = 100;
do {
responseData = await apiRequest.call(this, method, endpoint, body, query);
query.page++;
returnData.push.apply(returnData, responseData);
} while (
responseData.length !== 0
);
return returnData;
}