namecheap-ts 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +0,0 @@
1
- import { Command } from "./commands";
2
- import { DomainPriceAction } from "./types";
3
- export interface INamecheapConfig {
4
- ApiUser: string;
5
- ApiKey: string;
6
- UserName: string;
7
- ClientIp: string;
8
- }
9
- export interface IReponse {
10
- data: any;
11
- status: number;
12
- }
13
- export interface ICheckDomainResponse {
14
- availabe: boolean;
15
- premium: boolean;
16
- }
17
- declare class Namecheap {
18
- private readonly config;
19
- private readonly apiClient;
20
- constructor(config: INamecheapConfig, sandbox?: boolean);
21
- call(command: Command, payload: Record<string, string>): Promise<IReponse>;
22
- checkDomain(domainName: string): Promise<ICheckDomainResponse>;
23
- getDomainPrice(domainName: string, action: DomainPriceAction): Promise<IReponse>;
24
- }
25
- export default Namecheap;
package/dist/namecheap.js DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const api_1 = __importDefault(require("./api"));
16
- const commands_1 = require("./commands");
17
- const exceptions_1 = require("./exceptions");
18
- class Namecheap {
19
- constructor(config, sandbox) {
20
- this.config = config;
21
- const baseURL = `https://api${sandbox ? ".sandbox" : ""}.namecheap.com/xml.response`;
22
- this.apiClient = new api_1.default(baseURL);
23
- }
24
- call(command, payload) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const params = Object.assign(Object.assign(Object.assign({}, payload), this.config), { command });
27
- const url = "?" + new URLSearchParams(params).toString();
28
- const { data, status } = yield this.apiClient.get(url);
29
- return { data, status };
30
- });
31
- }
32
- checkDomain(domainName) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const { data } = yield this.call(commands_1.Commands.DOMAINS_CHECK, {
35
- DomainList: domainName,
36
- });
37
- const isAvailabe = data[0].DomainCheckResult[0].$.Available;
38
- const isPremium = data[0].DomainCheckResult[0].$.IsPremiumName;
39
- const response = {
40
- availabe: isAvailabe === "true",
41
- premium: isPremium === "true",
42
- };
43
- return response;
44
- });
45
- }
46
- getDomainPrice(domainName, action) {
47
- var _a, _b, _c, _d, _e, _f, _g, _h;
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const [_, tld] = domainName.split(".");
50
- if (!tld) {
51
- throw new exceptions_1.InvalidDomainNameException(domainName);
52
- }
53
- const { data, status } = yield this.call(commands_1.Commands.USERS_GETPRICING, {
54
- ProductType: "DOMAIN",
55
- ProductCategory: "DOMAINS",
56
- ActionName: action,
57
- ProductName: tld,
58
- });
59
- const pricing = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = data[0].UserGetPricingResult[0]) === null || _a === void 0 ? void 0 : _a.ProductType) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.ProductCategory) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.Product) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.Price) === null || _h === void 0 ? void 0 : _h.map((price) => (Object.assign({}, price.$)));
60
- return { data: pricing, status };
61
- });
62
- }
63
- }
64
- exports.default = Namecheap;
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export declare enum DomainPriceActions {
2
- REGISTER = "REGISTER",
3
- RENEW = "RENEW",
4
- REACTIVATE = "REACTIVATE",
5
- TRANSFER = "TRANSFER"
6
- }
7
- export type DomainPriceAction = `${DomainPriceActions}`;
package/dist/types.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DomainPriceActions = void 0;
4
- var DomainPriceActions;
5
- (function (DomainPriceActions) {
6
- DomainPriceActions["REGISTER"] = "REGISTER";
7
- DomainPriceActions["RENEW"] = "RENEW";
8
- DomainPriceActions["REACTIVATE"] = "REACTIVATE";
9
- DomainPriceActions["TRANSFER"] = "TRANSFER";
10
- })(DomainPriceActions || (exports.DomainPriceActions = DomainPriceActions = {}));