import { Axios } from "./axios"; import type { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios"; /** * @class Api Class is a fancy es6 wrapper class for axios. * * @param {import("axios").AxiosRequestConfig} config - axios Request Config. * @link [AxiosRequestConfig](https://github.com/axios/axios#request-config) */ export declare class Api extends Axios { private token; /** * Gets Token. * * @returns {string} token. * @memberof Api */ getToken(): string; /** * Sets Token. * * @param {string} token - token. * @memberof Api */ setToken(token: string): void; /** * Get Uri * * @param {import("axios").AxiosRequestConfig} [config] * @returns {string} * @memberof Api */ getUri(config?: AxiosRequestConfig): string; /** * Generic request. * * @access public * @template R - `RESPONSE`: payload you are going to get from back-end. * @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 R - `RESPONSE`: payload object the back-end return. * @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 OPTIONS method. * * @access public * @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 */ options(url: string, config?: AxiosRequestConfig): Promise>; /** * HTTP DELETE method, `statusCode`: 204 No Content. * * @access public * @template R - `RESPONSE`: expected object/value. * @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 R - `RESPONSE`: expected object/value 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 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 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 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; /** * * * @template T type. * @param {AxiosError} error * @memberof Api */ error(error: AxiosError): void; } //# sourceMappingURL=api.d.ts.map