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
| Name | Type | Description |
|---|---|---|
options? | RequestOptions | The options for the HTTP request. |
Defined in
Properties
apiToken
• Private Optional apiToken: string
Defined in
baseUrl
• Private baseUrl: string
Defined in
body
• Private body: HTTPBody = {}
Defined in
params
• Private params: HTTPParams = {}
Defined in
Methods
fetch
▸ fetch(url, method?): Promise<ITripayResponse>
Fetches data asynchronously from the given URL.
Throws
If the request failed.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
url | string | undefined | The 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
generateUserAgent
▸ Private generateUserAgent(): string
Generates a user agent string for the current environment.
Returns
string
The generated user agent string.
Defined in
removeUndefinedValues
▸ Private removeUndefinedValues(obj): Record<string, string>
Removes undefined values from an object and converts other values to strings.
Parameters
| Name | Type | Description |
|---|---|---|
obj | Record<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
setBody
▸ setBody(body): HTTPRequest
Sets the body of the function.
Parameters
| Name | Type | Description |
|---|---|---|
body | HTTPBody | The body to be set. |
Returns
This function does not return a value.
Defined in
setParams
▸ setParams(params): HTTPRequest
Sets the params for the HTTPRequest.
Parameters
| Name | Type | Description |
|---|---|---|
params | HTTPParams | The params to be set. |
Returns
- The updated HTTPRequest.