Add Trello List getAll/getCards functionality (#1350)

* Fix to add List.getCards

*  Small improvements to #1347

*  Minor formatting improvements

*  Small fix

Co-authored-by: tumf <y.takahara@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza
2021-01-19 09:09:03 -05:00
committed by GitHub
parent 9911348166
commit 4336088741
5 changed files with 283 additions and 4 deletions

View File

@@ -53,3 +53,26 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
throw error;
}
}
export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
query.limit = 30;
query.sort = '-id';
const returnData: IDataObject[] = [];
let responseData;
do {
responseData = await apiRequest.call(this, method, endpoint, body, query);
returnData.push.apply(returnData, responseData);
if (responseData.length !== 0) {
query.before = responseData[responseData.length - 1].id;
}
} while (
query.limit <= responseData.length
);
return returnData;
}