import { Ajax } from '@salaxy/core';

/**
 * Provides wrapper methods for communicating with the Palkkaus.fi API.
 * The raw Ajax-access to the server methods: GET, POST and DELETE
 * with different return types and authentication / error events.
 * This is the JQuery based ajax implementation.
 */
declare class AjaxJQuery implements Ajax {
    /**
     * By default (true) the token is set to salaxy-token -cookie.
     * Disable cookies with this flag.
     */
    useCookie: boolean;
    /**
     * By default credentials are not used in http-calls.
     * Enable credentials with this flag.
     */
    useCredentials: boolean;
    /**
     * The server address - root of the server. This is settable field.
     * Will probably be changed to a configuration object in the final version.
     */
    serverAddress: string;
    private token;
    /**
     * Creates a new instance of AjaxJQuery
     */
    constructor();
    /** Gets the API address with version information. E.g. 'https://test-api.salaxy.com/v02/api' */
    getApiAddress(): string;
    /** Gets the Server address that is used as bases to the HTML queries. E.g. 'https://test-api.salaxy.com' */
    getServerAddress(): string;
    /**
     * Gets a JSON-message from server using the API
     *
     * @param method - The API method is the url path after the api version segments (e.g. '/v02/api')
     * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.
     *
     * @returns A Promise with result data. Standard Promise rejection to be used for error handling.
     */
    getJSON(method: string): Promise<any>;
    /**
     * Gets a HTML-message from server using the API
     *
     * @param method - The API method is the url path after the api version segments (e.g. '/v02/api')
     * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.
     *
     * @returns A Promise with result html. Standard Promise rejection to be used for error handling.
     */
    getHTML(method: string): Promise<string>;
    /**
     * POSTS data to server and receives back a JSON-message.
     *
     * @param method - The API method is the url path after the api version segments (e.g. '/v02/api')
     * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.
     * @param data - The data that is posted to the server.
     *
     * @returns A Promise with result data. Standard Promise rejection to be used for error handling.
     */
    postJSON(method: string, data: any): Promise<any>;
    /**
     * POSTS data to server and receives back HTML.
     *
     * @param method - The API method is the url starting from api version, e.g. '/v02/api'. E.g. '/calculator/new'
     * @param data - The data that is posted to the server.
     *
     * @returns A Promise with result data. Standard Promise rejection to be used for error handling.
     */
    postHTML(method: string, data: any): Promise<string>;
    /**
     * Sends a DELETE-message to server using the API
     *
     * @param method - The API method is the url path after the api version segments (e.g. '/v02/api')
     * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.
     *
     * @returns A Promise with result data. Standard Promise rejection to be used for error handling.
     */
    remove(method: string): Promise<any>;
    /**
     * Gets the current token.
     * Will check the salaxy-token cookie if the token is persisted there
     */
    getCurrentToken(): string;
    /**
     * Sets the current token. The token is set to cookie called "salaxy-token" or
     * if the HTML page is running from local computer, it is set to local storage.
     *
     * @param token - the authentication token to store.
     */
    setCurrentToken(token: string): void;
    /**
     * Implements the OAuth2 "Resource Owner Password Credentials Grant" flow (RFC6749 4.3).
     * This method is not typically used in production web sites - use Implicit Grant instead for client side JavScript (SPAs).
     * However, it is very useful in development, testing, trusted helpers and server-side scenarios.
     */
    resourceOwnerLogin(username: string, password: string): void;
    private getJQuery;
    /** If missing, append the API server address to the given url method string */
    private getUrl;
}

export { AjaxJQuery };
