fix: enabled strict null checks and made changes to deal with this compiler change. fix: modified endpoint factory methods to not need baseURL to be passed in. instead just return endpoint because the axios client with already have a default url set as part of constructing a new onspring client instance

This commit is contained in:
StevanFreeborn
2023-02-02 13:53:02 -06:00
parent 88bf080847
commit d453f19c97
8 changed files with 137 additions and 178 deletions
+4 -12
View File
@@ -29,7 +29,7 @@ export class OnspringClient {
baseUrl: string | undefined | null,
apiKey: string | undefined | null
) {
if (ArgumentValidator.isValidUrl(baseUrl) === false) {
if (ArgumentValidator.isValidUrl(baseUrl) === false || baseUrl === null) {
throw new Error('baseUrl must be an absolute and well-formed URI.');
}
@@ -48,9 +48,7 @@ export class OnspringClient {
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating if the client can connect to the Onspring API.
*/
public async canConnect(): Promise<boolean> {
const endpoint = EndpointFactory.getPingEndpoint(
this._client.defaults.baseURL
);
const endpoint = EndpointFactory.getPingEndpoint();
const response = await this.get<any>(endpoint);
return response.isSuccessful;
@@ -64,10 +62,7 @@ export class OnspringClient {
public async getApps(
pagingRequest: PagingRequest = new PagingRequest(1, 50)
): Promise<ApiResponse<GetPagedAppsResponse>> {
const endpoint = EndpointFactory.getAppsEndpoint(
this._client.defaults.baseURL,
pagingRequest
);
const endpoint = EndpointFactory.getAppsEndpoint(pagingRequest);
var apiResponse = await this.get<any>(endpoint);
@@ -79,10 +74,7 @@ export class OnspringClient {
}
public async getAppById(appId: number): Promise<ApiResponse<App>> {
const endpoint = EndpointFactory.getAppByIdEndpoint(
this._client.defaults.baseURL,
appId
);
const endpoint = EndpointFactory.getAppByIdEndpoint(appId);
var apiResponse = await this.get<any>(endpoint);