ts-mailcow-api
Version:
TypeScript wrapper for the mailcow API.
34 lines (33 loc) • 1.13 kB
TypeScript
import MailcowClient from './index';
/**
* Function that wraps T | T[] to T[]
* @internal
* @param promise - The promise of which the output to wrap.
*/
export declare function wrapPromiseToArray<T>(promise: Promise<T | T[]>): Promise<T[]>;
/**
* Factory method patterns for creating Axios Requests.
* @internal
*/
export default class RequestFactory {
private ctx;
constructor(ctx: MailcowClient);
/**
* Executes a request and applies Mailcow-specific error handling: a 2XX
* response with `type: 'danger'` or `type: 'error'` is converted into a
* MailcowException, and an axios error whose response body looks like a
* Mailcow error is unwrapped into a MailcowException as well.
*/
private request;
/**
* POST Request Factory
* @param route - The route to which to send the request.
* @param payload - The payload to send with the request.
*/
post<T, P extends object>(route: string, payload: P): Promise<T>;
/**
* GET Request Factory
* @param route - The route to which to send the request.
*/
get<T>(route: string): Promise<T>;
}