feat: implement getFieldsByAppId method

This commit is contained in:
StevanFreeborn
2023-02-03 11:45:15 -06:00
parent 0559f60726
commit 59a12cb8b6
6 changed files with 84 additions and 5 deletions
+18
View File
@@ -9,6 +9,7 @@ import { type GetPagedAppsResponse } from './GetPagedAppsResponse';
import { type App } from './App';
import { type CollectionResponse } from './CollectionResponse';
import { type Field } from './Field';
import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse';
/**
* @class OnspringClient - A client that can communicate with the Onspring API.
@@ -145,6 +146,23 @@ export class OnspringClient {
return apiResponse.AsFieldCollectionType();
}
public async getFieldsByAppId(
appId: number,
pagingRequest: PagingRequest = new PagingRequest(1, 50)
): Promise<ApiResponse<GetPagedFieldsResponse>> {
const endpoint = EndpointFactory.getFieldsByAppIdEndpoint(
appId,
pagingRequest
);
const apiResponse = await this.get<any>(endpoint);
if (apiResponse.isSuccessful === false) {
return apiResponse;
}
return apiResponse.AsGetPagedFieldsResponseType();
}
/**
* @method get - Makes a GET request to the specified endpoint.
* @param {string} endpoint - The endpoint that will be used to make the request.