enom 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 James Miller
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ = Enom
2
+
3
+ A ruby wrapper for the Enom Domain Registrar's API for checking domain name
4
+ availability, domain contact information, name server settings, etc.
5
+
6
+ = Copyright
7
+
8
+ Copyright (c) 2010 James Miller
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the enom_api plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
@@ -0,0 +1,9 @@
1
+ require 'rest_client'
2
+ require 'crack/xml'
3
+ require File.expand_path(File.dirname(__FILE__) + '/enom/client')
4
+ require File.expand_path(File.dirname(__FILE__) + '/enom/domain')
5
+
6
+ module Enom
7
+ class InterfaceError < StandardError; end
8
+ class InvalidNameServerCount < StandardError; end
9
+ end
@@ -0,0 +1,44 @@
1
+ require 'cgi'
2
+ module Enom
3
+
4
+ class Client
5
+
6
+ def initialize(username, password, ssl = true, test = false)
7
+ @@username = username
8
+ @@password = password
9
+ @@protocol = ssl == true ? "https" : "http"
10
+ @@endpoint = test == true ? "resellertest.enom.com" : "reseller.enom.com"
11
+ end
12
+
13
+ def find_domain(name)
14
+ sld, tld = name.split('.')
15
+ payload = get('Command' => 'GetDomainInfo', 'SLD' => sld, 'TLD' => tld)
16
+ Domain.new(payload)
17
+ end
18
+
19
+ def get_balance
20
+ get('Command' => 'GetBalance')
21
+ end
22
+
23
+ private
24
+
25
+ def get(params = {})
26
+ params.merge!(default_params)
27
+ payload = Crack::XML.parse(RestClient.get(url, {:params => params }))
28
+ if payload['interface_response']['ErrCount'] == '0'
29
+ return payload
30
+ else
31
+ raise InterfaceError
32
+ end
33
+ end
34
+
35
+ def url
36
+ @@protocol + "://" + @@endpoint + "/interface.asp"
37
+ end
38
+
39
+ def default_params
40
+ { 'UID' => @@username, 'PW' => @@password, 'ResponseType' => 'xml'}
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,58 @@
1
+ module Enom
2
+ class Domain < Client
3
+
4
+ attr_reader :name, :sld, :tld
5
+
6
+ def initialize(payload)
7
+ @name = payload['interface_response']['GetDomainInfo']['domainname']
8
+ @sld, @tld = @name.split('.')
9
+ @domain_payload = payload
10
+ end
11
+
12
+ def lock
13
+ get('Command' => 'SetRegLock', 'SLD' => sld, 'TLD' => tld, 'UnlockRegistrar' => '0')
14
+ end
15
+
16
+ def unlock
17
+ get('Command' => 'SetRegLock', 'SLD' => sld, 'TLD' => tld, 'UnlockRegistrar' => '1')
18
+ end
19
+
20
+ def locked?
21
+ payload = get('Command' => 'GetRegLock', 'SLD' => sld, 'TLD' => tld)
22
+ payload['interface_response']['reg_lock'] == '1' ? true : false
23
+ end
24
+
25
+ def nameservers
26
+ @domain_payload['interface_response']['GetDomainInfo']['services']['entry'].first['configuration']['dns']
27
+ end
28
+
29
+ def update_nameservers(nameservers)
30
+ count = 1
31
+ ns = {}
32
+ if (2..12).include?(nameservers.size)
33
+ nameservers.each do |nameserver|
34
+ ns.merge!("NS#{count}" => nameserver)
35
+ count += 1
36
+ end
37
+ get({'Command' => 'ModifyNS', 'SLD' => sld, 'TLD' => tld}.merge(ns))
38
+ else
39
+ raise InvalidNameServerCount, "A minimum of 2 and maximum of 12 nameservers are required"
40
+ end
41
+ end
42
+
43
+ def expiration_date
44
+ @domain_payload['interface_response']['GetDomainInfo']['status']['expiration']
45
+ end
46
+
47
+ def expired?
48
+ end
49
+
50
+ def registration_status
51
+ @domain_payload['interface_response']['GetDomainInfo']['status']['registrationstatus']
52
+ end
53
+
54
+ def renew
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class EnomTest < ActiveSupport::TestCase
4
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enom
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - James Miller
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-13 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rest-client
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 6
33
+ - 0
34
+ version: 1.6.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: crack
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 9
46
+ segments:
47
+ - 0
48
+ - 1
49
+ version: "0.1"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: shoulda
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: Enom is a simple Ruby wrapper for a small portion of the Enom domain reseller API.
67
+ email: bensie@gmail.com
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - README.rdoc
76
+ - Rakefile
77
+ - LICENSE
78
+ - lib/enom.rb
79
+ - lib/enom/client.rb
80
+ - lib/enom/domain.rb
81
+ - test/enom_test.rb
82
+ - test/test_helper.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/bensie/enom
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.3.7
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Ruby wrapper for the Enom API
117
+ test_files: []
118
+