import { AxiosInstance } from 'axios';

/**
 * Configuration options for the Porkbun API client
 * @interface PorkbunConfig
 */
interface PorkbunConfig {
    /** Your Porkbun API key */
    apiKey: string;
    /** Your Porkbun secret API key */
    secretApiKey: string;
    /**
     * Optional custom base URL for the API
     * @default 'https://api.porkbun.com/api/json/v3'
     * @deprecated Use api.porkbun.com instead of porkbun.com after 2024-12-01
     */
    baseURL?: string;
}
/**
 * Base client for making authenticated requests to the Porkbun API
 * @class PorkbunClient
 */
declare class PorkbunClient {
    protected config: PorkbunConfig;
    /** Axios instance for making HTTP requests */
    protected client: AxiosInstance;
    /**
     * Creates a new PorkbunClient instance
     * @param {PorkbunConfig} config - API configuration
     */
    constructor(config: PorkbunConfig);
    /**
     * Returns the authentication payload for API requests
     * @returns {Object} Authentication payload
     * @protected
     */
    protected getAuthPayload(): {
        apikey: string;
        secretapikey: string;
    };
    /**
     * Sets up response interceptors for error handling
     * @private
     */
    private setupInterceptors;
    /**
     * Validates TTL value
     * @param {number} [ttl] - Time to live in seconds
     * @throws {PorkbunError} If TTL is less than 600 seconds
     * @protected
     */
    protected validateTTL(ttl?: number): void;
    /**
     * Makes an authenticated POST request
     * @template T - Expected response type
     * @param {string} endpoint - API endpoint
     * @param {Record<string, any>} [data] - Request payload
     * @returns {Promise<T>} API response
     * @protected
     */
    protected post<T>(endpoint: string, data?: Record<string, any>): Promise<T>;
}

/**
 * Standard API response interface
 * @interface APIResponse
 * @property {('SUCCESS'|'ERROR')} status - Response status
 * @property {string} [message] - Optional response message
 */
interface APIResponse {
    status: 'SUCCESS' | 'ERROR';
    message?: string;
}
/**
 * Response type for ping endpoint
 * @interface PingResponse
 * @extends {APIResponse}
 * @property {string} yourIp - Client IP address
 *
 * @example
 * ```typescript
 * const response: PingResponse = await client.post('/ping');
 * console.log(response.yourIp); // "192.168.1.1"
 * ```
 */
interface PingResponse extends APIResponse {
    yourIp: string;
}

/**
 * Domain information
 * @interface DomainInfo
 */
interface DomainInfo {
    /** Domain name */
    domain: string;
    /** Domain registration status */
    status: string;
    /** Top-level domain */
    tld: string;
    /** Domain creation date */
    createDate: string;
    /** Domain expiration date */
    expireDate: string;
    /** Domain lock status */
    securityLock: string;
    /** WHOIS privacy status */
    whoisPrivacy: string;
    /** Auto-renewal setting (0 or 1) */
    autoRenew: number;
    /** Local registration indicator (0 or 1) */
    notLocal: number;
    /** Optional domain labels */
    labels?: Array<{
        /** Label identifier */
        id: string;
        /** Label name */
        title: string;
        /** Label color code */
        color: string;
    }>;
}
/**
 * Options for listing domains
 * @interface DomainListOptions
 */
interface DomainListOptions {
    /** Starting index for pagination */
    start?: number;
    /** Include domain labels in response */
    includeLabels?: boolean;
}
/**
 * Response for domain listing
 * @interface DomainListResponse
 */
interface DomainListResponse extends APIResponse {
    /** Array of domain information */
    domains: DomainInfo[];
}
/**
 * Response for nameserver retrieval
 * @interface NameServersResponse
 */
interface NameServersResponse extends APIResponse {
    /** Array of nameserver hostnames */
    ns: string[];
}
/**
 * URL forwarding configuration
 * @interface URLForwardingOptions
 */
interface URLForwardingOptions {
    /** Subdomain to forward. Leave empty for root domain */
    subdomain?: string;
    /** Target URL to forward to */
    location: string;
    /** Forward type */
    type: 'temporary' | 'permanent';
    /** Include path in forwarding */
    includePath: 'yes' | 'no';
    /** Also forward all subdomains */
    wildcard: 'yes' | 'no';
}
/**
 * URL forwarding rule
 * @interface URLForward
 */
interface URLForward {
    /** Forwarding rule ID */
    id: string;
    /** Forwarded subdomain */
    subdomain: string;
    /** Destination URL */
    location: string;
    /** Forwarding type */
    type: 'temporary' | 'permanent';
    /** Path inclusion setting */
    includePath: 'yes' | 'no';
    /** Wildcard setting */
    wildcard: 'yes' | 'no';
}
/**
 * Response for URL forwarding retrieval
 * @interface URLForwardingResponse
 */
interface URLForwardingResponse extends APIResponse {
    /** Array of forwarding rules */
    forwards: URLForward[];
}

/**
 * Handles domain-related operations
 * @class DomainModule
 * @extends {PorkbunClient}
 *
 * @example
 * ```typescript
 * const api = new PorkbunAPI({
 *   apiKey: 'YOUR_API_KEY',
 *   secretApiKey: 'YOUR_SECRET_API_KEY'
 * });
 *
 * // Access domain operations through the domain module
 * const domains = await api.domain.listAll();
 * ```
 */
declare class DomainModule extends PorkbunClient {
    /**
     * Lists all domains in your account
     * @param {DomainListOptions} [options={}] - Optional parameters
     * @param {number} [options.start] - Starting index for pagination
     * @param {boolean} [options.includeLabels] - Include domain labels in response
     * @returns {Promise<DomainListResponse>} List of domains
     *
     * @example
     * ```typescript
     * // List all domains
     * const domains = await api.domain.listAll();
     *
     * // List domains with pagination and labels
     * const domainsWithLabels = await api.domain.listAll({
     *   start: 10,
     *   includeLabels: true
     * });
     * ```
     */
    listAll(options?: DomainListOptions): Promise<DomainListResponse>;
    /**
     * Gets nameservers for a domain
     * @param {string} domain - The domain name
     * @returns {Promise<NameServersResponse>} Current nameservers
     *
     * @example
     * ```typescript
     * const nameservers = await api.domain.getNameServers('example.com');
     * ```
     */
    getNameServers(domain: string): Promise<NameServersResponse>;
    /**
     * Updates nameservers for a domain
     * @param {string} domain - The domain name
     * @param {string[]} nameservers - Array of nameserver hostnames
     * @returns {Promise<APIResponse>} Update operation response
     *
     * @example
     * ```typescript
     * await api.domain.updateNameServers('example.com', [
     *   'ns1.provider.com',
     *   'ns2.provider.com'
     * ]);
     * ```
     */
    updateNameServers(domain: string, nameservers: string[]): Promise<APIResponse>;
    /**
     * Adds URL forwarding for a domain
     * @param {string} domain - The domain name
     * @param {URLForwardingOptions} options - Forwarding configuration
     * @param {('redirect'|'permanent'|'masked')} options.type - Type of forwarding
     * @param {string} options.destination - Target URL
     * @returns {Promise<APIResponse>} Creation response
     *
     * @example
     * ```typescript
     * await api.domain.addUrlForward('example.com', {
     *   type: 'redirect',
     *   destination: 'https://target.com'
     * });
     * ```
     */
    addUrlForward(domain: string, options: URLForwardingOptions): Promise<APIResponse>;
    /**
     * Gets URL forwarding settings for a domain
     * @param {string} domain - The domain name
     * @returns {Promise<URLForwardingResponse>} Current forwarding rules
     *
     * @example
     * ```typescript
     * const forwards = await api.domain.getUrlForwarding('example.com');
     * ```
     */
    getUrlForwarding(domain: string): Promise<URLForwardingResponse>;
    /**
     * Deletes a URL forwarding rule
     * @param {string} domain - The domain name
     * @param {string} id - Forwarding rule ID
     * @returns {Promise<APIResponse>} Delete operation response
     *
     * @example
     * ```typescript
     * await api.domain.deleteUrlForward('example.com', 'forward123');
     * ```
     */
    deleteUrlForward(domain: string, id: string): Promise<APIResponse>;
    /**
     * Tests API connectivity
     * @returns {Promise<APIResponse>} Ping response with status
     *
     * @example
     * ```typescript
     * await api.domain.ping();
     * ```
     */
    ping(): Promise<unknown>;
}

/**
 * Supported DNS record types
 */
type DNSRecordType = 'A' | 'MX' | 'CNAME' | 'ALIAS' | 'TXT' | 'NS' | 'AAAA' | 'SRV' | 'TLSA' | 'CAA' | 'HTTPS' | 'SVCB';
/**
 * DNS record details
 */
interface DNSRecord {
    /** Record identifier */
    id: string;
    /** Record name (subdomain) */
    name: string;
    /** Record type */
    type: DNSRecordType;
    /** Record value */
    content: string;
    /** Time to live */
    ttl: string;
    /** Priority (for MX/SRV) */
    prio: string;
    /** Optional record notes */
    notes: string;
}
/**
 * Options for creating DNS records
 */
interface DNSCreateOptions {
    /**
     * Subdomain for the record, not including domain itself.
     * Leave blank for root domain. Use * for wildcard record
     */
    name?: string;
    /** Record type */
    type: DNSRecordType;
    /**
     * Record value. See DNS management console for proper formatting
     * of each record type
     */
    content: string;
    /**
     * Time to live in seconds.
     * @minimum 600
     * @default 600
     */
    ttl?: number;
    /** Priority for records that support it (MX, SRV) */
    prio?: number;
}
/**
 * Options for editing DNS records
 * All fields are optional
 */
interface DNSEditOptions extends Partial<DNSCreateOptions> {
}
/**
 * Response when retrieving DNS records
 */
interface DNSRecordsResponse extends APIResponse {
    /** Array of DNS records */
    records: DNSRecord[];
}
/**
 * Response when creating a DNS record
 */
interface DNSCreateResponse extends APIResponse {
    /** ID of created record */
    id: string;
}

/**
 * Handles DNS record operations
 * @class DNSModule
 * @extends {PorkbunClient}
 *
 * @example
 * ```typescript
 * const api = new PorkbunAPI({
 *   apiKey: 'YOUR_API_KEY',
 *   secretApiKey: 'YOUR_SECRET_API_KEY'
 * });
 *
 * // Access DNS operations through the dns module
 * const records = await api.dns.retrieve('example.com');
 * ```
 */
declare class DNSModule extends PorkbunClient {
    /**
     * Creates a new DNS record
     * @param {string} domain - The domain name
     * @param {DNSCreateOptions} options - DNS record configuration
     * @param {DNSRecordType} options.type - Record type (A, AAAA, MX, etc.)
     * @param {string} options.name - Subdomain or @ for root
     * @param {string} options.content - Record value
     * @param {number} [options.ttl] - Time to live in seconds
     * @returns {Promise<DNSCreateResponse>} Creation response with record ID
     *
     * @example
     * ```typescript
     * await api.dns.create('example.com', {
     *   type: 'A',
     *   name: 'www',
     *   content: '192.0.2.1',
     *   ttl: 600
     * });
     * ```
     */
    create(domain: string, options: DNSCreateOptions): Promise<DNSCreateResponse>;
    /**
     * Edits an existing DNS record
     * @param {string} domain - The domain name
     * @param {string} id - Record ID to edit
     * @param {DNSEditOptions} options - Updated record configuration
     * @returns {Promise<APIResponse>} Edit operation response
     *
     * @example
     * ```typescript
     * await api.dns.edit('example.com', 'record123', {
     *   content: '192.0.2.2'
     * });
     * ```
     */
    edit(domain: string, id: string, options: DNSEditOptions): Promise<APIResponse>;
    /**
     * Edits DNS records matching name and type
     * @param {string} domain - The domain name
     * @param {DNSRecordType} type - Record type to edit
     * @param {string} subdomain - Subdomain or @ for root
     * @param {DNSEditOptions} options - Updated record configuration
     * @returns {Promise<APIResponse>} Edit operation response
     *
     * @example
     * ```typescript
     * await api.dns.editByNameType('example.com', 'A', 'www', {
     *   content: '192.0.2.2'
     * });
     * ```
     */
    editByNameType(domain: string, type: DNSRecordType, subdomain: string, options: DNSEditOptions): Promise<APIResponse>;
    /**
     * Deletes a DNS record
     * @param {string} domain - The domain name
     * @param {string} id - Record ID to delete
     * @returns {Promise<APIResponse>} Delete operation response
     *
     * @example
     * ```typescript
     * await api.dns.delete('example.com', 'record123');
     * ```
     */
    delete(domain: string, id: string): Promise<APIResponse>;
    /**
     * Deletes DNS records matching name and type
     * @param {string} domain - The domain name
     * @param {DNSRecordType} type - Record type to delete
     * @param {string} subdomain - Subdomain or @ for root
     * @returns {Promise<APIResponse>} Delete operation response
     *
     * @example
     * ```typescript
     * await api.dns.deleteByNameType('example.com', 'A', 'www');
     * ```
     */
    deleteByNameType(domain: string, type: DNSRecordType, subdomain: string): Promise<APIResponse>;
    /**
     * Retrieves DNS records
     * @param {string} domain - The domain name
     * @param {string} [id] - Optional record ID for specific record
     * @returns {Promise<DNSRecordsResponse>} DNS records
     *
     * @example
     * ```typescript
     * // Get all records
     * const allRecords = await api.dns.retrieve('example.com');
     *
     * // Get specific record
     * const record = await api.dns.retrieve('example.com', 'record123');
     * ```
     */
    retrieve(domain: string, id?: string): Promise<DNSRecordsResponse>;
    /**
     * Retrieves DNS records matching name and type
     * @param {string} domain - The domain name
     * @param {DNSRecordType} type - Record type to retrieve
     * @param {string} subdomain - Subdomain or @ for root
     * @returns {Promise<DNSRecordsResponse>} Matching DNS records
     *
     * @example
     * ```typescript
     * const records = await api.dns.retrieveByNameType('example.com', 'A', 'www');
     * ```
     */
    retrieveByNameType(domain: string, type: DNSRecordType, subdomain: string): Promise<DNSRecordsResponse>;
}

/**
 * SSL certificate bundle contents
 * @interface SSLBundle
 * @property {string} certificatechain - Full certificate chain in PEM format
 * @property {string} privatekey - Private key in PEM format
 * @property {string} publickey - Public key in PEM format
 */
interface SSLBundle {
    certificatechain: string;
    privatekey: string;
    publickey: string;
}
/**
 * Response type for SSL bundle retrieval
 * @type {APIResponse & SSLBundle}
 */
type SSLBundleResponse = APIResponse & SSLBundle;

/**
 * Handles SSL certificate operations
 * @class SSLModule
 * @extends {PorkbunClient}
 *
 * @example
 * ```typescript
 * const api = new PorkbunAPI({
 *   apiKey: 'YOUR_API_KEY',
 *   secretApiKey: 'YOUR_SECRET_API_KEY'
 * });
 *
 * const ssl = await api.ssl.retrieve('example.com');
 * ```
 */
declare class SSLModule extends PorkbunClient {
    /**
     * Retrieves SSL certificate bundle for a domain
     * @param {string} domain - The domain name
     * @returns {Promise<SSLBundleResponse>} SSL certificate bundle
     *
     * @example
     * ```typescript
     * const bundle = await api.ssl.retrieve('example.com');
     * ```
     */
    retrieve(domain: string): Promise<SSLBundleResponse>;
}

declare class PorkbunAPI {
    readonly domain: DomainModule;
    readonly dns: DNSModule;
    readonly ssl: SSLModule;
    constructor(config: PorkbunConfig);
}

export { type APIResponse, type DNSCreateOptions, type DNSCreateResponse, type DNSEditOptions, type DNSRecord, type DNSRecordType, type DNSRecordsResponse, type DomainInfo, type DomainListOptions, type DomainListResponse, type NameServersResponse, type PingResponse, PorkbunAPI, type SSLBundle, type SSLBundleResponse, type URLForward, type URLForwardingOptions, type URLForwardingResponse };
