namecheap 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,15 +39,15 @@ Usage
39
39
 
40
40
  In your initializers, configure Namecheap like so:
41
41
 
42
- Namecheap.configure do |config|
43
- config.key = 'apikey'
44
- config.username = 'apiuser'
45
- config.client_ip = '127.0.0.1'
46
- end
42
+ Namecheap.configure do |config|
43
+ config.key = 'apikey'
44
+ config.username = 'apiuser'
45
+ config.client_ip = '127.0.0.1'
46
+ end
47
47
 
48
48
  Then you can do something like:
49
49
 
50
- Namecheap.domains.get_list
50
+ Namecheap.domains.get_list
51
51
 
52
52
  Please see the Namecheap API documentation for more information
53
53
 
@@ -14,6 +14,14 @@ class Hash
14
14
  end.sort * '&'
15
15
  end
16
16
 
17
+ def camelize_keys!
18
+ keys.each do |key|
19
+ self[key.to_s.camelize] = delete(key)
20
+ end
21
+ self
22
+ end
23
+
24
+
17
25
  protected
18
26
 
19
27
  def to_query(key)
@@ -53,4 +61,24 @@ class Module
53
61
  module_eval("def #{prefix}#{method}(*args, &block)\n#{to}.__send__(#{method.inspect}, *args, &block)\nend\n", "(__DELEGATION__)", 1)
54
62
  end
55
63
  end
64
+ end
65
+
66
+ class String
67
+ def camelize(first_letter = :upper)
68
+ case first_letter
69
+ when :upper then _camelize(self, true)
70
+ when :lower then _camelize(self, false)
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def _camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
77
+ if first_letter_in_uppercase
78
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
79
+ else
80
+ lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
81
+ end
82
+ end
83
+
56
84
  end
@@ -9,13 +9,13 @@ module Namecheap
9
9
 
10
10
  extend self
11
11
 
12
- # Sets the Mongoid configuration options. Best used by passing a block.
12
+ # Sets the Namecheap configuration options. Best used by passing a block.
13
13
  #
14
14
  # @example Set up configuration options.
15
15
  # Namecheap.configure do |config|
16
- # key = "apikey"
17
- # username = "apiuser"
18
- # client_ip = "127.0.0.1"
16
+ # config.key = "apikey"
17
+ # config.username = "apiuser"
18
+ # config.client_ip = "127.0.0.1"
19
19
  # end
20
20
  # @return [ Config ] The configuration obejct.
21
21
  def configure
@@ -6,14 +6,17 @@ module Namecheap
6
6
  ENDPOINT = (ENVIRONMENT == 'production' ? PRODUCTION : SANDBOX)
7
7
 
8
8
  def api_call(command, command_args)
9
+ args = init_args(command_args.merge :command => command)
10
+ query = ENDPOINT + '?' + args.to_param
11
+ HTTParty.get(query)
12
+ end
13
+
14
+ def init_args(options = {})
9
15
  args = {}
10
16
  args['ApiUser'] = args['UserName'] = Namecheap.username
11
17
  args['ApiKey'] = Namecheap.key
12
18
  args['ClientIp'] = Namecheap.client_ip
13
- args['Command'] = command
14
- args.merge! command_args
15
- query = ENDPOINT + '?' + args.to_param
16
- HTTParty.get(query)
19
+ args.merge options.camelize_keys!
17
20
  end
18
21
  end
19
22
  end
@@ -0,0 +1,51 @@
1
+ module Namecheap
2
+ class Dns < Api
3
+ def set_default(sld, tld, options = {})
4
+ args = options.clone
5
+ args['SLD'] = sld
6
+ args['TLD'] = tld
7
+ api_call('namecheap.domains.dns.setDefault', args)
8
+ end
9
+
10
+ def set_custom(sld, tld, nameservers = [], options = {})
11
+ args = options.clone
12
+ args['SLD'] = sld
13
+ args['TLD'] = tld
14
+ args['Nameservers'] = nameservers.respond_to?(:join) ? nameservers.join(',') : nameservers
15
+ api_call('namecheap.domains.dns.setCustom', args)
16
+ end
17
+
18
+ def get_list(sld, tld, options = {})
19
+ args = options.clone
20
+ args['SLD'] = sld
21
+ args['TLD'] = tld
22
+ api_call('namecheap.domains.dns.getList', args)
23
+ end
24
+
25
+ def get_hosts(sld, tld, options = {})
26
+ args = options.clone
27
+ args['SLD'] = sld
28
+ args['TLD'] = tld
29
+ api_call('namecheap.domains.dns.getHosts', args)
30
+ end
31
+
32
+ def get_email_forwarding(domain, options = {})
33
+ args = options.clone
34
+ args['DomainName'] = domain
35
+ api_call('namecheap.domains.dns.getEmailForwarding', args)
36
+ end
37
+
38
+ def set_email_forwarding(domain, options = {})
39
+ args = options.clone
40
+ args['DomainName'] = domain
41
+ api_call('namecheap.domains.dns.setEmailForwarding', args)
42
+ end
43
+
44
+ def set_hosts(sld, tld, options = {})
45
+ args = options.clone
46
+ args['SLD'] = sld
47
+ args['TLD'] = tld
48
+ api_call('namecheap.domains.dns.setHosts', args)
49
+ end
50
+ end
51
+ end
@@ -5,10 +5,63 @@ module Namecheap
5
5
  api_call('namecheap.domains.getList', args)
6
6
  end
7
7
 
8
+ def get_contacts(domain, options = {})
9
+ args = options.clone
10
+ args['DomainName'] = domain
11
+ api_call('namecheap.domains.getContacts', args)
12
+ end
13
+
14
+ def create(domain, options = {})
15
+ args = options.clone
16
+ args['DomainName'] = domain
17
+ api_call('namecheap.domains.create', args)
18
+ end
19
+
20
+ def get_tld_list(options = {})
21
+ args = options.clone
22
+ api_call('namecheap.domains.getTldList', args)
23
+ end
24
+
25
+ def set_contacts(domain, options = {})
26
+ args = options.clone
27
+ args['DomainName'] = domain
28
+ api_call('namecheap.domains.setContacts', args)
29
+ end
30
+
8
31
  def check(domains = [], options = {})
9
32
  args = options.clone
10
33
  args['DomainList'] = domains.respond_to?(:join) ? domains.join(',') : domains
11
34
  api_call('namecheap.domains.check', args)
12
35
  end
36
+
37
+ def reactivate(domain, options = {})
38
+ args = options.clone
39
+ args['DomainName'] = domain
40
+ api_call('namecheap.domains.reactivate', args)
41
+ end
42
+
43
+ def renew(domain, options = {})
44
+ args = options.clone
45
+ args['DomainName'] = domain
46
+ api_call('namecheap.domains.renew', args)
47
+ end
48
+
49
+ def get_registrar_lock(domain, options = {})
50
+ args = options.clone
51
+ args['DomainName'] = domain
52
+ api_call('namecheap.domains.getRegistrarLock', args)
53
+ end
54
+
55
+ def set_registrar_lock(domain, options = {})
56
+ args = options.clone
57
+ args['DomainName'] = domain
58
+ api_call('namecheap.domains.setRegistrarLock', args)
59
+ end
60
+
61
+ def get_info(domain, options = {})
62
+ args = options.clone
63
+ args['DomainName'] = domain
64
+ api_call('namecheap.domains.getInfo', args)
65
+ end
13
66
  end
14
- end
67
+ end
@@ -0,0 +1,31 @@
1
+ module Namecheap
2
+ class Ns < Api
3
+ def create(sld, tld, options = {})
4
+ args = options.clone
5
+ args['SLD'] = sld
6
+ args['TLD'] = tld
7
+ api_call('namecheap.domains.ns.create', args)
8
+ end
9
+
10
+ def delete(sld, tld, options = {})
11
+ args = options.clone
12
+ args['SLD'] = sld
13
+ args['TLD'] = tld
14
+ api_call('namecheap.domains.ns.delete', args)
15
+ end
16
+
17
+ def get_info(sld, tld, options = {})
18
+ args = options.clone
19
+ args['SLD'] = sld
20
+ args['TLD'] = tld
21
+ api_call('namecheap.domains.ns.getInfo', args)
22
+ end
23
+
24
+ def update(sld, tld, options = {})
25
+ args = options.clone
26
+ args['SLD'] = sld
27
+ args['TLD'] = tld
28
+ api_call('namecheap.domains.ns.update', args)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,60 @@
1
+ module Namecheap
2
+ class Ssl < Api
3
+ def activate(id, options = {})
4
+ args = options.clone
5
+ args['CertificateID'] = id
6
+ api_call('namecheap.ssl.activate', args)
7
+ end
8
+
9
+ def get_info(id, options = {})
10
+ args = options.clone
11
+ args['CertificateID'] = id
12
+ api_call('namecheap.ssl.getInfo', args)
13
+ end
14
+
15
+ def parse_csr(csr, options = {})
16
+ args = options.clone
17
+ args['csr'] = csr
18
+ api_call('namecheap.ssl.parseCSR', args)
19
+ end
20
+
21
+ def get_approver_email_list(domain, options = {})
22
+ args = options.clone
23
+ args['DomainName'] = domain
24
+ api_call('namecheap.ssl.getApproverEmailList', args)
25
+ end
26
+
27
+ def get_list(options = {})
28
+ args = options.clone
29
+ api_call('namecheap.ssl.getList', args)
30
+ end
31
+
32
+ def create(options = {})
33
+ args = options.clone
34
+ api_call('namecheap.ssl.create', args)
35
+ end
36
+
37
+ def renew(options = {})
38
+ args = options.clone
39
+ api_call('namecheap.ssl.renew', args)
40
+ end
41
+
42
+ def resend_approver_email(id, options = {})
43
+ args = options.clone
44
+ args['CertificateID'] = id
45
+ api_call('namecheap.ssl.resendApproverEmail', args)
46
+ end
47
+
48
+ def resend_fulfillment_email(id, options = {})
49
+ args = options.clone
50
+ args['CertificateID'] = id
51
+ api_call('namecheap.ssl.resendfulfillmentemail', args)
52
+ end
53
+
54
+ def reissue(id, options = {})
55
+ args = options.clone
56
+ args['CertificateID'] = id
57
+ api_call('namecheap.ssl.reissue', args)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,26 @@
1
+ module Namecheap
2
+ class Transfers < Api
3
+ def create(domain, options = {})
4
+ args = options.clone
5
+ args['DomainName'] = domain
6
+ api_call('namecheap.domains.transfer.create', args)
7
+ end
8
+
9
+ def get_status(id, options = {})
10
+ args = options.clone
11
+ args['TransferID'] = id
12
+ api_call('namecheap.domains.transfer.getStatus', args)
13
+ end
14
+
15
+ def update_status(id, options = {})
16
+ args = options.clone
17
+ args['TransferID'] = id
18
+ api_call('namecheap.domains.transfer.updateStatus', args)
19
+ end
20
+
21
+ def get_list(options = {})
22
+ args = options.clone
23
+ api_call('namecheap.domains.transfer.getList', args)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ module Namecheap
2
+ class Users < Api
3
+ def get_pricing(options = {})
4
+ args = options.clone
5
+ api_call('namecheap.users.getPricing', args)
6
+ end
7
+
8
+ def get_balances(options = {})
9
+ args = options.clone
10
+ api_call('namecheap.users.getBalances', args)
11
+ end
12
+
13
+ def change_password(options = {})
14
+ args = options.clone
15
+ api_call('namecheap.users.changePassword', args)
16
+ end
17
+
18
+ def update(options = {})
19
+ args = options.clone
20
+ api_call('namecheap.users.update', args)
21
+ end
22
+
23
+ def create_add_funds_request(options = {})
24
+ args = options.clone
25
+ api_call('namecheap.users.createaddfundsrequest', args)
26
+ end
27
+
28
+ def get_add_funds_status(id, options = {})
29
+ args = options.clone
30
+ args['TokenId'] = id
31
+ api_call('namecheap.users.getAddFundsStatus', args)
32
+ end
33
+
34
+ def login(options = {})
35
+ args = options.clone
36
+ api_call('namecheap.users.login', args)
37
+ end
38
+
39
+ def reset_password(options = {})
40
+ args = options.clone
41
+ api_call('namecheap.users.resetPassword', args)
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Namecheap
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,40 @@
1
+ module Namecheap
2
+ class Whois_Guard < Api
3
+ def allot(id, domain, options = {})
4
+ args = options.clone
5
+ args['WhoisguardId'] = id
6
+ args['DomainName'] = domain
7
+ api_call('namecheap.whoisguard.allot', args)
8
+ end
9
+
10
+ def discard(id, options = {})
11
+ args = options.clone
12
+ args['WhoisguardId'] = id
13
+ api_call('namecheap.whoisguard.discard', args)
14
+ end
15
+
16
+ def unallot(id, options = {})
17
+ args = options.clone
18
+ args['WhoisguardId'] = id
19
+ api_call('namecheap.whoisguard.unallot', args)
20
+ end
21
+
22
+ def disable(id, options = {})
23
+ args = options.clone
24
+ args['WhoisguardId'] = id
25
+ api_call('namecheap.whoisguard.disable', args)
26
+ end
27
+
28
+ def enable(id, options = {})
29
+ args = options.clone
30
+ args['WhoisguardId'] = id
31
+ api_call('namecheap.whoisguard.enable', args)
32
+ end
33
+
34
+ def change_email_address(id, options = {})
35
+ args = options.clone
36
+ args['WhoisguardId'] = id
37
+ api_call('namecheap.whoisguard.changeemailaddress', args)
38
+ end
39
+ end
40
+ end
@@ -8,4 +8,3 @@ end
8
8
 
9
9
  require File.dirname(__FILE__) + '/../lib/namecheap'
10
10
  $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib/namecheap")
11
- require 'namecheap/domains'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namecheap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - parasquid
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-15 00:00:00 Z
18
+ date: 2013-06-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -65,8 +65,14 @@ files:
65
65
  - lib/namecheap.rb
66
66
  - lib/namecheap/api.rb
67
67
  - lib/namecheap/config.rb
68
+ - lib/namecheap/dns.rb
68
69
  - lib/namecheap/domains.rb
70
+ - lib/namecheap/ns.rb
71
+ - lib/namecheap/ssl.rb
72
+ - lib/namecheap/transfers.rb
73
+ - lib/namecheap/users.rb
69
74
  - lib/namecheap/version.rb
75
+ - lib/namecheap/whois_guard.rb
70
76
  - namecheap.gemspec
71
77
  - spec/domains_spec.rb
72
78
  - spec/namecheap_spec.rb
@@ -100,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
106
  requirements: []
101
107
 
102
108
  rubyforge_project: namecheap
103
- rubygems_version: 1.8.10
109
+ rubygems_version: 1.8.25
104
110
  signing_key:
105
111
  specification_version: 3
106
112
  summary: Ruby wrapper for the Namecheap API