Skip to content

ApiClient

Defined in: ApiClient.ts:18

Base class providing common functionality for all API clients.

ApiClientOptions and BaseUrl

new ApiClient(baseUrl, options?): ApiClient;

Defined in: ApiClient.ts:74

string

The base URL for all API requests. BaseUrl

ApiClientOptions

Optional configuration options. ApiClientOptions

ApiClient

apiPrefix: string | undefined;

Defined in: ApiClient.ts:32

ApiClientOptions.apiPrefix


authentication: Authentication | undefined;

Defined in: ApiClient.ts:42

ApiClientOptions.authentication


baseUrl: string;

Defined in: ApiClient.ts:27

BaseUrl


cache:
| Cache
| undefined;

Defined in: ApiClient.ts:52

ApiClientOptions.cache


customFetch:
| ((input, init?) => Promise<Response>)
| undefined;

Defined in: ApiClient.ts:37

ApiClientOptions.customFetch


debug: boolean | undefined;

Defined in: ApiClient.ts:67

ApiClientOptions.debug


defaultLocale: string | undefined;

Defined in: ApiClient.ts:47

ApiClientOptions.defaultLocale


logger:
| {
debug?: LogMethod;
error?: LogMethod;
http?: LogMethod;
info?: LogMethod;
silly?: LogMethod;
verbose?: LogMethod;
warn?: LogMethod;
}
| undefined;

Defined in: ApiClient.ts:62

ApiClientOptions.logger


serializer:
| Serializer
| undefined;

Defined in: ApiClient.ts:57

ApiClientOptions.serializer

addAuthorizationHeader(options): Promise<RequestInit>;

Defined in: ApiClient.ts:220

Adds an authorization header to the provided RequestInit options if authentication of type “Basic” is configured. If the authentication type is “OAuth”, it will fetch a new access token or use the stored access token if it exists and is still valid. if the authentication type is “Custom”, it will use the provided value.

RequestInit | undefined

The RequestInit options to which the authorization header should be added.

Promise<RequestInit>

The updated RequestInit options with the authorization header, if applicable.


fetch(input, init?): Promise<FetchReturn>;

Defined in: ApiClient.ts:106

Uses customFetch if it is set, otherwise uses the default fetch

RequestInfo | URL

RequestInfo

RequestInit

RequestInit

Promise<FetchReturn>

a response wrapped in a promise


protected getAccessToken(__namedParameters): Promise<OAuthTokenResponse>;

Defined in: ApiClient.ts:138

Fetch the OAuth token from the BaseUrl

OAuthCredentials

Promise<OAuthTokenResponse>

params - The credentials for getting an OAuth token. OAuthCredentials


getCachedResponse<T>(cacheKey): Promise<
| NonNullable<Awaited<T>>
| null>;

Defined in: ApiClient.ts:310

Retrieves a cached response from the cache.

T

string

The cache key to use for retrieving the cached response.

Promise< | NonNullable<Awaited<T>> | null>

A promise wrapping the cached response as a generic type.


log(level, message): void;

Defined in: ApiClient.ts:295

Calls the appropriate logger method based on level

LogLevels

level based on npm log levels

string

the message to log

void