@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
99 lines (98 loc) • 5.03 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tlds = void 0;
const paginate_1 = require("./paginate");
class Tlds {
constructor(_client) {
this._client = _client;
/**
* Lists TLDs supported for registration or transfer.
*
* This API is paginated. Call `listTlds.iterateAll(params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listTlds.collectAll(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 /tlds
*
* @see https://developer.dnsimple.com/v2/tlds/#listTlds
*
* @param params Query parameters
* @param params.sort Sort results. Default sorting is by tld ascending.
*/
this.listTlds = (() => {
const method = (params = {}) => this._client.request("GET", `/tlds`, null, params);
method.iterateAll = (params = {}) => (0, paginate_1.paginate)((page) => method(Object.assign(Object.assign({}, params), { page })));
method.collectAll = (params = {}) => __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
const items = [];
try {
for (var _d = true, _e = __asyncValues(method.iterateAll(params)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
_c = _f.value;
_d = false;
try {
const item = _c;
items.push(item);
}
finally {
_d = true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
}
finally { if (e_1) throw e_1.error; }
}
return items;
});
return method;
})();
/**
* Retrieves the details of a TLD.
*
* GET /tlds/{tld}
*
* @see https://developer.dnsimple.com/v2/tlds/#getTld
*
* @param tld The TLD string
* @param params Query parameters
*/
this.getTld = (() => {
const method = (tld, params = {}) => this._client.request("GET", `/tlds/${tld}`, null, params);
return method;
})();
/**
* Lists a TLD extended attributes.
*
* Some TLDs require extended attributes when registering or transferring a domain. This API interface provides information on the extended attributes for any particular TLD. Extended attributes are extra TLD-specific attributes, required by the TLD registry to collect extra information about the registrant or legal agreements.
*
* GET /tlds/{tld}/extended_attributes
*
* @see https://developer.dnsimple.com/v2/tlds/#getTldExtendedAttributes
*
* @param tld The TLD string
* @param params Query parameters
*/
this.getTldExtendedAttributes = (() => {
const method = (tld, params = {}) => this._client.request("GET", `/tlds/${tld}/extended_attributes`, null, params);
return method;
})();
}
}
exports.Tlds = Tlds;
;