feat: added tests for getFileById method. fix: refactor getApiResponse and TryToGetMessage methods in ApiResponseFactory class to be able to return the proper string message when the responseType passed to axios was 'stream'

This commit is contained in:
Stevan Freeborn
2023-02-16 16:57:52 -06:00
parent 4370574bbd
commit ee5aaf3c1f
5 changed files with 244 additions and 27 deletions
+5 -5
View File
@@ -252,7 +252,7 @@ export class OnspringClient {
responseType: 'stream',
});
const apiResponse = ApiResponseFactory.getApiResponse<any>(response);
const apiResponse = await ApiResponseFactory.getApiResponse<any>(response);
if (apiResponse.isSuccessful === false) {
return apiResponse;
@@ -511,7 +511,7 @@ export class OnspringClient {
config: AxiosRequestConfig = {}
): Promise<ApiResponse<T>> {
const response = await this._client.get(endpoint, config);
const apiResponse = ApiResponseFactory.getApiResponse<T>(response);
const apiResponse = await ApiResponseFactory.getApiResponse<T>(response);
return apiResponse;
}
@@ -528,7 +528,7 @@ export class OnspringClient {
config: AxiosRequestConfig = {}
): Promise<ApiResponse<T>> {
const response = await this._client.post(endpoint, data, config);
const apiResponse = ApiResponseFactory.getApiResponse<T>(response);
const apiResponse = await ApiResponseFactory.getApiResponse<T>(response);
return apiResponse;
}
@@ -545,7 +545,7 @@ export class OnspringClient {
config: AxiosRequestConfig = {}
): Promise<ApiResponse<T>> {
const response = await this._client.put(endpoint, data, config);
const apiResponse = ApiResponseFactory.getApiResponse<T>(response);
const apiResponse = await ApiResponseFactory.getApiResponse<T>(response);
return apiResponse;
}
@@ -560,7 +560,7 @@ export class OnspringClient {
config: AxiosRequestConfig = {}
): Promise<ApiResponse<T>> {
const response = await this._client.delete(endpoint, config);
const apiResponse = ApiResponseFactory.getApiResponse<T>(response);
const apiResponse = await ApiResponseFactory.getApiResponse<T>(response);
return apiResponse;
}
}