/// <reference types="node" />
import type { Agent } from 'node:http';
import { ApiClientInterface, Headers } from './_types/generalTypes';
import { APIError } from './error';
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
export type HTTPMethod = "post" | "get" | "put" | "delete";
export type FinalRequestOptions = RequestOptions & {
    method: HTTPMethod;
    path: string;
};
export type RequestOptions = {
    method?: HTTPMethod;
    path?: string;
    query?: Record<string, any> | undefined;
    body?: Record<string, any> | undefined;
    headers?: Headers | undefined;
    httpAgent?: Agent;
    stream?: boolean | undefined;
};
type APIResponseProps = {
    response: Response;
    options: FinalRequestOptions;
};
type PromiseOrValue<T> = T | Promise<T>;
export declare class APIPromise<T> extends Promise<T> {
    private responsePromise;
    private parseResponse;
    private parsedPromise;
    constructor(responsePromise: Promise<APIResponseProps>, parseResponse?: (props: APIResponseProps) => PromiseOrValue<T>);
    private parse;
    then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
    catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
    finally(onfinally?: (() => void) | undefined | null): Promise<T>;
}
export declare abstract class ApiClient {
    apiKey: string | null;
    baseURL: string;
    private fetch;
    constructor({ apiKey, baseURL }: ApiClientInterface);
    protected defaultHeaders(): Record<string, string>;
    post<Rsp>(path: string, opts?: RequestOptions): APIPromise<Rsp>;
    protected generateError(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError;
    request(opts: FinalRequestOptions): Promise<APIResponseProps>;
    buildRequest(opts: FinalRequestOptions): {
        req: RequestInit;
        url: string;
    };
    methodRequest<Rsp>(method: HTTPMethod, path: string, opts?: RequestOptions): APIPromise<Rsp>;
}
export {};
