import { Cata } from './Basics'; import { Task, Cmd } from './index'; import Maybe from './Maybe'; import Either from './Either'; import Decode from './Json/Decode'; import Encode from './Json/Encode'; export declare abstract class Error { abstract cata(pattern: Error.Pattern): T; } export declare namespace Error { type Pattern = Cata<{ BadUrl(url: string): T; Timeout(): T; NetworkError(): T; BadStatus(response: Response): T; BadBody(error: Decode.Error, response: Response): T; }>; const BadUrl: (url: string) => Error; const Timeout: Error; const NetworkError: Error; const BadStatus: (response: Response) => Error; const BadBody: (error: Decode.Error, response: Response) => Error; } export declare class Header { protected readonly name: string; protected readonly value: string; protected constructor(name: string, value: string); } declare abstract class PhantomHeader extends Header { static of(name: string, value: string): Header; static getName(header: PhantomHeader): string; static getValue(header: PhantomHeader): string; } export declare const header: typeof PhantomHeader.of; export interface Response { readonly url: string; readonly statusCode: number; readonly statusText: string; readonly headers: { [name: string]: string; }; readonly body: T; } export declare class Expect { protected readonly responseType: XMLHttpRequestResponseType; protected readonly responseToResult: (response: Response) => Either; protected constructor(responseType: XMLHttpRequestResponseType, responseToResult: (response: Response) => Either); } export declare const expectResponse: (responseToResult: (response: Response) => Either) => Expect; export declare const expectWhatever: Expect; export declare const expectString: Expect; export declare const expectJson: (decoder: Decode.Decoder) => Expect; interface BodyContent { type: string; value: string; } export declare class Body { protected readonly content: Maybe; protected constructor(content: Maybe); } export declare const emptyBody: Body; export declare const stringBody: (type: string, value: string) => Body; export declare const jsonBody: (encoder: Encode.Value) => Body; export declare class Request { private readonly config; protected constructor(config: Readonly<{ method: string; url: string; headers: Array
; body: Body; expect: Expect; timeout: Maybe; withCredentials: boolean; queryParams: Array<[string, string]>; }>); withHeader(name: string, value: string): Request; withHeaders(headers: Array
): Request; withBody(body: Body): Request; withStringBody(type: string, value: string): Request; withJsonBody(encoder: Encode.Value): Request; withTimeout(timeout: number): Request; withoutTimeout(): Request; withCredentials(enabled: boolean): Request; withQueryParam(key: string, value: string): Request; withQueryParams(queries: Array<[string, string]>): Request; withExpect(expect: Expect): Request; withExpectResponse(responseToResult: (response: Response) => Either): Request; withExpectString(): Request; withExpectJson(decoder: Decode.Decoder): Request; toTask(): Task; send(tagger: (result: Either) => R): Cmd; } export declare const get: (url: string) => Request; export declare const post: (url: string) => Request; export declare const put: (url: string) => Request; export declare const patch: (url: string) => Request; export declare const del: (url: string) => Request; export declare const options: (url: string) => Request; export declare const trace: (url: string) => Request; export declare const head: (url: string) => Request; export {};