import { Promise } from "es6-promise"; import { Props } from "../../types"; import AjaxResponse from "./AjaxResponse"; import AjaxDefaults from "./AjaxDefaults"; import { AjaxFileEventHandler, AjaxFileEventHandlerProps } from "./AjaxFileEvent"; export interface AjaxProps { async?: boolean; user?: string; password?: string; headers?: Props; contentType?: string; timeout?: number; withCredentials?: boolean; params?: Props; queries?: Props; } export interface AjaxPropsWithData extends AjaxProps { data?: D; upload?: Props; } export interface FileAjaxPropsWithData extends AjaxPropsWithData> { } export default class Ajax { static _defaults: AjaxDefaults; static readonly ContentTypeHeader = "Content-Type"; static readonly ResponseTypeHeader = "content-type"; static readonly AllowMethodsHeader = "access-control-allow-methods"; static readonly AllowOriginHeader = "access-control-allow-origin"; static fetch(method: string, url: string, props?: AjaxPropsWithData): Promise; static configureUpload(xhr: XMLHttpRequest, props: AjaxPropsWithData): void; static getRequestData(contentType: string, clientProps: AjaxPropsWithData): any; static setContentType(client: XMLHttpRequest, contentType: string): string; static isSuccess(status: number): boolean; static getResponse(xhr: XMLHttpRequest, err?: Error): AjaxResponse; static parseHeaders(header: string): Props; static getResponseData(responseType: string, xhr: XMLHttpRequest): any; static get(url: string, props?: AjaxProps): Promise; static post(url: string, props?: AjaxPropsWithData): Promise; static put(url: string, props?: AjaxPropsWithData): Promise; static delete(url: string, props?: AjaxPropsWithData): Promise; static patch(url: string, props?: AjaxPropsWithData): Promise; static head(url: string, props?: AjaxProps): Promise; static options(url: string, props?: AjaxProps): Promise; static upload(url: string, props?: FileAjaxPropsWithData): Promise; static dataToFormData(data: any): FormData; static setup(merge: AjaxDefaults): void; }