fix: added dependencies for development. feat: added axios as dependency. feat: added some initial modeals. feat: setup unit testing
This commit is contained in:
+22
-6
@@ -1,9 +1,25 @@
|
||||
class OnspringClient {
|
||||
private readonly _baseUrl: string;
|
||||
private readonly _apiKey: string;
|
||||
import { AxiosInstance } from "axios";
|
||||
import axios from "axios";
|
||||
import { ArgumentValidator } from "./models/ArgumentValidator";
|
||||
|
||||
constructor(baseUrl: string, apiKey: string) {
|
||||
this._baseUrl = baseUrl;
|
||||
this._apiKey = apiKey;
|
||||
export class OnspringClient {
|
||||
protected readonly client: AxiosInstance;
|
||||
|
||||
constructor(baseUrl: string | undefined | null, apiKey: string | undefined | null) {
|
||||
if (ArgumentValidator.isValidUrl(baseUrl) === false) {
|
||||
throw new Error("baseUrl must be an absolute and well-formed URI.");
|
||||
}
|
||||
|
||||
if (ArgumentValidator.isNullOrWhiteSpace(apiKey)) {
|
||||
throw new Error("apiKey cannot be null/empty/whitespace.");
|
||||
}
|
||||
|
||||
this.client = axios.create({
|
||||
baseURL: baseUrl,
|
||||
headers: {
|
||||
"x-apikey": apiKey,
|
||||
"x-api-version": "2",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user