@myparcel/sdk
Version:
JavaScript SDK to connect to the MyParcel API via Node.js or browser
58 lines (56 loc) • 1.91 kB
TypeScript
import { HttpMethod } from '../../types/request.types';
import { EndpointDefinition } from './AbstractEndpoint.types';
interface EndpointOptions {
headers?: AbstractEndpoint['definition']['headers'];
parameters?: AbstractEndpoint['definition']['parameters'];
}
export declare abstract class AbstractEndpoint<D = EndpointDefinition> {
/**
* HTTP method.
*/
readonly method: HttpMethod;
/**
* Name of the endpoint.
*/
abstract readonly name: string;
/**
* URL path of the API endpoint. Can contain path variables like `:variable`.
*/
abstract readonly path: string;
/**
* The property in the request body and response body. If the response body
* property differs, set responseProperty alongside property.
* If the property is undefined, the endpoint will be called without a namespace.
*/
readonly property: string | undefined;
/**
* Property used in the response. Falls back to `this.property` if it's not
* set.
*/
readonly responseProperty: string | undefined;
/**
* Timeout in milliseconds.
* This is used to override the default timeout of the client.
*/
readonly timeout: number | undefined;
/**
* Used to expose EndpointDefinition type.
*/
readonly definition: D;
/**
* Headers to include when calling this endpoint.
*/
private readonly headers;
/**
* Parameters to include in the endpoint url.
*/
private readonly parameters;
constructor(options?: EndpointOptions);
getHeaders(): AbstractEndpoint['definition']['headers'];
getParameters(): AbstractEndpoint['definition']['parameters'];
getPath(): AbstractEndpoint['path'];
getProperty(): AbstractEndpoint['property'];
getResponseProperty(): AbstractEndpoint['responseProperty'];
getTimeout(): AbstractEndpoint['timeout'];
}
export {};