@inweb/client
Version:
JavaScript REST API client for the Open Cloud Server
74 lines (73 loc) • 2.88 kB
TypeScript
import { IHttpClient } from "./IHttpClient";
/**
* Base class for the REST API endpoints.
*/
export declare class Endpoint {
/**
* Endpoint API path relative to the REST API server URL.
*/
path: string;
/**
* Endpoint-specific HTTP headers for the `GET`, `POST`, `PUT` and `DELETE` requests. You can add
* custom headers at any time.
*/
headers: HeadersInit;
httpClient: IHttpClient;
private _useVersion;
/**
* @ignore
* @param path - The API path of the endpoint relative to the REST API server URL of the specified HTTP
* client.
* @param httpClient - HTTP client instance used to send requests to the REST API server.
* @param headers - Endpoint-specific HTTP headers.
*/
constructor(path: string, httpClient: IHttpClient, headers?: {});
appendVersionParam(relativePath: string): string;
/**
* Returns the endpoint API path.
*
* @ignore
* @param relativePath - Nested endpoint relative path.
*/
getEndpointPath(relativePath: string): string;
/**
* Sends the `GET` request to the endpoint.
*
* @ignore
* @param relativePath - Nested endpoint relative path.
* @param signal - An
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
* to communicate with a fetch request and abort it if desired.
*/
get(relativePath: string, signal?: AbortSignal): Promise<Response>;
/**
* Sends the `POST` request to the endpoint.
*
* @ignore
* @param relativePath - Nested endpoint relative path.
* @param body - Request body. Can be
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
*/
post(relativePath: string, body?: BodyInit | object): Promise<Response>;
/**
* Sends the `PUT` request to the endpoint.
*
* @ignore
* @param relativePath - Nested endpoint relative path.
* @param body - Request body. Can be
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
*/
put(relativePath: string, body?: BodyInit | object): Promise<Response>;
/**
* Sends the `DELETE` request to the endpoint.
*
* @ignore
* @param relativePath - Nested endpoint relative path.
*/
delete(relativePath: string): Promise<Response>;
useVersion(version?: number): this;
}