import { JsonObject, JsonValue } from 'type-fest'; import { Dispatcher } from 'undici'; import { InternalError } from '../errors/index.js'; /** * Defining types */ export interface APIRequestOptions extends Partial { baseURL?: string; throwErrorOnFailure?: boolean; data?: JsonObject; } export interface APIResponse { statusCode: number; headers: Record; data: T | null; } export interface CustomAPIRequest { new (options?: APIRequestOptions): APIRequest; setOptions(options: Omit): void; } export declare class APIRequest { private readonly options; private static readonly logger; private constructor(); static get(url: string): APIRequest; static post(url: string): APIRequest; static put(url: string): APIRequest; static patch(url: string): APIRequest; static delete(url: string): APIRequest; child(): CustomAPIRequest; suppressErrors(): this; header(key: string, value: string): this; query(key: string, value: string): this; field(key: string, value: JsonValue): this; body(data: JsonObject): this; execute(): Promise>; then(resolve: (value: APIResponse) => void, reject?: (reason?: Error) => any): Promise>; catch(reject: (reason?: Error) => any): Promise>; finally(callback: () => void): Promise>; } export declare class APIError extends InternalError { readonly statusCode: number; readonly data?: unknown | undefined; constructor(statusCode: number, data?: unknown | undefined); }