namecheap 0.3.0 → 0.3.1
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +15 -0
- data/README.md +102 -59
- data/lib/namecheap/api.rb +39 -26
- data/lib/namecheap/config.rb +20 -5
- data/lib/namecheap/dns.rb +16 -16
- data/lib/namecheap/domains.rb +22 -22
- data/lib/namecheap/ns.rb +8 -8
- data/lib/namecheap/ssl.rb +17 -17
- data/lib/namecheap/transfers.rb +7 -7
- data/lib/namecheap/users.rb +10 -10
- data/lib/namecheap/version.rb +1 -1
- data/lib/namecheap/whois_guard.rb +14 -12
- data/lib/namecheap.rb +12 -15
- metadata +80 -50
- data/.gitignore +0 -8
- data/.ruby-version +0 -1
- data/.travis.yml +0 -7
- data/Gemfile +0 -12
- data/Rakefile +0 -6
- data/namecheap.gemspec +0 -27
- data/spec/helper.rb +0 -25
- data/spec/namecheap/dns_spec.rb +0 -13
- data/spec/namecheap/domains_spec.rb +0 -13
- data/spec/namecheap/ns_spec.rb +0 -13
- data/spec/namecheap/ssl_spec.rb +0 -17
- data/spec/namecheap/transfers.rb +0 -13
- data/spec/namecheap/users_spec.rb +0 -13
- data/spec/namecheap/whois_guard_spec.rb +0 -13
- data/spec/namecheap_spec.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ac9a157ca91cc9a4089e1e2bd74c2f83fd58b9d5b5e07d8eeccc3ac3ccc9d0e5
|
|
4
|
+
data.tar.gz: 164c6465fe12394adb24b8a7217b114bb35549af30c154016d8b26e44ac9e8ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e24890a03f3420defe8dda7102ba59b59d8f4171ddff4eb01fe15c06d3485c53b69293ecceecfa2911e1909e0cfaa206ee23656312452e9cad9e2698fb3b0bb
|
|
7
|
+
data.tar.gz: 1daca40cfe219520446afaa5c5518bafc64d3b44ef22a554afb20aea0a2f99a963da215132b3f96d28be82584faaec1c1608ab2c4ff7e9b0f4342cdc8abef61d
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.1 (2026-07-25)
|
|
4
|
+
|
|
5
|
+
- Require Ruby 3.3 or newer and add CI coverage for supported Ruby versions.
|
|
6
|
+
- Fix required configuration validation for username and client IP.
|
|
7
|
+
- Fix PUT and DELETE request dispatch.
|
|
8
|
+
- Fix YAML configuration loading on modern Ruby.
|
|
9
|
+
- Replace accidental live-network specs with deterministic request tests.
|
|
10
|
+
- Modernize gem metadata, development tooling, and documentation.
|
|
11
|
+
- Allow sandbox or production selection independently of the Rails/Rack environment.
|
|
12
|
+
|
|
13
|
+
## 0.3.0 (2014-08-18)
|
|
14
|
+
|
|
15
|
+
- Refactor the API wrappers and add Rails 3 compatibility.
|
data/README.md
CHANGED
|
@@ -1,94 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
========
|
|
1
|
+
# Namecheap
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
-----
|
|
3
|
+
`namecheap` is a Ruby wrapper for the [Namecheap XML API](https://www.namecheap.com/support/api/intro/). It supports the existing domains, DNS, nameserver, transfer, SSL, user, and domain privacy commands exposed by the gem.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Version 0.3.1 requires Ruby 3.3 or newer.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
-----
|
|
7
|
+
## Installation
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
Add the gem to your bundle:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem "namecheap"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then run `bundle install`.
|
|
16
|
+
|
|
17
|
+
## API setup
|
|
18
|
+
|
|
19
|
+
Enable API access in your Namecheap account and whitelist the public IPv4 address that will make requests. Sandbox and production use separate accounts and credentials.
|
|
20
|
+
|
|
21
|
+
The gem uses the sandbox endpoint unless `RACK_ENV` (or `Rails.env`) is `production`. Test requests against the sandbox before enabling production:
|
|
13
22
|
|
|
14
23
|
```ruby
|
|
15
24
|
Namecheap.configure do |config|
|
|
16
|
-
config.key =
|
|
17
|
-
config.username =
|
|
18
|
-
config.client_ip =
|
|
25
|
+
config.key = ENV.fetch("NAMECHEAP_API_KEY")
|
|
26
|
+
config.username = ENV.fetch("NAMECHEAP_USERNAME")
|
|
27
|
+
config.client_ip = ENV.fetch("NAMECHEAP_CLIENT_IP")
|
|
19
28
|
end
|
|
20
29
|
```
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
Applications can select the Namecheap environment independently of `RACK_ENV`
|
|
32
|
+
or `Rails.env`. This is useful when a staging application runs in production
|
|
33
|
+
mode but must continue using Namecheap's sandbox:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
Namecheap.configure do |config|
|
|
37
|
+
config.environment = "sandbox"
|
|
38
|
+
end
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Set `environment` to either `"sandbox"` or `"production"`. Leave it unset, or
|
|
42
|
+
set it to `nil`, to retain automatic Rails/Rack environment selection.
|
|
43
|
+
|
|
44
|
+
Avoid committing API keys or account configuration to source control.
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
The resource methods mirror Namecheap command names:
|
|
23
49
|
|
|
24
50
|
```ruby
|
|
25
51
|
Namecheap.domains.get_list
|
|
52
|
+
Namecheap.domains.check(["example.com", "example.net"])
|
|
53
|
+
Namecheap.dns.get_hosts("example", "com")
|
|
26
54
|
```
|
|
27
55
|
|
|
28
|
-
|
|
56
|
+
Additional command parameters can be passed as a final hash:
|
|
29
57
|
|
|
30
|
-
|
|
31
|
-
|
|
58
|
+
```ruby
|
|
59
|
+
Namecheap.domains.get_list(page: 2, page_size: 50)
|
|
60
|
+
```
|
|
32
61
|
|
|
33
|
-
Namecheap
|
|
62
|
+
Namecheap returns XML responses. This version returns the `HTTParty::Response` directly so existing applications can inspect the parsed response, status, and headers.
|
|
34
63
|
|
|
35
|
-
|
|
64
|
+
Configuration can also be loaded from an ERB-enabled YAML file. The selected top-level key must match `RACK_ENV`, or `development` when it is unset:
|
|
36
65
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
```yaml
|
|
67
|
+
development:
|
|
68
|
+
username: sandbox_user
|
|
69
|
+
key: <%= ENV.fetch("NAMECHEAP_API_KEY") %>
|
|
70
|
+
client_ip: 192.0.2.1
|
|
71
|
+
environment: sandbox
|
|
72
|
+
```
|
|
42
73
|
|
|
43
|
-
|
|
44
|
-
|
|
74
|
+
```ruby
|
|
75
|
+
Namecheap::Config.load!("config/namecheap.yml")
|
|
76
|
+
```
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
* the DNS is pointed to our load balancer
|
|
48
|
-
* a subversion repository is created (with users)
|
|
49
|
-
* a template is committed to the repository with default pages
|
|
50
|
-
* a project is created in webistrano
|
|
51
|
-
* the initial setup and deployment is done
|
|
78
|
+
## Development
|
|
52
79
|
|
|
53
|
-
|
|
54
|
-
We purchase most of our domains from Namecheap (and some from GoDaddy) and it was
|
|
55
|
-
fortunate that Namecheap has an API. Unfortunately there didn't seem to be a gem
|
|
56
|
-
that already existed.
|
|
80
|
+
Install dependencies and run the test and style checks:
|
|
57
81
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
```shell
|
|
83
|
+
mise exec -- bundle install
|
|
84
|
+
mise exec -- bundle exec rake
|
|
85
|
+
```
|
|
62
86
|
|
|
63
|
-
|
|
64
|
-
-------
|
|
87
|
+
Build a local gem without publishing it:
|
|
65
88
|
|
|
66
|
-
|
|
89
|
+
```shell
|
|
90
|
+
mise exec -- bundle exec gem build namecheap.gemspec
|
|
91
|
+
```
|
|
67
92
|
|
|
68
|
-
|
|
93
|
+
### Manual release
|
|
69
94
|
|
|
70
|
-
|
|
95
|
+
Releases from this legacy branch are intentionally manual. Start from a clean
|
|
96
|
+
`legacy/0.3` checkout and confirm that `lib/namecheap/version.rb` and the dated
|
|
97
|
+
changelog heading contain the same version. Then run:
|
|
71
98
|
|
|
99
|
+
```shell
|
|
100
|
+
mise exec -- bundle install
|
|
101
|
+
mise exec -- bundle exec rake
|
|
102
|
+
mise exec -- bundle exec gem build namecheap.gemspec
|
|
103
|
+
mise exec -- ruby -rrubygems/package -e \
|
|
104
|
+
'spec = Gem::Package.new(ARGV.fetch(0)).spec; puts "#{spec.name} #{spec.version} (Ruby #{spec.required_ruby_version})"' \
|
|
105
|
+
namecheap-0.3.1.gem
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Commit and push the finalized release changes before creating a signed,
|
|
109
|
+
annotated tag for the exact release commit:
|
|
72
110
|
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
```shell
|
|
112
|
+
git tag -s v0.3.1 -m "Release 0.3.1"
|
|
113
|
+
git push origin legacy/0.3
|
|
114
|
+
git push origin v0.3.1
|
|
115
|
+
```
|
|
75
116
|
|
|
76
|
-
|
|
117
|
+
Publish the artifact to RubyGems manually. RubyGems may prompt for MFA:
|
|
77
118
|
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
```shell
|
|
120
|
+
mise exec -- gem push namecheap-0.3.1.gem
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
After RubyGems reports version 0.3.1 as published, create the corresponding
|
|
124
|
+
GitHub Release:
|
|
125
|
+
|
|
126
|
+
```shell
|
|
127
|
+
gh release create v0.3.1 --verify-tag --generate-notes --title v0.3.1
|
|
128
|
+
```
|
|
80
129
|
|
|
81
|
-
|
|
130
|
+
Changing the version, building the gem, or pushing the branch does not publish
|
|
131
|
+
a release.
|
|
82
132
|
|
|
83
|
-
|
|
84
|
-
it under the terms of the GNU General Public License as published by
|
|
85
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
86
|
-
(at your option) any later version.
|
|
133
|
+
## License
|
|
87
134
|
|
|
88
|
-
This
|
|
89
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
90
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
91
|
-
GNU General Public License for more details.
|
|
135
|
+
Copyright 2011 Tristan V. Gomez. This project is available under the GNU Lesser General Public License, version 3 or any later version. See [COPYING](COPYING).
|
|
92
136
|
|
|
93
|
-
|
|
94
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
137
|
+
The original API wrapper was forked from Hashrocket's `namecheap` project.
|
data/lib/namecheap/api.rb
CHANGED
|
@@ -1,62 +1,75 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "active_support/core_ext/string/inflections"
|
|
2
2
|
|
|
3
3
|
module Namecheap
|
|
4
4
|
class Api
|
|
5
|
-
SANDBOX =
|
|
6
|
-
PRODUCTION =
|
|
7
|
-
ENVIRONMENT = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : (ENV["RACK_ENV"] ||
|
|
8
|
-
ENDPOINT = (ENVIRONMENT ==
|
|
5
|
+
SANDBOX = "https://api.sandbox.namecheap.com/xml.response"
|
|
6
|
+
PRODUCTION = "https://api.namecheap.com/xml.response"
|
|
7
|
+
ENVIRONMENT = (defined?(Rails) && Rails.respond_to?(:env)) ? Rails.env.to_s : (ENV["RACK_ENV"] || "development")
|
|
8
|
+
ENDPOINT = (ENVIRONMENT == "production") ? PRODUCTION : SANDBOX
|
|
9
9
|
|
|
10
10
|
def get(command, options = {})
|
|
11
|
-
request
|
|
11
|
+
request "get", command, options
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def post(command, options = {})
|
|
15
|
-
request
|
|
15
|
+
request "post", command, options
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def put(command, options = {})
|
|
19
|
-
request
|
|
19
|
+
request "put", command, options
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def delete(command, options = {})
|
|
23
|
-
request
|
|
23
|
+
request "delete", command, options
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def request(method, command, options = {})
|
|
27
|
-
command =
|
|
28
|
-
options = init_args.merge(options).merge(
|
|
27
|
+
command = "namecheap.#{command}"
|
|
28
|
+
options = init_args.merge(options).merge(command: command)
|
|
29
29
|
options.keys.each do |key|
|
|
30
30
|
options[key.to_s.camelize] = options.delete(key)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
case method
|
|
34
|
-
when
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
HTTParty.delete(ENDPOINT, { :query => options})
|
|
34
|
+
when "get"
|
|
35
|
+
HTTParty.get(endpoint, query: options)
|
|
36
|
+
when "post"
|
|
37
|
+
HTTParty.post(endpoint, query: options)
|
|
38
|
+
when "put"
|
|
39
|
+
HTTParty.put(endpoint, query: options)
|
|
40
|
+
when "delete"
|
|
41
|
+
HTTParty.delete(endpoint, query: options)
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def init_args
|
|
47
|
-
%w
|
|
48
|
-
if Namecheap.config.key.nil?
|
|
46
|
+
%w[username key client_ip].each do |key|
|
|
47
|
+
if Namecheap.config.public_send(key).nil?
|
|
49
48
|
raise Namecheap::Config::RequiredOptionMissing,
|
|
50
|
-
"Configuration parameter missing: #{key}, "
|
|
49
|
+
"Configuration parameter missing: #{key}, " \
|
|
51
50
|
"please add it to the Namecheap.configure block"
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
api_user: Namecheap.config.username,
|
|
56
56
|
user_name: Namecheap.config.username,
|
|
57
|
-
api_key:
|
|
57
|
+
api_key: Namecheap.config.key,
|
|
58
58
|
client_ip: Namecheap.config.client_ip
|
|
59
59
|
}
|
|
60
60
|
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def endpoint
|
|
65
|
+
case Namecheap.config.environment
|
|
66
|
+
when "sandbox"
|
|
67
|
+
SANDBOX
|
|
68
|
+
when "production"
|
|
69
|
+
PRODUCTION
|
|
70
|
+
else
|
|
71
|
+
ENDPOINT
|
|
72
|
+
end
|
|
73
|
+
end
|
|
61
74
|
end
|
|
62
75
|
end
|
data/lib/namecheap/config.rb
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
require "yaml"
|
|
3
|
+
|
|
1
4
|
module Namecheap
|
|
2
5
|
module Config
|
|
3
|
-
class RequiredOptionMissing < RuntimeError
|
|
6
|
+
class RequiredOptionMissing < RuntimeError; end
|
|
4
7
|
extend self
|
|
5
8
|
|
|
9
|
+
ENVIRONMENTS = %w[sandbox production].freeze
|
|
10
|
+
|
|
6
11
|
attr_accessor :key, :username, :client_ip
|
|
12
|
+
attr_reader :environment
|
|
13
|
+
|
|
14
|
+
def environment=(environment)
|
|
15
|
+
if environment.nil?
|
|
16
|
+
@environment = nil
|
|
17
|
+
elsif ENVIRONMENTS.include?(environment)
|
|
18
|
+
@environment = environment
|
|
19
|
+
else
|
|
20
|
+
raise ArgumentError, "environment must be sandbox or production"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
7
23
|
|
|
8
24
|
# Configure namecheap from a hash. This is usually called after parsing a
|
|
9
25
|
# yaml config file such as mongoid.yml.
|
|
@@ -26,10 +42,9 @@ module Namecheap
|
|
|
26
42
|
#
|
|
27
43
|
# @param [ String ] path The path to the file.
|
|
28
44
|
def load!(path)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
45
|
+
contents = ERB.new(File.read(path)).result
|
|
46
|
+
settings = YAML.safe_load(contents, aliases: true)&.fetch(Namecheap::Api::ENVIRONMENT, nil)
|
|
47
|
+
from_hash(settings) if settings && !settings.empty?
|
|
33
48
|
end
|
|
34
49
|
end
|
|
35
50
|
end
|
data/lib/namecheap/dns.rb
CHANGED
|
@@ -3,54 +3,54 @@ module Namecheap
|
|
|
3
3
|
# Sets domain to use Namecheap's default DNS servers.
|
|
4
4
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:setdefault
|
|
5
5
|
def set_default(sld, tld, options = {})
|
|
6
|
-
options = {:
|
|
7
|
-
get
|
|
6
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
7
|
+
get "domains.dns.setDefault", options
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
# Sets domain to use custom DNS servers.
|
|
11
11
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:setcustom
|
|
12
12
|
def set_custom(sld, tld, nameservers = [], options = {})
|
|
13
13
|
if nameservers.respond_to?(:join)
|
|
14
|
-
nameservers = nameservers.join(
|
|
14
|
+
nameservers = nameservers.join(",")
|
|
15
15
|
end
|
|
16
|
-
|
|
17
|
-
options = {:
|
|
18
|
-
get
|
|
16
|
+
|
|
17
|
+
options = {SLD: sld, TLD: tld, Nameservers: nameservers}.merge(options)
|
|
18
|
+
get "domains.dns.setCustom", options
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Gets a list of DNS servers associated with the requested domain.
|
|
22
22
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:getlist
|
|
23
23
|
def get_list(sld, tld, options = {})
|
|
24
|
-
options = {:
|
|
25
|
-
get
|
|
24
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
25
|
+
get "domains.dns.getList", options
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# Retrieves DNS host record settings for the requested domain.
|
|
29
29
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:gethosts
|
|
30
30
|
def get_hosts(sld, tld, options = {})
|
|
31
|
-
options = {:
|
|
32
|
-
get
|
|
31
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
32
|
+
get "domains.dns.getHosts", options
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Gets email forwarding settings for the requested domain.
|
|
36
36
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:getemailforwarding
|
|
37
37
|
def get_email_forwarding(domain, options = {})
|
|
38
|
-
options = {:
|
|
39
|
-
get
|
|
38
|
+
options = {DomainName: domain}.merge(options)
|
|
39
|
+
get "domains.dns.getEmailForwarding", options
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Sets email forwarding for a domain name.
|
|
43
43
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:setemailforwarding
|
|
44
44
|
def set_email_forwarding(domain, options = {})
|
|
45
|
-
options = {:
|
|
46
|
-
get
|
|
45
|
+
options = {DomainName: domain}.merge(options)
|
|
46
|
+
get "domains.dns.setEmailForwarding", options
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# Sets DNS host records settings for the requested domain.
|
|
50
50
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.dns:sethosts
|
|
51
51
|
def set_hosts(sld, tld, options = {})
|
|
52
|
-
options = {:
|
|
53
|
-
get
|
|
52
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
53
|
+
get "domains.dns.setHosts", options
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
data/lib/namecheap/domains.rb
CHANGED
|
@@ -3,80 +3,80 @@ module Namecheap
|
|
|
3
3
|
# Returns a list of domains for the particular user.
|
|
4
4
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:getlist
|
|
5
5
|
def get_list(options = {})
|
|
6
|
-
get
|
|
6
|
+
get "domains.getList", options
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
# Gets contact information for the requested domain.
|
|
10
10
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:getcontacts
|
|
11
11
|
def get_contacts(domain, options = {})
|
|
12
|
-
options = {:
|
|
13
|
-
get
|
|
12
|
+
options = {DomainName: domain}.merge(options)
|
|
13
|
+
get "domains.getContacts", options
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Registers a domain.
|
|
17
17
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:create
|
|
18
18
|
def create(domain, options = {})
|
|
19
|
-
options = {:
|
|
20
|
-
get
|
|
19
|
+
options = {DomainName: domain}.merge(options)
|
|
20
|
+
get "domains.create", options
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
# Returns a list of tlds.
|
|
24
24
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:gettldlist
|
|
25
25
|
def get_tld_list(options = {})
|
|
26
|
-
get
|
|
26
|
+
get "domains.getTldList", options
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Sets contact information for the requested domain.
|
|
30
30
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:setcontacts
|
|
31
31
|
def set_contacts(domain, options = {})
|
|
32
|
-
options = {:
|
|
33
|
-
get
|
|
32
|
+
options = {DomainName: domain}.merge(options)
|
|
33
|
+
get "domains.setContacts", options
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# Checks the availability of domains.
|
|
37
37
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:check
|
|
38
38
|
def check(domains = [], options = {})
|
|
39
39
|
if domains.respond_to?(:join)
|
|
40
|
-
domains = domains.join(
|
|
40
|
+
domains = domains.join(",")
|
|
41
41
|
end
|
|
42
|
-
|
|
43
|
-
options = {:
|
|
44
|
-
get
|
|
42
|
+
|
|
43
|
+
options = {DomainList: domains}.merge(options)
|
|
44
|
+
get "domains.check", options
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Reactivates an expired domain.
|
|
48
48
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:reactivate
|
|
49
49
|
def reactivate(domain, options = {})
|
|
50
|
-
options = {:
|
|
51
|
-
get
|
|
50
|
+
options = {DomainName: domain}.merge(options)
|
|
51
|
+
get "domains.reactivate", options
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# Renews an expiring domain.
|
|
55
55
|
# http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:renew
|
|
56
56
|
def renew(domain, options = {})
|
|
57
|
-
options = {:
|
|
58
|
-
get
|
|
57
|
+
options = {DomainName: domain}.merge(options)
|
|
58
|
+
get "domains.renew", options
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# Gets the status of RegistrarLock for the requested domain.
|
|
62
62
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:getregistrarlock
|
|
63
63
|
def get_registrar_lock(domain, options = {})
|
|
64
|
-
options = {:
|
|
65
|
-
get
|
|
64
|
+
options = {DomainName: domain}.merge(options)
|
|
65
|
+
get "domains.getRegistrarLock", options
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Sets the RegistrarLock status for a domain.
|
|
69
69
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:setregistrarlock
|
|
70
70
|
def set_registrar_lock(domain, options = {})
|
|
71
|
-
options = {:
|
|
72
|
-
get
|
|
71
|
+
options = {DomainName: domain}.merge(options)
|
|
72
|
+
get "domains.setRegistrarLock", options
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# Returns information about the requested domain.
|
|
76
76
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains:getinfo
|
|
77
77
|
def get_info(domain, options = {})
|
|
78
|
-
options = {:
|
|
79
|
-
get
|
|
78
|
+
options = {DomainName: domain}.merge(options)
|
|
79
|
+
get "domains.getInfo", options
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
data/lib/namecheap/ns.rb
CHANGED
|
@@ -3,29 +3,29 @@ module Namecheap
|
|
|
3
3
|
# Creates a new nameserver.
|
|
4
4
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.ns:create
|
|
5
5
|
def create(sld, tld, options = {})
|
|
6
|
-
options = {:
|
|
7
|
-
get
|
|
6
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
7
|
+
get "domains.ns.create", options
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
# Deletes a nameserver associated with the requested domain.
|
|
11
11
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.ns:delete
|
|
12
12
|
def delete(sld, tld, options = {})
|
|
13
|
-
options = {:
|
|
14
|
-
get
|
|
13
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
14
|
+
get "domains.ns.delete", options
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# Retrieves information about a registered nameserver.
|
|
18
18
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.ns:getinfo
|
|
19
19
|
def get_info(sld, tld, options = {})
|
|
20
|
-
options = {:
|
|
21
|
-
get
|
|
20
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
21
|
+
get "domains.ns.getInfo", options
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# Updates the IP address of a registered nameserver.
|
|
25
25
|
# @see http://developer.namecheap.com/docs/doku.php?id=api-reference:domains.ns:update
|
|
26
26
|
def update(sld, tld, options = {})
|
|
27
|
-
options = {:
|
|
28
|
-
get
|
|
27
|
+
options = {SLD: sld, TLD: tld}.merge(options)
|
|
28
|
+
get "domains.ns.update", options
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
end
|