@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
117 lines (116 loc) • 4.1 kB
TypeScript
import type { DNSimple, QueryParams } from "./main";
import type * as types from "./types";
export declare class Contacts {
private readonly _client;
constructor(_client: DNSimple);
/**
* List contacts in the account.
*
* This API is paginated. Call `listContacts.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listContacts.collectAll(account, params)` to quickly retrieve all items across all pages into an array. We suggest using `iterateAll` when possible, as `collectAll` will make all requests at once, which may increase latency and trigger rate limits.
*
* GET /{account}/contacts
*
* @see https://developer.dnsimple.com/v2/contacts/#listContacts
*
* @param account The account id
* @param params Query parameters
* @param params.sort Sort results. Default sorting is by id ascending.
*/
listContacts: {
(account: number, params?: QueryParams & {
sort?: "id:asc" | "id:desc" | "label:asc" | "label:desc" | "email:asc" | "email:desc";
}): Promise<{
data: Array<types.Contact>;
pagination: types.Pagination;
}>;
iterateAll(account: number, params?: QueryParams & {
sort?: "id:asc" | "id:desc" | "label:asc" | "label:desc" | "email:asc" | "email:desc";
}): AsyncGenerator<types.Contact, any, any>;
collectAll(account: number, params?: QueryParams & {
sort?: "id:asc" | "id:desc" | "label:asc" | "label:desc" | "email:asc" | "email:desc";
}): Promise<types.Contact[]>;
};
/**
* Creates a contact.
*
* POST /{account}/contacts
*
* @see https://developer.dnsimple.com/v2/contacts/#createContact
*
* @param account The account id
* @param params Query parameters
*/
createContact: (account: number, data: Partial<{
label?: string;
first_name: string;
last_name: string;
address1: string;
address2: string | null;
city: string;
state_province: string;
postal_code: string;
country: string;
email: string;
phone: string;
fax: string | null;
organization_name: string;
job_title: string;
}>, params?: QueryParams & {}) => Promise<{
data: types.Contact;
}>;
/**
* Retrieves the details of an existing contact.
*
* GET /{account}/contacts/{contact}
*
* @see https://developer.dnsimple.com/v2/contacts/#getContact
*
* @param account The account id
* @param contact The contact id
* @param params Query parameters
*/
getContact: (account: number, contact: number, params?: QueryParams & {}) => Promise<{
data: types.Contact;
}>;
/**
* Updates the contact details.
*
* PATCH /{account}/contacts/{contact}
*
* @see https://developer.dnsimple.com/v2/contacts/#updateContact
*
* @param account The account id
* @param contact The contact id
* @param params Query parameters
*/
updateContact: (account: number, contact: number, data: Partial<{
label?: string;
first_name: string;
last_name: string;
address1: string;
address2: string | null;
city: string;
state_province: string;
postal_code: string;
country: string;
email: string;
phone: string;
fax: string | null;
organization_name: string;
job_title: string;
}>, params?: QueryParams & {}) => Promise<{
data: types.Contact;
}>;
/**
* Permanently deletes a contact from the account.
*
* DELETE /{account}/contacts/{contact}
*
* @see https://developer.dnsimple.com/v2/contacts/#deleteContact
*
* @param account The account id
* @param contact The contact id
* @param params Query parameters
*/
deleteContact: (account: number, contact: number, params?: QueryParams & {}) => Promise<{}>;
}