UNPKG

@jesseditson/dnsimple

Version:

A Node.JS client for the DNSimple API.

99 lines (98 loc) 3.31 kB
import { Accounts } from "./accounts"; import { Billing } from "./billing"; import { Certificates } from "./certificates"; import { Contacts } from "./contacts"; import { Domains } from "./domains"; import { Identity } from "./identity"; import { OAuth } from "./oauth"; import { Registrar } from "./registrar"; import { Services } from "./services"; import { Templates } from "./templates"; import { Tlds } from "./tlds"; import { VanityNameServers } from "./vanity_name_servers"; import { Webhooks } from "./webhooks"; import { Zones } from "./zones"; export * from "./types"; export type QueryParams = { [name: string]: string | boolean | number | null | undefined; }; export declare const toQueryString: (params: QueryParams) => string; export declare class TimeoutError extends Error { } export declare class RequestError extends Error { readonly status: number; constructor(status: number, description: string); } export declare class AuthenticationError extends RequestError { readonly data: any; constructor(data: any); } export declare class NotFoundError extends RequestError { readonly data: any; constructor(data: any); } export declare class MethodNotAllowedError extends RequestError { constructor(); } export declare class TooManyRequestsError extends RequestError { constructor(); } export declare class ClientError extends RequestError { readonly data: any; constructor(status: number, data: any); attributeErrors(): any; } export declare class ServerError extends RequestError { readonly data: any; constructor(status: number, data: any); } /** * A function that makes an HTTP request. It's responsible for throwing {@link TimeoutError} and aborting the request on {@param params.timeout}. * It should return the response status and full body as a string. It should not throw on any status, even if 4xx or 5xx. * It can decide to implement retries as appropriate. The default fetcher currently does not implement any retry strategy. */ export type Fetcher = (params: { method: string; url: string; headers: { [name: string]: string; }; body?: string; timeout: number; }) => Promise<{ status: number; body: string; }>; export declare class DNSimple { static VERSION: string; static DEFAULT_TIMEOUT: number; static DEFAULT_BASE_URL: string; static DEFAULT_USER_AGENT: string; accessToken: string | undefined; baseUrl: string; fetcher: Fetcher; timeout: number; userAgent: string; readonly accounts: Accounts; readonly billing: Billing; readonly certificates: Certificates; readonly contacts: Contacts; readonly domains: Domains; readonly identity: Identity; readonly oauth: OAuth; readonly registrar: Registrar; readonly services: Services; readonly templates: Templates; readonly tlds: Tlds; readonly vanityNameServers: VanityNameServers; readonly webhooks: Webhooks; readonly zones: Zones; constructor({ accessToken, baseUrl, fetcher, timeout, userAgent, }?: { accessToken?: string; baseUrl?: string; fetcher?: Fetcher; timeout?: number; userAgent?: string; }); request(method: string, path: string, body: any, params: QueryParams): Promise<any>; }