import { HttpClient } from "./http-client"; import type { Config, QueryParamsOf } from "./types"; /** * BaseApi class provides basic functionality for making API requests. */ export declare abstract class BaseApi { protected apiKey?: string; protected readonly environment: string; protected readonly base_api: HttpClient; protected readonly headers: Record; protected readonly verbose: boolean; /** * @param {Config} config - Configuration object. * @param {string} [config.apiKey] - API key. * @param {Environment} [config.environment='prod'] - Environment for the API (e.g. 'dev', 'prod'). */ constructor(config: Config); /** * Retrieves the headers associated with the API instance. * * @returns An object containing key-value pairs representing the headers. */ getHeaders(): Record; /** * Retrieves the underlying HTTP client backing this API instance. * * @returns An HttpClient instance representing the base API instance. */ getBaseApi(): HttpClient; /** * Retrieves the API key associated with the API instance, if it exists. * * @returns The API key as a string if it is set, or undefined if not set. */ getApiKey(): string | undefined; /** * Sets the API key for the API instance. * * @param {string} apiKey - The API key to set. */ setApiKey(apiKey: string): void; /** * Retrieves the environment associated with the API instance. * * @returns A string representing the environment (e.g., 'dev', 'prod'). */ getEnvironment(): string; /** * Makes a GET request to the given endpoint. * * `params` is constrained by its own values rather than by an index signature, * so a purpose-built params interface can be passed directly — see * {@link QueryParamsOf}. Pagination is *not* baked into this signature: the * scheme differs per endpoint, so each params type declares its own (see * `OffsetPagination` / `PagePagination` / `CursorPagination`). * * @param {string} endpoint - Endpoint for the request. * @returns {Promise} - Promise that resolves with the response data. * @template T - Type of the response data. * @template P - Type of the query parameters. */ protected get = Record>(endpoint: string, params?: P): Promise; /** * Makes a POST request to the given endpoint with the given data. * * @param {string} endpoint - Endpoint for the request. * @param {I} data - Data to be sent in the request. * @returns {Promise} - Promise that resolves with the response data. * @template I - Type of the request data. * @template T - Type of the response data. */ protected post(endpoint: string, data?: I): Promise; /** * Sends a DELETE request to the specified endpoint. * * @param {string} endpoint - The endpoint to send the request to. * @returns {Promise} A promise that resolves when the DELETE request is complete. * @protected */ protected delete(endpoint: string): Promise; /** * Makes a PUT request to the specified endpoint with the given data. * * @param endpoint - The endpoint to make the request to. * @param data - The data to send in the request body. * @returns A Promise that resolves to the data returned by the server. */ protected put(endpoint: string, data: I): Promise; /** * Makes a PATCH request to the specified endpoint with the given data. * * Unlike {@link BaseApi.put}, a PATCH body carries only the fields being * changed — the endpoints that accept one leave everything else as it is. * * @param endpoint - The endpoint to make the request to. * @param data - The fields to change. * @returns A Promise that resolves to the data returned by the server. */ protected patch(endpoint: string, data: I): Promise; /** * Returns the base URL for the API based on the environment. * * @returns {string} - Base URL for the API. * @private */ getBaseUrl(): string; /** * Returns the headers for the API request. * * @returns {Object.} - Headers for the API request. * @private */ private constructHeaders; /** * Renders params into a query string, repeating array values (`?tag=a&tag=b`). * * Constrained by value rather than by index signature, for the reasons in * {@link QueryParamsOf}. */ protected constructQueryString = Record>(parameters?: T): string; }