Exemplo n.º 1
0
        internal Query(GlobalParameters globals)
        {
            if (globals == null)
                throw new ArgumentNullException("globals");

            _globals = globals;
        }
Exemplo n.º 2
0

        
 public NameCheapApi(string username, string apiUser, string apiKey, string clientIp, bool isSandbox = false)
 {
     _params = new GlobalParameters()
     {
         ApiKey = apiKey,
         ApiUser = apiUser,
         CLientIp = clientIp,
         IsSandBox = isSandbox,
         UserName = username
     };
 }
Exemplo n.º 4
0
 public NameCheapApi(string username, string apiUser, string apiKey, string clientIp, bool isSandbox = false)
 {
     _params = new GlobalParameters()
     {
         ApiKey    = apiKey,
         ApiUser   = apiUser,
         CLientIp  = clientIp,
         IsSandBox = isSandbox,
         UserName  = username
     };
 }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a NameCheap API instance configured with the appropriate credentials.
        /// All parameters are required.
        /// </summary>
        /// <param name="username">The Username on which a command is executed. Generally, the values of ApiUser and UserName parameters are the same.</param>
        /// <param name="apiUser">Username required to access the API</param>
        /// <param name="apiKey">Password required used to access the API</param>
        /// <param name="clientIp">An IP address of the server from which our system receives API calls (only IPv4 can be used).</param>
        /// <param name="isSandbox">Whether to execute the commands against the sandbox API or the live API.</param>
        /// <remarks>
        /// See the '$/docs/running_tests.md' on how to set up a Sandbox account in order
        /// to test the operations of the API before going live.
        /// </remarks>
        public NameCheapApi(string username, string apiUser, string apiKey, string clientIp, bool isSandbox = false)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentNullException(nameof(username));
            }

            if (string.IsNullOrWhiteSpace(apiUser))
            {
                throw new ArgumentNullException(nameof(apiUser));
            }

            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentNullException(nameof(apiKey));
            }

            if (string.IsNullOrWhiteSpace(clientIp))
            {
                throw new ArgumentNullException(nameof(clientIp));
            }
            else
            {
                if (IPAddress.TryParse(clientIp, out var ip))
                {
                    if (ip.AddressFamily != AddressFamily.InterNetwork)
                    {
                        throw new ArgumentException($"Client IP {clientIp} is not a valid IPv4 address.", nameof(clientIp));
                    }
                }
                else
                {
                    throw new ArgumentException($"{clientIp} does not seem a valid IP address.", nameof(clientIp));
                }
            }

            _params = new GlobalParameters()
            {
                ApiKey    = apiKey,
                ApiUser   = apiUser,
                CLientIp  = clientIp,
                IsSandBox = isSandbox,
                UserName  = username
            };

            _dnsApi     = new Lazy <DnsApi>(() => new DnsApi(_params));
            _domainsApi = new Lazy <DomainsApi>(() => new DomainsApi(_params));
        }
Exemplo n.º 6
0
 internal DomainsApi(GlobalParameters globalParams)
 {
     _params = globalParams;
 }
Exemplo n.º 7
0
 internal DomainsApi(GlobalParameters globalParams)
 {
     _params = globalParams;
 }