import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; /** * ES6 Axios Class. * * @class Api * @extends {Axios} * @example * class UserApi extends Api { * public constructor (config) { * super(config); * * this.login=this.login.bind(this); * } * * public login (user: User) { * return this.api.post>("https://www.domain/login", {name: user.name, pass: user.pass}) * .then((res: AxiosResponse) => res.data); * } * } */ export declare class Api { [x: string]: any; /** * Creates an instance of Api. * * @param {import("axios").AxiosRequestConfig} [config] - axios configuration. * @memberof Api */ constructor(config?: AxiosRequestConfig); /** * Get Uri * * @param {import("axios").AxiosRequestConfig} [config] * @returns {string} * @memberof Api */ getUri(config?: AxiosRequestConfig): string; /** * Generic request. * * @access public * @template T - `TYPE`: expected object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP axios response payload. * @memberof Api * * @example * api.request({ * method: "GET|POST|DELETE|PUT|PATCH" * baseUrl: "http://www.domain.com", * url: "/api/v1/users", * headers: { * "Content-Type": "application/json" * } * }).then((response: AxiosResponse) => response.data) * */ request>(config: AxiosRequestConfig): Promise; /** * HTTP GET method, used to fetch data `statusCode`: 200. * * @access public * @template T - `TYPE`: expected object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} HTTP `axios` response payload. * @memberof Api */ get>(url: string, config?: AxiosRequestConfig): Promise; /** * HTTP DELETE method, `statusCode`: 204 No Content. * * @access public * @template T - `TYPE`: expected object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP [axios] response payload. * @memberof Api */ delete>(url: string, config?: AxiosRequestConfig): Promise; /** * HTTP HEAD method. * * @access public * @template T - `TYPE`: expected object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP [axios] response payload. * @memberof Api */ head>(url: string, config?: AxiosRequestConfig): Promise; /** * HTTP POST method `statusCode`: 201 Created. * * @access public * @template T - `TYPE`: expected object. * @template B - `BODY`: body request object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {B} data - payload to be send as the `request body`, * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP [axios] response payload. * @memberof Api */ post>(url: string, data?: B, config?: AxiosRequestConfig): Promise; /** * HTTP PUT method. * * @access public * @template T - `TYPE`: expected object. * @template B - `BODY`: body request object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {B} data - payload to be send as the `request body`, * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP [axios] response payload. * @memberof Api */ put>(url: string, data?: B, config?: AxiosRequestConfig): Promise; /** * HTTP PATCH method. * * @access public * @template T - `TYPE`: expected object. * @template B - `BODY`: body request object. * @template R - `RESPONSE`: expected object inside a axios response format. * @param {string} url - endpoint you want to reach. * @param {B} data - payload to be send as the `request body`, * @param {import("axios").AxiosRequestConfig} [config] - axios request configuration. * @returns {Promise} - HTTP [axios] response payload. * @memberof Api */ patch>(url: string, data?: B, config?: AxiosRequestConfig): Promise; /** * * @template T - type. * @param {import("axios").AxiosResponse} response - axios response. * @returns {T} - expected object. * @memberof Api */ success(response: AxiosResponse): T; error(error: AxiosError): void; static toAxiosError(error: any): Error; static isAxiosError(error: any): boolean; }