/** * Helper class that builds URLs from a baseUrl and given query parameters */ export declare class UrlBuilder { url: string; hasQuery: boolean; /** * Static method that creates an URL query string from a key, value pair provided as param * * @param param either a string or a number to be converted. */ static stringifyQuery(values: { [key: string]: string | number | string[] | undefined; }): string; /** * Static method that converts the parameter to a string * * @param param either a string or a number to be converted. */ static toString(param: string | number): string; private static appendQueryString; /** * Default constructor. * * @param url The base URL. * @param hasQuery Whether the base URL already contains query parameters. */ constructor(url: string, hasQuery?: boolean); /** * Appends a query parameter to the URL, either using '&key=value' or '?key=value' * depending on the [[hasQuery]] parameter. * * Escapes all strings using `encodeURIComponent`, except for the comma, * which is kept unescaped as a list separator. * * String arrays are concatenated using commas. * * @param key The key of the query parameter. * @param value The value of the query parameter. */ appendQuery(key: string, value?: string | number | boolean | string[] | number[], operator?: string): void; } export interface RequestOptions { method?: string; body?: string; headers?: { [header: string]: string; }; } /** * Abstract class used for building requests to a REST API. */ export declare abstract class RequestBuilder { readonly baseUrl: string; /** * Constructs a new RequestBuilder. * * @param baseUrl The base URL of the service. */ constructor(baseUrl: string); /** * Helper method to download the resource. * * @param urlObj the URL to fetch. */ request(urlObj: UrlBuilder, init?: RequestOptions): Promise; /** * Helper method to download the resource. * * @param urlObj the URL to fetch. */ requestBlob(urlObj: UrlBuilder, init?: RequestOptions): Promise; /** * Implement this function to download the given url as JSON object. * * @param url The URL to download. */ abstract download(url: string, init?: RequestOptions): Promise; /** * Implement this function to download the given url as Blob object. * * @param url The URL to download. */ abstract downloadBlob(url: string, init?: RequestOptions): Promise; }