Class: ApiClient#

Provides a lightweight wrapper for the axios HTTP client that can perform automatic serialization, header assignment and automatic request retries.

Hierarchy#

  • ApiClient

Index#

Constructors#

Properties#

Methods#

Constructors#

constructor#

+ new ApiClient(config: Configuration): ApiClient

Defined in src/ApiClient.ts:33

Parameters:#

Name

Type

config

Configuration

Returns: ApiClient

Properties#

axios#

Private axios: AxiosInstance

Defined in src/ApiClient.ts:31


config#

Private config: Configuration

Defined in src/ApiClient.ts:32


cookies#

Private cookies: Map<string, string> = new Map()

Defined in src/ApiClient.ts:33

Methods#

clearCookies#

clearCookies(): void

Defined in src/ApiClient.ts:54

Deletes all cached cookies.

Returns: void


delete#

delete(url: string, query?: any, headers?: any): Promise<void>

Defined in src/ApiClient.ts:64

Sends an HTTP DELETE request to the specified url using the given query and headers values.

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<void>


get#

get(url: string, query?: any, headers?: any): Promise<any | undefined>

Defined in src/ApiClient.ts:77

Sends an HTTP GET request to the specified url using the given query and headers values and returns the HTTP response.

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<any | undefined>

The HTTP response.


getList#

getList<T>(url: string, type: {}, query?: any, headers?: any): Promise<T[] | undefined>

Defined in src/ApiClient.ts:106

Sends an HTTP GET request to the specified url using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

type

{}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T[] | undefined>


getObject#

getObject<T>(url: string, type: {}, query?: any, headers?: any): Promise<T | undefined>

Defined in src/ApiClient.ts:89

Sends an HTTP GET request to the specified url using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

type

{}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T | undefined>



post#

post(url: string, body: any, query?: any, headers?: any): Promise<any | undefined>

Defined in src/ApiClient.ts:143

Sends an HTTP POST request to the specified url with the provided body using the given query and headers values and returns the HTTP response.

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<any | undefined>

The HTTP response.


postList#

postList<T>(url: string, body: any, type?: undefined | {}, query?: any, headers?: any): Promise<T[] | undefined>

Defined in src/ApiClient.ts:180

Sends an HTTP POST request to the specified url with the provided body using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

type?

undefined | {}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T[] | undefined>


postObject#

postObject<T>(url: string, body: any, type: {}, query?: any, headers?: any): Promise<T | undefined>

Defined in src/ApiClient.ts:161

Sends an HTTP POST request to the specified url with the provided body using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

type

{}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T | undefined>


put#

put(url: string, body: any, query?: any, headers?: any): Promise<any | undefined>

Defined in src/ApiClient.ts:200

Sends an HTTP PUT request to the specified url with the provided body using the given query and headers values and returns the HTTP response.

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<any | undefined>

The HTTP response.


putList#

putList<T>(url: string, body: any, type: {}, query?: any, headers?: any): Promise<T[] | undefined>

Defined in src/ApiClient.ts:237

Sends an HTTP PUT request to the specified url with the provided body using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

type

{}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T[] | undefined>


putObject#

putObject<T>(url: string, body: any, type: {}, query?: any, headers?: any): Promise<T | undefined>

Defined in src/ApiClient.ts:218

Sends an HTTP PUT request to the specified url with the provided body using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Description

url

string

The url to send the request to.

body

any

The data to send in the body of the request.

type

{}

The class type of the result to return.

query?

any

The query parameters to append to the url.

headers?

any

The headers to append to the request.

Returns: Promise<T | undefined>


send#

send(url: string, method: string, body: any, query?: any, headers?: any, retryDelay: number, retryCount: number): Promise<any>

Defined in src/ApiClient.ts:260

Sends an HTTP request to the specified url with the provided body using the given query and headers values and returns the HTTP response.

Parameters:#

Name

Type

Default value

Description

url

string

-

The url to send the request to.

method

string

-

The HTTP method to send the request as.

body

any

-

The data to send in the body of the request.

query?

any

-

The query parameters to append to the url.

headers?

any

-

The headers to append to the request.

retryDelay

number

250

The amount of time to wait before the next retry attempt.

retryCount

number

0

The number of retry attempts that have occurred so far.

Returns: Promise<any>

The HTTP response.


sendList#

sendList<T>(url: string, method: string, body?: any, type?: undefined | {}, query?: any, headers?: any, retryDelay: number, retryCount: number): Promise<T[] | undefined>

Defined in src/ApiClient.ts:492

Sends an HTTP request to the specified url with the provided body using the given query and headers values and returns a list of results of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Default value

Description

url

string

-

The url to send the request to.

method

string

-

The HTTP method to send the request as.

body?

any

-

The data to send in the body of the request.

type?

undefined | {}

-

The class type of the result to return.

query?

any

-

The query parameters to append to the url.

headers?

any

-

The headers to append to the request.

retryDelay

number

250

The amount of time to wait before the next retry attempt.

retryCount

number

0

The number of retry attempts that have occurred so far.

Returns: Promise<T[] | undefined>


sendObject#

sendObject<T>(url: string, method: string, body: any, type: {}, query?: any, headers?: any, retryDelay: number, retryCount: number): Promise<T | undefined>

Defined in src/ApiClient.ts:373

Sends an HTTP request to the specified url with the provided body using the given query and headers values and returns a result of the given type.

Type parameters:#

Name

T

Parameters:#

Name

Type

Default value

Description

url

string

-

The url to send the request to.

method

string

-

The HTTP method to send the request as.

body

any

-

The data to send in the body of the request.

type

{}

-

The class type of the result to return.

query?

any

-

The query parameters to append to the url.

headers?

any

-

The headers to append to the request.

retryDelay

number

250

The amount of time to wait before the next retry attempt.

retryCount

number

0

The number of retry attempts that have occurred so far.

Returns: Promise<T | undefined>


storeCookies#

PrivatestoreCookies(cookies: string[]): void

Defined in src/ApiClient.ts:607

Merges the provided list of set cookies from a given response to our local cache.

Parameters:#

Name

Type

Description

cookies

string[]

The list of cookies to merge.

Returns: void