import { ConfigObject } from '../types'; import { Method } from '../types/request'; export default class RequestService { /** API URL * @memberof RequestService */ protected apiUrl: string; /** API key * @memberof RequestService */ protected apiKey: string; /** API language * @memberof RequestService */ protected apiLanguage: string; /** * @memberof RequestService */ protected storeID?: string; /** * Initialize the request service * @param config The config object */ constructor(config: ConfigObject); /** * Set the API URL * @param apiUrl The API URL * @throws {Error} Throws an error if the API URL is not a string or empty * @returns The request service */ setApiUrl(apiUrl: string): RequestService; /** * Get the API URL * @returns {string} The API URL */ getApiUrl(): string; /** * Set the API key * @param key The API key * @throws {Error} Throws an error if the API key is not a string or empty * @returns {RequestService} The request service */ setApiKey(apiKey: string): RequestService; /** * Get the API key * @returns {string} The API key */ getApiKey(): string; /** * Set the API language * @param lang The API lang * @returns {RequestService} The request service */ setApiLanguage(lang?: string): RequestService; /** * Get the API language set * @returns {string} The API key */ getApiLanguage(): string; /** * Prepares the options to pass to fetch * @param {RequestInit} [optionsToMerge] The user provided options to fetch API * @returns {RequestInit} The filled user options with correct headers for API calls */ protected prepareFetchOptions(optionsToMerge?: RequestInit): RequestInit; /** * Performs a GET request * @param path The path to get (appended to this.apiUrl) * @param {RequestInit} [options] Options to add to fetch request * @returns {Promise} A promise resolved with requested datas */ get(path: string, options?: RequestInit): Promise; /** * Performs a POST request * @param path The path to POST (appended to this.apiUrl) * @param {RequestInit} [options] Options to add to fetch request * @param {BodyInit} [body] The datas to post * @returns {Promise} A promise resolved with requested datas */ post(path: string, options?: RequestInit, body?: BodyInit): Promise; /** * Performs a PUT request * @param path The path to PUT (appended to this.apiUrl) * @param {RequestInit} [options] Options to add to fetch request * @param {BodyInit} [body] The datas to post * @returns {Promise} A promise resolved with requested datas */ put(path: string, options?: RequestInit, body?: BodyInit): Promise; /** * Performs a DELETE request * @param path The path to DELETE (appended to this.apiUrl) * @param {RequestInit} [options] Options to add to fetch request * @param {BodyInit} [body] The datas to post * @returns {Promise} A promise resolved with requested datas */ delete(path: string, options?: RequestInit, body?: BodyInit): Promise; /** * Performs a PATCH request * @param path The path to PATCH (appended to this.apiUrl) * @param {RequestInit} [options] Options to add to fetch request * @param {BodyInit} [body] The datas to post * @returns {Promise} A promise resolved with requested datas */ patch(path: string, options?: RequestInit, body?: BodyInit): Promise; /** * Performs a request * @param method the method to use * @param path The path * @param [options] Options to add to fetch request * @param [body] The datas to post * @returns A promise resolved with requested datas */ protected request(method: Method, path: string, options?: RequestInit, body?: BodyInit): Promise; } export declare function makeUrl(path: string, apiUrl: string, storeID?: string): string;