namecheap/ts/types.ts
2025-04-02 15:19:18 +00:00

948 lines
21 KiB
TypeScript

/**
* Namecheap API Client - Type Definitions
*/
// Base interface for API authentication
export interface INamecheapAuth {
apiUser: string;
apiKey: string;
userName: string;
clientIp: string;
}
// Base parameters that all API calls require
export interface TBaseParams {
ApiUser: string;
ApiKey: string;
UserName: string;
ClientIp: string;
Command: string;
}
// Response status types
export type TApiResponseStatus = 'OK' | 'ERROR';
// Base API response structure
export interface IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
[key: string]: any;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain List Parameters
export interface IDomainsGetListParams {
Page?: number;
PageSize?: number;
SortBy?: 'NAME' | 'NAME_DESC' | 'EXPIREDATE' | 'EXPIREDATE_DESC' | 'CREATEDATE' | 'CREATEDATE_DESC';
ListType?: 'ALL' | 'EXPIRING' | 'EXPIRED';
SearchTerm?: string;
}
// Domain information returned from getList
export interface IDomainInfo {
ID: string;
Name: string;
User: string;
Created: string;
Expires: string;
IsExpired: boolean;
IsLocked: boolean;
AutoRenew: boolean;
WhoisGuard: 'ENABLED' | 'DISABLED' | 'NOTPRESENT';
IsPremium: boolean;
IsOurDNS: boolean;
Nameservers: string;
}
// GetList response
export interface IDomainsGetListResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainGetListResult: Array<{
Domain: Array<{
$: IDomainInfo;
Nameservers: string[];
}>;
}>;
Paging: Array<{
TotalItems: string[];
CurrentPage: string[];
PageSize: string[];
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain Check Response
export interface IDomainCheckResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainCheckResult: IDomainCheckResult | IDomainCheckResult[];
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain Check Result
export interface IDomainCheckResult {
$: {
Domain: string;
Available: string;
ErrorNo: string;
Description: string;
IsPremiumName: string;
PremiumRegistrationPrice: string;
PremiumRenewalPrice: string;
PremiumRestorePrice: string;
PremiumTransferPrice: string;
IcannFee: string;
EapFee: string;
};
}
// Domain Availability (processed result)
export interface IDomainAvailability {
domain: string;
available: boolean;
errorNo: number;
description: string;
isPremium: boolean;
premiumRegistrationPrice: number;
premiumRenewalPrice: number;
premiumRestorePrice: number;
premiumTransferPrice: number;
icannFee: number;
eapFee: number;
}
// Domain Get Info Response
export interface IDomainGetInfoResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainGetInfoResult: Array<{
$: {
Status: string;
ID: string;
DomainName: string;
OwnerName: string;
IsOwner: string;
IsPremium: string;
};
DomainDetails?: Array<{
CreatedDate: string[];
ExpiredDate: string[];
}>;
LockDetails?: any[];
Whoisguard?: Array<{
$: {
Enabled: string;
};
ID: string[];
ExpiredDate: string[];
}>;
DnsDetails?: Array<{
$: {
ProviderType: string;
};
}>;
Modificationrights?: Array<{
$: {
All: string;
};
}>;
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain Info Result (processed)
export interface IDomainInfoResult {
status: string;
id: number;
domainName: string;
ownerName: string;
isOwner: boolean;
isPremium: boolean;
createdDate: string;
expiredDate: string;
whoisGuard: {
enabled: boolean;
id: number;
expiredDate: string;
};
dnsProvider: string;
modificationRights: {
all: boolean;
};
}
// Domain Get Contacts Response
export interface IDomainGetContactsResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainContactsResult: Array<{
Registrant?: Array<Record<string, string[]>>;
Tech?: Array<Record<string, string[]>>;
Admin?: Array<Record<string, string[]>>;
AuxBilling?: Array<Record<string, string[]>>;
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Contact information structure
export interface IContactInfo {
FirstName?: string;
LastName?: string;
Address1?: string;
Address2?: string;
City?: string;
StateProvince?: string;
StateProvinceChoice?: string;
PostalCode?: string;
Country?: string;
Phone?: string;
PhoneExt?: string;
Fax?: string;
EmailAddress?: string;
OrganizationName?: string;
JobTitle?: string;
}
// Domain Contacts
export interface IDomainContacts {
registrant: IContactInfo;
tech: IContactInfo;
admin: IContactInfo;
auxBilling: IContactInfo;
}
// Domain Set Contacts Parameters
export interface IDomainSetContactsParams {
registrant?: IContactInfo;
tech?: IContactInfo;
admin?: IContactInfo;
auxBilling?: IContactInfo;
}
// Domain Create Parameters
export interface IDomainCreateParams {
domainName: string;
years: number;
contacts: IDomainSetContactsParams;
nameservers?: string[];
addFreeWhoisguard?: boolean;
whoisguardPrivacy?: boolean;
premiumPrice?: number;
}
// Domain Create Response
export interface IDomainCreateResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainCreateResult: Array<{
$: {
Domain: string;
Registered: string;
ChargedAmount: string;
TransactionID: string;
OrderID: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain Renew Parameters
export interface IDomainRenewParams {
DomainName: string;
Years: number;
PremiumPrice?: number;
}
// Domain Renew Response
export interface IDomainRenewResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainRenewResult: Array<{
$: {
DomainName: string;
DomainID: string;
Renewed: string;
ChargedAmount: string;
TransactionID: string;
OrderID: string;
DomainDetails?: {
ExpiredDate: string;
};
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain Renew Result (processed)
export interface IDomainRenewResult {
domainName: string;
domainId: number;
renewed: boolean;
chargedAmount: number;
transactionId: number;
orderId: number;
expireDate: string;
}
// Registrar Lock Response
export interface IRegistrarLockResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainGetRegistrarLockResult: Array<{
$: {
RegistrarLockStatus: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Domain TLD List Response
export interface IDomainTldListResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
Tlds: Array<{
Tld: Array<{
$: {
Name: string;
};
}>;
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Host Record
export interface IDnsHost {
id: number;
name: string;
type: string;
address: string;
mxPref: number;
ttl: number;
isActive: boolean;
isDDNSEnabled: boolean;
}
// DNS Record
export interface IDnsRecord {
name: string;
type: string;
address: string;
mxPref?: number;
ttl?: number;
}
// DNS Get Hosts Response
export interface IDnsDomainHostsResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSGetHostsResult: Array<{
$: {
Domain: string;
IsUsingOurDNS: string;
};
host: Array<{
$: {
HostId: string;
Name: string;
Type: string;
Address: string;
MXPref?: string;
TTL: string;
IsActive?: string;
IsDDNSEnabled?: string;
};
}>;
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Set Hosts Response
export interface IDnsSetHostsResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSSetHostsResult: Array<{
$: {
Domain: string;
IsSuccess: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Set Custom Response
export interface IDnsSetCustomResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSSetCustomResult: Array<{
$: {
Domain: string;
Updated: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Get Email Forwarding Response
export interface IDnsGetEmailForwardingResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSGetEmailForwardingResult: Array<{
$: {
Domain: string;
};
forward: Array<{
$: {
from: string;
to: string;
};
}>;
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Set Email Forwarding Response
export interface IDnsSetEmailForwardingResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSSetEmailForwardingResult: Array<{
$: {
Domain: string;
IsSuccess: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// DNS Get List Response
export interface IDnsGetListResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainDNSGetListResult: Array<{
Nameserver: string[];
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Transfer Info
export interface ITransferInfo {
id: number;
domainName: string;
status: string;
statusDescription: string;
date: string;
lockTransferDate: string | null;
transferOrderDetailId: number;
isLocked: boolean;
authInfo: string | null;
}
// Transfer Status Info
export interface ITransferStatusInfo extends ITransferInfo {}
// Transfer Get List Response
export interface ITransferGetListResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
TransferGetListResult: Array<{
Transfer: Array<{
$: {
ID: string;
DomainName: string;
Status: string;
StatusDescription: string;
Date: string;
LockTransferDate?: string;
TransferOrderDetailID?: string;
IsLocked?: string;
AuthInfo?: string;
};
}>;
}>;
Paging: Array<{
TotalItems: string[];
CurrentPage: string[];
PageSize: string[];
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Transfer Get Status Response
export interface ITransferGetStatusResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
TransferGetStatusResult: Array<{
$: {
TransferID: string;
Status: string;
StatusDescription: string;
DomainName: string;
Date: string;
LockTransferDate?: string;
TransferOrderDetailID?: string;
IsLocked?: string;
AuthInfo?: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Transfer Create Response
export interface ITransferCreateResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainTransferCreateResult: Array<{
$: {
TransferID: string;
OrderID: string;
IsSuccess?: string;
Status: string;
StatusDescription: string;
ChargedAmount: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Transfer Update Status Response
export interface ITransferUpdateStatusResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
TransferUpdateStatusResult: Array<{
$: {
Domain: string;
Updated: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Transfer Get Info Response
export interface ITransferGetInfoResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
TransferGetInfoResult: Array<{
$: {
TransferID: string;
DomainName: string;
Status: string;
StatusDescription: string;
AuthInfo?: string;
Date: string;
WhoisguardStatus?: string;
OrderDate: string;
OrderID: string;
TransferOrderDetailID: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Nameserver Info
export interface INsInfo {
nameserver: string;
ip: string;
statuses: string[];
}
// Nameserver Create Response
export interface INsCreateResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainNSCreateResult: Array<{
$: {
Domain: string;
Nameserver: string;
IP: string;
IsSuccess: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Nameserver Delete Response
export interface INsDeleteResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainNSDeleteResult: Array<{
$: {
Domain: string;
Nameserver: string;
IsSuccess: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Nameserver Get Info Response
export interface INsGetInfoResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainNSInfoResult: Array<{
$: {
Nameserver: string;
IP: string;
Statuses?: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Nameserver Update Response
export interface INsUpdateResponse extends IApiResponse {
ApiResponse: {
$: {
Status: TApiResponseStatus;
xmlns: string;
};
Errors: Array<{ Error: string[] }> | [{}];
Warnings: Array<{ Warning: string[] }> | [{}];
RequestedCommand: string[];
CommandResponse: Array<{
$: {
Type: string;
};
DomainNSUpdateResult: Array<{
$: {
Domain: string;
Nameserver: string;
OldIP: string;
IP: string;
IsSuccess: string;
};
}>;
}>;
Server: string[];
GMTTimeDifference: string[];
ExecutionTime: string[];
};
}
// Error response
export interface IErrorResponse {
message: string;
errors?: string[];
}