import type { Formatter } from './formatters/common.js'; import type { MiddlewareAsync } from './middlewares/shared.js'; import type { TypedSerializableObject } from './helpers.js'; /** * Configuration options for HTTP requests. */ export interface HttpOptions { method?: string; url: string | URL; queryString?: string | URLSearchParams; body?: BodyInit | TypedSerializableObject; headers?: { [key: string]: string | number | Date; }; contentType?: 'json' | 'form' | 'form-urlencoded'; type?: 'json' | 'xml' | 'text' | 'raw'; } /** * Interface defining methods for making HTTP requests. */ export interface Http { /** * Sends a GET request to the specified URL. * @param url The URL to request. * @param params Query parameters to append. * @returns A promise resolving to the HTTP response. */ get(url: string | URL, params?: string | URLSearchParams): PromiseLike; /** * Sends a POST request with a body. * @param url The target URL. * @param body The request body. * @returns A promise resolving to form data from the response. */ post(url: string | URL, body?: unknown): PromiseLike; /** * Sends a JSON POST request. * @param url The target URL. * @param body The JSON body content. * @returns A promise resolving to the parsed JSON response. */ postJSON(url: string | URL, body?: unknown): PromiseLike; /** * Sends a GET request expecting JSON response. * @param url The target URL. * @param params Query parameters to include. * @returns A promise resolving to the parsed JSON data. */ getJSON(url: string | URL, params?: string | URLSearchParams): PromiseLike; /** * Sends a SOAP-based POST request. * @param namespace SOAP namespace. * @param action SOAP action name. * @param url The target URL. * @param params SOAP parameters. * @returns A promise resolving to the SOAP response. */ invokeSOAP(namespace: string, action: string, url: string | URL, params?: { [key: string]: string | number | boolean; }): PromiseLike; /** * Sends a custom HTTP request using options. * @param options Configuration for the request. * @returns A promise resolving to the HTTP response. */ call(options: HttpOptions): PromiseLike; } export type CallInterceptor = MiddlewareAsync<[RequestInit, Response]>; export declare class FetchHttp implements Http { private interceptor; constructor(interceptor: CallInterceptor); /** * Sends a GET request to the specified URL. * @param url The URL to request. * @param params Query parameters to append. * @returns A promise resolving to the HTTP response. */ get(url: string, params?: URLSearchParams): Promise; /** * Sends a POST request with a body. * @param url The target URL. * @param body The request body. * @returns A promise resolving to form data from the response. */ post(url: string, body?: BodyInit): PromiseLike; /** * Sends a JSON POST request. * @param url The target URL. * @param body The JSON body content. * @returns A promise resolving to the parsed JSON response. */ postJSON(url: string, body?: BodyInit): PromiseLike; /** * Sends a GET request expecting JSON response. * @param url The target URL. * @param params Query parameters to include. * @returns A promise resolving to the parsed JSON data. */ getJSON(url: string, params?: string | URLSearchParams): PromiseLike; /** * Sends a SOAP-based POST request. * @param namespace SOAP namespace. * @param action SOAP action name. * @param url The target URL. * @param params SOAP parameters. * @returns A promise resolving to the SOAP response. */ invokeSOAP(namespace: string, action: string, url: string, params?: { [key: string]: string | number | boolean; }): Promise; /** * Sends a custom HTTP request using options. * @param options Configuration for the request. * @returns A promise resolving to the HTTP response. */ call(options: HttpOptions): Promise; private fetch; /** * Serializes an object into URL-encoded format. */ static serialize(obj: any, prefix?: string): string | FormData; } type SettingsType = { method?: keyof Http; } & Omit, 'url'>; export declare class HttpCallFormatter implements Formatter> { private readonly settings; private previousValue; private previousCall; constructor(settings: SettingsType); format(scope: unknown): PromiseLike; } export {};