import { Observable } from 'rxjs';
import { AjaxError, AjaxRequest, AjaxResponse } from 'rxjs/ajax';
import { HttpStatusCode } from './http-constants';
/**
 * The Http Retry Handler interface. Describes an object that can handle specific status codes.
 * the handle function takes a status code, AjaxRequest and AjaxError.
 * It returns an observable for new AjaxRequest to try again
 */
export interface HttpResponseRetryHandler {
    canHandle(code: HttpStatusCode, error: AjaxError): boolean;
    handle?(code: HttpStatusCode, request: AjaxRequest, error: AjaxError): Observable<AjaxRequest>;
    handleNoRetry?(code: HttpStatusCode, request: AjaxRequest, error: AjaxError): Observable<void>;
}
/**
 * Retry options for an http request
 */
export declare class HttpRetryOptions {
    maxRetry: number;
    handlers: HttpResponseRetryHandler[];
}
/**
 * Set of monitors for pre and post process of ajax.
 */
export interface HttpMonitorSet {
    name: string;
    preMonitor: (request: AjaxRequest) => Observable<AjaxRequest | Error>;
    successMonitor: (response: AjaxResponse<any>) => Observable<AjaxResponse<any>>;
    errorMonitor: (error: any) => Observable<AjaxResponse<any>>;
}
/**
 * Enum for http method types
 */
export declare enum HttpMethod {
    Get = "GET",
    Post = "POST",
    Put = "PUT",
    Delete = "DELETE",
    Patch = "PATCH",
    Head = "HEAD",
    Options = "OPTIONS"
}
/**
 * The Http observable based class.
 */
export declare class Http {
    /**
     * Default ajax options must be used for CORS.
     */
    static defaultHttpOptions: AjaxRequest;
    /**
     * The collection of set of monitors.
     */
    private static monitorSets;
    /**
     * The default retry options.
     */
    defaultRetryOptions: HttpRetryOptions;
    /**
     * Register the set of monitors.
     *
     * @param monitorSet The set of monitors.
     */
    static registerMonitorSet(monitorSet: HttpMonitorSet): void;
    /**
     * Unregister the set of monitors.
     *
     * @param name The name of set of monitors.
     * @returns boolean true if unregistered the named set.
     */
    static unregisterMonitors(name: string): boolean;
    /**
     * The common request method.
     * Adds default responseType, contentType, Accept values if they are not already included in the request
     *
     * @param request the request options.
     * @param options the retry options.
     */
    request(request: AjaxRequest, retryOptions?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request without modification.
     * If the result is an error, we will retry with the handlers in options
     *
     * @param request the request options.
     * @param options the retry options.
     * @param count the current iteration of the retry cycle.
     */
    private requestWithHandlers;
    /**
     * Performs a request with `get` http method.
     *
     * @param url the url.
     * @param request the request options.
     * @param options the retry options.
     */
    get(url: string, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `post` http method.
     *
     * @param url the url.
     * @param body the body content.
     * @param request the request options.
     * @param options the retry options.
     */
    post(url: string, body: any, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `put` http method.
     *
     * @param url the url.
     * @param body the body content.
     * @param request the request options.
     * @param options the retry options.
     */
    put(url: string, body: any, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `delete` http method.
     *
     * @param url the url.
     * @param request the request options.
     * @param options the retry options.
     */
    delete(url: string, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `patch` http method.
     *
     * @param url the url.
     * @param body the body content.
     * @param request the request options.
     * @param options the retry options.
     */
    patch(url: string, body: any, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `head` http method.
     *
     * @param url the url.
     * @param request the request options.
     * @param options the retry options.
     */
    head(url: string, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with `options` http method.
     *
     * @param url the url.
     * @param request the request options.
     * @param options the retry options.
     */
    options(url: string, request?: AjaxRequest, options?: HttpRetryOptions): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with 'get' http method with cache control.
     *
     * @param url the uri for GET call.
     * @return the observable for GET result data.
     */
    getNoCache(url: string, noCache?: boolean, responseType?: XMLHttpRequestResponseType, withCredentials?: boolean): Observable<AjaxResponse<any>>;
    /**
     * Performs a request with 'delete' http method without waiting for the response.
     *
     * @param url the uri for GET call.
     */
    deleteQuick(url: string, headers: any): void;
    private monitorAjax;
    private monitor;
}
