Skip to main content

Class: HTTPRequest

HTTPRequest class for making HTTP requests to the Tripay API.

Constructors​

constructor​

• new HTTPRequest(options?)

Constructs a new instance of the HTTPRequest class.

Parameters​

NameTypeDescription
options?RequestOptionsThe options for the HTTP request.

Defined in​

src/request/request.ts:27

Properties​

apiToken​

• Private Optional apiToken: string

Defined in​

src/request/request.ts:17


baseUrl​

• Private baseUrl: string

Defined in​

src/request/request.ts:18


body​

• Private body: HTTPBody = {}

Defined in​

src/request/request.ts:15


params​

• Private params: HTTPParams = {}

Defined in​

src/request/request.ts:16

Methods​

fetch​

▸ fetch(url, method?): Promise<ITripayResponse>

Fetches data asynchronously from the given URL.

Throws

If the request failed.

Parameters​

NameTypeDefault valueDescription
urlstringundefinedThe URL to fetch data from.
method"GET" | "POST"'GET'The HTTP method to use for the request. Can be 'GET' or 'POST'.

Returns​

Promise<ITripayResponse>

A Promise that resolves to a ITripayResponse object.

Defined in​

src/request/request.ts:112


generateUserAgent​

▸ Private generateUserAgent(): string

Generates a user agent string for the current environment.

Returns​

string

The generated user agent string.

Defined in​

src/request/request.ts:63


removeUndefinedValues​

▸ Private removeUndefinedValues(obj): Record<string, string>

Removes undefined values from an object and converts other values to strings.

Parameters​

NameTypeDescription
objRecord<string, any>The object to remove undefined values from.

Returns​

Record<string, string>

A new object with undefined values removed and other values converted to strings.

Defined in​

src/request/request.ts:72


setBody​

▸ setBody(body): HTTPRequest

Sets the body of the function.

Parameters​

NameTypeDescription
bodyHTTPBodyThe body to be set.

Returns​

HTTPRequest

This function does not return a value.

Defined in​

src/request/request.ts:42


setParams​

▸ setParams(params): HTTPRequest

Sets the params for the HTTPRequest.

Parameters​

NameTypeDescription
paramsHTTPParamsThe params to be set.

Returns​

HTTPRequest

  • The updated HTTPRequest.

Defined in​

src/request/request.ts:53