feat: implement getFieldById method

This commit is contained in:
StevanFreeborn
2023-02-02 21:37:40 -06:00
parent 8b61dfa36a
commit a1d3683603
6 changed files with 340 additions and 2 deletions
+12
View File
@@ -8,6 +8,7 @@ import { PagingRequest } from './PagingRequest';
import { GetPagedAppsResponse } from './GetPagedAppsResponse';
import { App } from './App';
import { CollectionResponse } from './CollectionResponse';
import { Field } from './Field';
/**
* @class OnspringClient - A client that can communicate with the Onspring API.
@@ -109,6 +110,17 @@ export class OnspringClient {
return apiResponse.AsAppCollectionType();
}
public async getFieldById(fieldId: number): Promise<ApiResponse<Field>> {
const endpoint = EndpointFactory.getFieldByIdEndpoint(fieldId);
const apiResponse = await this.get<any>(endpoint);
if (apiResponse.isSuccessful === false) {
return apiResponse;
}
return apiResponse.AsFieldType();
}
/**
* @method get - Makes a GET request to the specified endpoint.
* @param {string} endpoint - The endpoint that will be used to make the request.