@planbgmbh/flinkey-web-components
Version:
This project provides some Web Components built for usage in combination with the flinkey API.
65 lines (64 loc) • 2.37 kB
TypeScript
/**
* Global parameters that all web components use to call flinkey API endpoints.
*/
declare class Globals {
/**
* The ID of the customer that could be found in the flinkey Portal's developer area.
*/
static customerId: number;
/**
* The apiKey (aka. flinkey-API-Key) that could be found in the flinkey Portal's developer area.
*/
static apiKey: string;
/**
* The token that is created via the flinkey API's authorization endpoint.
*/
static token: string;
/**
* The base URL of the flinkey API to call (e.g. "https://api.flinkey.de/v3").
*/
static apiBaseUrl: string;
}
/**
* The HTTP response structure.
*/
interface HttpResponse<T> extends Response {
parsedBody?: T;
}
/**
* Sets the default headers for API calls.
* @returns {HeadersInit} The default headers.
*/
declare function setDefaultHeaders(): HeadersInit;
/**
* Sets the default headers for API calls.
* @param {string} path - The path of the endpoint.
* @param {URLSearchParams} [searchParams] - The search params to append to the endpoint.
* @returns {string} The generated endpoint.
*/
declare function setEndpoint(path: string, searchParams?: URLSearchParams): string;
/**
* Sends an HTTP GET request via fetch API.
* @param {string} path - The path of the endpoint to call in the request.
* @param {URLSearchParams} [searchParams] - The search params to send in the request.
* @returns {Promise<HttpResponse<T>>} The HTTP response.
* @template T
*/
declare function httpGet<T>(path: string, searchParams?: URLSearchParams): Promise<HttpResponse<T>>;
/**
* Sends an HTTP PUT request via fetch API.
* @param {string} path - The path of the endpoint to call in the request.
* @param {unknown} body - The body to send in the request.
* @returns {Promise<HttpResponse<T>>} The HTTP response.
* @template T
*/
declare function httpPut<T>(path: string, body: unknown): Promise<HttpResponse<T>>;
/**
* Sends an HTTP DELETE request via fetch API.
* @param {string} path - The path of the endpoint to call in the request.
* @param {unknown} [body] - The body to send in the request.
* @returns {Promise<HttpResponse<T>>} The HTTP response.
* @template T
*/
declare function httpDelete<T>(path: string, body?: unknown): Promise<HttpResponse<T>>;
export { Globals, HttpResponse, httpGet, httpPut, httpDelete, setDefaultHeaders, setEndpoint };