Class representing a REST API request action. This action sends an HTTP request to a given base_url with specified HTTP method, headers, body, and timeout.

Hierarchy (View Summary)

Constructors

  • Creates an instance of the RestApiRequest class.

    Parameters

    • base_url: string

      The base URL for the API request.

    • body: AbstractBody = ...

      The body of the API request. Defaults to an empty body if not provided.

    • protocol: Protocol = Protocol.HTTP

      The protocol to use for the request. Defaults to HTTP.

    • method: Method = Method.GET

      The HTTP method for the request. Defaults to GET.

    • headers: Record<string, string> = ...

      The headers for the request. Defaults to { 'content-type': 'application/json' }.

    • timeout: number = 2000

      The timeout in milliseconds for the request. Defaults to 2000 ms.

    Returns RestApiRequest

Properties

base_url: string

The base URL for the API request.

The body of the API request, which can be a custom or empty body.

headers: Record<string, string>

The headers for the request, represented as key-value pairs.

method: Method

The HTTP method (GET, POST, etc.) used for the request.

protocol: Protocol

The protocol used for the request (e.g., HTTP or HTTPS).

timeout: number

The timeout for the request in milliseconds.

type: string

The type of the action, specific to REST API requests.

AbstractBody: typeof AbstractBody = AbstractBody

A reference to the AbstractBody class.

EmptyBody: typeof __class = ...

Class representing an empty body for the REST API request. This can be used when no body is required in the request.

JsonBody: typeof __class = ...

Class representing a JSON body for the REST API request. Serializes data into a JSON string for use in the request body.