feat: implement queryRecords method

This commit is contained in:
StevanFreeborn
2023-02-12 19:11:42 -06:00
parent 1255b93d96
commit 71ef5ffb07
2 changed files with 228 additions and 1 deletions
+17
View File
@@ -25,6 +25,7 @@ import { type GetRecordRequest } from './GetRecordRequest';
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest';
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse';
import { type GetRecordsRequest } from './GetRecordsRequest';
import { type QueryRecordsRequest } from './QueryRecordsRequest';
/**
* @class OnspringClient - A client that can communicate with the Onspring API.
@@ -375,6 +376,22 @@ export class OnspringClient {
return apiResponse.asRecordCollectionType();
}
public async queryRecords(
request: QueryRecordsRequest
): Promise<ApiResponse<GetPagedRecordsResponse>> {
const endpoint = EndpointFactory.getQueryRecordsEndpoint();
const { pagingRequest, ...data } = request;
const params = { ...pagingRequest };
const apiResponse = await this.post<any>(endpoint, data, { params });
if (apiResponse.isSuccessful === false) {
return apiResponse;
}
return apiResponse.asGetPagedRecordsResponseType();
}
/**
* @method getReportsByAppId - Gets a paged list of reports by the app id.
* @param {number} appId - The id of the app to get the reports for.