moo_moo 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -3
- data/LICENSE +1 -1
- data/README.md +16 -5
- data/Rakefile +21 -0
- data/lib/moo_moo/base.rb +93 -0
- data/lib/moo_moo/command.rb +36 -0
- data/lib/moo_moo/config.rb +26 -1
- data/lib/moo_moo/cookie.rb +28 -0
- data/lib/moo_moo/dns_zone.rb +45 -0
- data/lib/moo_moo/exceptions.rb +1 -1
- data/lib/moo_moo/lookup.rb +97 -0
- data/lib/moo_moo/middleware/open_srs_errors.rb +12 -0
- data/lib/moo_moo/middleware/open_srs_xml_builder.rb +101 -0
- data/lib/moo_moo/middleware/parse_open_srs.rb +58 -0
- data/lib/moo_moo/nameserver.rb +29 -0
- data/lib/moo_moo/provisioning.rb +62 -0
- data/lib/moo_moo/response.rb +39 -0
- data/lib/moo_moo/transfer.rb +60 -0
- data/lib/moo_moo/version.rb +1 -1
- data/lib/moo_moo.rb +18 -3
- data/moo_moo.gemspec +7 -5
- data/spec/fixtures/success_response.xml +14 -0
- data/spec/integration_spec.rb +15 -0
- data/spec/moo_moo/base_spec.rb +77 -0
- data/spec/moo_moo/command_spec.rb +42 -0
- data/spec/moo_moo/config_spec.rb +38 -0
- data/spec/moo_moo/cookie_spec.rb +8 -0
- data/spec/moo_moo/dns_zone_spec.rb +11 -0
- data/spec/moo_moo/lookup_spec.rb +18 -0
- data/spec/moo_moo/middleware/open_srs_xml_builder_spec.rb +53 -0
- data/spec/moo_moo/nameserver_spec.rb +8 -0
- data/spec/moo_moo/provisioning_spec.rb +14 -0
- data/spec/moo_moo/transfer_spec.rb +12 -0
- data/spec/moo_moo_spec.rb +1 -1
- data/spec/spec_helper.rb +35 -23
- data/spec/vcr_cassettes/integration/lookup.yml +44 -0
- metadata +117 -153
- data/lib/cacert.pem +0 -3910
- data/lib/moo_moo/opensrs/args.rb +0 -109
- data/lib/moo_moo/opensrs/base.rb +0 -73
- data/lib/moo_moo/opensrs/command.rb +0 -190
- data/lib/moo_moo/opensrs/cookie_commands.rb +0 -52
- data/lib/moo_moo/opensrs/lookup_commands.rb +0 -195
- data/lib/moo_moo/opensrs/nameserver_commands.rb +0 -70
- data/lib/moo_moo/opensrs/provisioning_commands.rb +0 -167
- data/lib/moo_moo/opensrs/response.rb +0 -41
- data/lib/moo_moo/opensrs/transfer_commands.rb +0 -83
- data/lib/moo_moo/opensrs.rb +0 -13
- data/spec/moo_moo/opensrs/args_spec.rb +0 -176
- data/spec/moo_moo/opensrs/base_spec.rb +0 -22
- data/spec/moo_moo/opensrs/cookie_spec.rb +0 -76
- data/spec/moo_moo/opensrs/lookup_spec.rb +0 -208
- data/spec/moo_moo/opensrs/nameserver_spec.rb +0 -136
- data/spec/moo_moo/opensrs/provisioning_spec.rb +0 -198
- data/spec/moo_moo/opensrs/transfer_spec.rb +0 -124
- data/spec/vcr_cassettes/cookie/delete_cookie.yml +0 -219
- data/spec/vcr_cassettes/cookie/quit_session.yml +0 -97
- data/spec/vcr_cassettes/cookie/set_cookie.yml +0 -123
- data/spec/vcr_cassettes/cookie/set_cookie_fail.yml +0 -54
- data/spec/vcr_cassettes/cookie/update_cookie.yml +0 -239
- data/spec/vcr_cassettes/lookup/belongs_to_rsp.yml +0 -54
- data/spec/vcr_cassettes/lookup/belongs_to_rsp_negative.yml +0 -55
- data/spec/vcr_cassettes/lookup/get_balance.yml +0 -55
- data/spec/vcr_cassettes/lookup/get_deleted_domains.yml +0 -80
- data/spec/vcr_cassettes/lookup/get_domain.yml +0 -211
- data/spec/vcr_cassettes/lookup/get_domain_fail.yml +0 -269
- data/spec/vcr_cassettes/lookup/get_domains_by_expiredate.yml +0 -76
- data/spec/vcr_cassettes/lookup/get_domains_contacts.yml +0 -129
- data/spec/vcr_cassettes/lookup/get_domains_contacts_fail.yml +0 -58
- data/spec/vcr_cassettes/lookup/get_notes_for_domain.yml +0 -85
- data/spec/vcr_cassettes/lookup/get_notes_for_order.yml +0 -61
- data/spec/vcr_cassettes/lookup/get_notes_for_transfer.yml +0 -61
- data/spec/vcr_cassettes/lookup/get_order_info.yml +0 -139
- data/spec/vcr_cassettes/lookup/get_orders_by_domain.yml +0 -76
- data/spec/vcr_cassettes/lookup/get_price.yml +0 -54
- data/spec/vcr_cassettes/lookup/get_product_info.yml +0 -49
- data/spec/vcr_cassettes/lookup/lookup_domain_available.yml +0 -55
- data/spec/vcr_cassettes/lookup/lookup_domain_registered.yml +0 -55
- data/spec/vcr_cassettes/lookup/name_suggest.yml +0 -396
- data/spec/vcr_cassettes/nameserver/create.yml +0 -49
- data/spec/vcr_cassettes/nameserver/delete.yml +0 -49
- data/spec/vcr_cassettes/nameserver/get.yml +0 -71
- data/spec/vcr_cassettes/nameserver/modify.yml +0 -49
- data/spec/vcr_cassettes/provisioning/cancel_order.yml +0 -56
- data/spec/vcr_cassettes/provisioning/cancel_order_invalid.yml +0 -49
- data/spec/vcr_cassettes/provisioning/cancel_pending_orders.yml +0 -58
- data/spec/vcr_cassettes/provisioning/modify_all_domains.yml +0 -49
- data/spec/vcr_cassettes/provisioning/modify_domain.yml +0 -49
- data/spec/vcr_cassettes/provisioning/process_pending.yml +0 -57
- data/spec/vcr_cassettes/provisioning/register_domain.yml +0 -57
- data/spec/vcr_cassettes/provisioning/register_pending_domain.yml +0 -55
- data/spec/vcr_cassettes/provisioning/register_taken_domain.yml +0 -55
- data/spec/vcr_cassettes/provisioning/renew_domain.yml +0 -58
- data/spec/vcr_cassettes/provisioning/revoke_domain.yml +0 -55
- data/spec/vcr_cassettes/provisioning/trust_service.yml +0 -60
- data/spec/vcr_cassettes/provisioning/update_contacts.yml +0 -66
- data/spec/vcr_cassettes/transfer/cancel_transfer.yml +0 -49
- data/spec/vcr_cassettes/transfer/cancel_trasnfer_order.yml +0 -49
- data/spec/vcr_cassettes/transfer/check_transfer.yml +0 -56
- data/spec/vcr_cassettes/transfer/check_transfer_exists.yml +0 -57
- data/spec/vcr_cassettes/transfer/get_transfers_away.yml +0 -60
- data/spec/vcr_cassettes/transfer/get_transfers_in.yml +0 -80
- data/spec/vcr_cassettes/transfer/process_transfer.yml +0 -49
- data/spec/vcr_cassettes/transfer/process_transfer_unsuccessful.yml +0 -49
- data/spec/vcr_cassettes/transfer/rsp2rsp_push_transfer.yml +0 -49
- data/spec/vcr_cassettes/transfer/send_password.yml +0 -49
- data/spec/vcr_cassettes/transfer/transfer.yml +0 -58
data/lib/moo_moo/opensrs/args.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
module MooMoo
|
2
|
-
module OpenSRS
|
3
|
-
class Args
|
4
|
-
attr_reader :required_params, :boolean_params, :optional_params, :one_of_params
|
5
|
-
attr_reader :options
|
6
|
-
# Check the included hash for the included parameters.
|
7
|
-
# Raises MooMooArgumentError when it's mising the proper params
|
8
|
-
#
|
9
|
-
# ==== Example
|
10
|
-
#
|
11
|
-
# Args.new(options) do |c|
|
12
|
-
# c.requries :user, :pass
|
13
|
-
# c.booleans :name
|
14
|
-
# c.optionals :whatever
|
15
|
-
# end
|
16
|
-
def initialize(options)
|
17
|
-
@required_params ||= []
|
18
|
-
@boolean_params ||= []
|
19
|
-
@optional_params ||= []
|
20
|
-
@one_of_params ||= []
|
21
|
-
@options = options
|
22
|
-
|
23
|
-
yield self
|
24
|
-
|
25
|
-
requires!
|
26
|
-
booleans!
|
27
|
-
one_ofs!
|
28
|
-
valid_options!
|
29
|
-
end
|
30
|
-
|
31
|
-
# Specifies the required arguments
|
32
|
-
def requires(*values)
|
33
|
-
@optional_params.concat(values)
|
34
|
-
@required_params = values
|
35
|
-
end
|
36
|
-
|
37
|
-
# Specifies which arguments are boolean
|
38
|
-
def booleans(*values)
|
39
|
-
@optional_params.concat(values)
|
40
|
-
@boolean_params = values
|
41
|
-
end
|
42
|
-
|
43
|
-
# Specifies which arguments are optional
|
44
|
-
def optionals(*values)
|
45
|
-
@optional_params.concat(values)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Specifies which arguments take one of a set of arguments
|
49
|
-
def one_of(*values)
|
50
|
-
@optional_params.concat(values)
|
51
|
-
@one_of_params = values
|
52
|
-
end
|
53
|
-
|
54
|
-
protected
|
55
|
-
|
56
|
-
# Verifies that all required arguments are present
|
57
|
-
def requires!
|
58
|
-
@required_params.each do |param|
|
59
|
-
key = (param.is_a?(Array) ? param.first : param)
|
60
|
-
verify_required_param(key)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# Checks to see if supplied params (which are booleans) contain
|
66
|
-
# either a 1 ("Yes") or 0 ("No") value.
|
67
|
-
def booleans!
|
68
|
-
@boolean_params.each do |param|
|
69
|
-
key = (param.is_a?(Array) ? param.first : param)
|
70
|
-
verify_boolean_param(key)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Verifies that only valid arguments were set
|
75
|
-
def valid_options!
|
76
|
-
@options.keys.uniq.each do |key|
|
77
|
-
raise MooMoo::MooMooArgumentError.new("Not a valid parameter: #{key}") unless @optional_params.include?(key)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# Verifies that the one_of arguments were used correctly
|
82
|
-
def one_ofs!
|
83
|
-
if @one_of_params.size > 1
|
84
|
-
specified = @options.keys.select { |key| @one_of_params.include?(key) }.uniq
|
85
|
-
if specified.size > 1 || specified.size == 0
|
86
|
-
raise MooMoo::MooMooArgumentError.new("The parameters may include only one of '#{@one_of_params.join(', ')}'")
|
87
|
-
end
|
88
|
-
else
|
89
|
-
raise MooMoo::MooMooArgumentError.new("One of requires two or more items") unless @one_of_params.empty?
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
|
95
|
-
# Internal method for verifiying required arguments
|
96
|
-
def verify_required_param(param)
|
97
|
-
raise MooMoo::MooMooArgumentError.new("Missing required parameter: #{param}") unless @options.has_key?(param)
|
98
|
-
raise MooMoo::MooMooArgumentError.new("Required parameter cannot be blank: #{param}") if (@options[param].nil? || (@options[param].respond_to?(:empty?) && @options[param].empty?))
|
99
|
-
end
|
100
|
-
|
101
|
-
# Internal method for verifying boolean arguments
|
102
|
-
def verify_boolean_param(param)
|
103
|
-
if @options.include?(param) && ![true, false].include?(@options[param])
|
104
|
-
raise MooMoo::MooMooArgumentError.new("Boolean parameter must be \"true\" or \"false\": #{param}")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
data/lib/moo_moo/opensrs/base.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
module MooMoo
|
2
|
-
module OpenSRS
|
3
|
-
class Base
|
4
|
-
include LookupCommands
|
5
|
-
include ProvisioningCommands
|
6
|
-
include TransferCommands
|
7
|
-
include NameserverCommands
|
8
|
-
include CookieCommands
|
9
|
-
|
10
|
-
attr_reader :host, :key, :user, :pass, :port
|
11
|
-
|
12
|
-
# Constructor
|
13
|
-
#
|
14
|
-
# === Required
|
15
|
-
# * <tt>:host</tt> - host of the OpenSRS server
|
16
|
-
# * <tt>:key</tt> - private key
|
17
|
-
# * <tt>:user</tt> - username of the reseller
|
18
|
-
# * <tt>:pass</tt> - password of the rseller
|
19
|
-
#
|
20
|
-
# === Optional
|
21
|
-
# * <tt>:port</tt> - port to connect on
|
22
|
-
def initialize(host = nil, key = nil, user = nil, pass = nil, port = 55443)
|
23
|
-
@host = host || MooMoo.config.host
|
24
|
-
@key = key || MooMoo.config.key
|
25
|
-
@user = user || MooMoo.config.user
|
26
|
-
@pass = pass || MooMoo.config.pass
|
27
|
-
@port = port || MooMoo.config.port
|
28
|
-
end
|
29
|
-
|
30
|
-
# Runs a command
|
31
|
-
#
|
32
|
-
# === Required
|
33
|
-
# * <tt>:command</tt> - command to run
|
34
|
-
# * <tt>:command</tt> - command to run
|
35
|
-
#
|
36
|
-
# === Optional
|
37
|
-
# * <tt>:params</tt> - parameters for the command
|
38
|
-
# * <tt>:cookie</tt> - cookie, if the command requires it
|
39
|
-
def run_command(action, object, params = {}, cookie = nil)
|
40
|
-
cmd = Command.new(action, object, params, cookie)
|
41
|
-
|
42
|
-
try_opensrs do
|
43
|
-
result = cmd.run(@host, @key, @user, @port)
|
44
|
-
Response.new(result, params[:key])
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
# Indexes an array by building a hash with numeric keys
|
51
|
-
#
|
52
|
-
# === Required
|
53
|
-
# * <tt>:arr</tt> - array to build an indexed hash of
|
54
|
-
def index_array(arr)
|
55
|
-
arr_indexed = {}
|
56
|
-
|
57
|
-
arr.each_with_index do |item, index|
|
58
|
-
arr_indexed[index] = item
|
59
|
-
end
|
60
|
-
|
61
|
-
arr_indexed
|
62
|
-
end
|
63
|
-
|
64
|
-
def try_opensrs
|
65
|
-
begin
|
66
|
-
yield
|
67
|
-
rescue Exception => e
|
68
|
-
raise OpenSRSException, e.message
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require 'digest/md5'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
module MooMoo
|
6
|
-
module OpenSRS
|
7
|
-
class Command
|
8
|
-
# Constructor
|
9
|
-
#
|
10
|
-
# ==== Required
|
11
|
-
# * <tt>:action</tt> - action of the command
|
12
|
-
# * <tt>:object</tt> - object the command operates on
|
13
|
-
# * <tt>:params</tt> - additional parameters for the command
|
14
|
-
#
|
15
|
-
# ==== Optional
|
16
|
-
# * <tt>:cookie</tt> - a cookie for the domain if the command requires it
|
17
|
-
def initialize(action, object, params = {}, cookie = nil)
|
18
|
-
@action = action
|
19
|
-
@object = object
|
20
|
-
@params = params
|
21
|
-
@cookie = cookie
|
22
|
-
end
|
23
|
-
|
24
|
-
# Runs the command against OpenSRS server
|
25
|
-
#
|
26
|
-
# ==== Required
|
27
|
-
# * <tt>:host</tt> - host of the OpenSRS server
|
28
|
-
# * <tt>:key</tt> - private key for the account
|
29
|
-
# * <tt>:user</tt> - username for the account
|
30
|
-
# * <tt>:port</tt> - port to connect to
|
31
|
-
def run(host, key, user, port)
|
32
|
-
xml = build_command(@action, @object, @params, @cookie)
|
33
|
-
|
34
|
-
md5_signature = Digest::MD5.hexdigest(
|
35
|
-
Digest::MD5.hexdigest(
|
36
|
-
xml + key
|
37
|
-
) + key
|
38
|
-
)
|
39
|
-
|
40
|
-
headers = {
|
41
|
-
'Content-Type' => 'text/xml',
|
42
|
-
'X-Username' => user,
|
43
|
-
'X-Signature' => md5_signature,
|
44
|
-
'Content-Length' => xml.size.to_s
|
45
|
-
}
|
46
|
-
|
47
|
-
http = Net::HTTP.new(URI.encode(host), port)
|
48
|
-
http.use_ssl = true
|
49
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
50
|
-
#http.ca_file = File.join(File.dirname(__FILE__), "../..", "cacert.pem")
|
51
|
-
res = http.post(URI.encode("/"), xml, headers)
|
52
|
-
|
53
|
-
@returned_parameters = parse_response(res.body)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
# Adds XML child elements to the specified XML element for a given collection
|
59
|
-
#
|
60
|
-
# ==== Required
|
61
|
-
# * <tt>:elem</tt> - XML element to add the child nodes to
|
62
|
-
# * <tt>:coll</tt> - collection that will be added as XML child elements
|
63
|
-
def xml_add_collection_as_child(elem, coll)
|
64
|
-
# default collection type is array
|
65
|
-
dt_type = 'dt_array'
|
66
|
-
|
67
|
-
# if it's a hash, make sure the keys aren't numeric
|
68
|
-
if coll.is_a?(Hash)
|
69
|
-
begin
|
70
|
-
Float(coll.keys.first)
|
71
|
-
rescue
|
72
|
-
# the keys weren't numeric, so it really is an association (hash)
|
73
|
-
dt_type = 'dt_assoc'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
elem = elem.add_element(dt_type)
|
78
|
-
coll = coll.first if coll.is_a? Array
|
79
|
-
|
80
|
-
coll.each do |key, value|
|
81
|
-
child = elem.add_element('item', {'key' => key})
|
82
|
-
if value.is_a?(Hash) || value.is_a?(Array)
|
83
|
-
xml_add_collection_as_child(child, value)
|
84
|
-
else
|
85
|
-
child.text = value
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Builds an XML string of the command which can be sent to OpenSRS
|
91
|
-
#
|
92
|
-
# ==== Required
|
93
|
-
# * <tt>:action</tt> - action of the command
|
94
|
-
# * <tt>:object</tt> - object the command operates on
|
95
|
-
#
|
96
|
-
# ==== Optional
|
97
|
-
# * <tt>:attributes</tt> - additional attributes for the command
|
98
|
-
# * <tt>:cookie</tt> - cookie for the domain if the command requires it
|
99
|
-
def build_command(action, object, attributes = nil, cookie = nil)
|
100
|
-
xml = <<-XML
|
101
|
-
|
102
|
-
<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
|
103
|
-
<!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>
|
104
|
-
<OPS_envelope>
|
105
|
-
<header>
|
106
|
-
<version>0.9</version>
|
107
|
-
</header>
|
108
|
-
<body>
|
109
|
-
<data_block>
|
110
|
-
<dt_assoc>
|
111
|
-
<item key="protocol">XCP</item>
|
112
|
-
<item key="action">GET_BALANCE</item>
|
113
|
-
<item key="object">BALANCE</item>
|
114
|
-
<item key="registrant_ip"/>
|
115
|
-
</dt_assoc>
|
116
|
-
</data_block>
|
117
|
-
</body>
|
118
|
-
</OPS_envelope>
|
119
|
-
XML
|
120
|
-
|
121
|
-
doc = REXML::Document.new(xml)
|
122
|
-
doc.root.elements["body/data_block/dt_assoc/item[@key='action']"].text = action
|
123
|
-
doc.root.elements["body/data_block/dt_assoc/item[@key='object']"].text = object
|
124
|
-
|
125
|
-
unless cookie.nil?
|
126
|
-
cookie_elem = doc.root.elements["body/data_block/dt_assoc"].add_element('item', {'key' => 'cookie'})
|
127
|
-
cookie_elem.text = cookie
|
128
|
-
end
|
129
|
-
|
130
|
-
unless attributes.nil?
|
131
|
-
elem = doc.root.elements["body/data_block/dt_assoc"].add_element('item', {'key' => 'attributes'})
|
132
|
-
elem = elem.add_element('dt_assoc')
|
133
|
-
attributes.each_pair do |key, value|
|
134
|
-
attrib_elem = elem.add_element('item', {'key' => key})
|
135
|
-
if value.is_a?(Hash) || value.is_a?(Array)
|
136
|
-
xml_add_collection_as_child(attrib_elem, value)
|
137
|
-
else
|
138
|
-
attrib_elem.text = (value.is_a?(String) ? value.dup : value)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
doc.to_s
|
144
|
-
end
|
145
|
-
|
146
|
-
# Parses an XML response from the OpenSRS registry and generates a
|
147
|
-
# hash containing all of the data. Elements with child elements
|
148
|
-
# are converted into hashes themselves, with the :element_text entry
|
149
|
-
# containing any raw text
|
150
|
-
#
|
151
|
-
# ==== Required
|
152
|
-
# * <tt>data</tt> - data of the response
|
153
|
-
def parse_response(data)
|
154
|
-
doc = REXML::Document.new(data)
|
155
|
-
|
156
|
-
values = {}
|
157
|
-
|
158
|
-
elements = doc.elements["/OPS_envelope/body/data_block/dt_assoc"].select { |item|
|
159
|
-
item.is_a? REXML::Element
|
160
|
-
}
|
161
|
-
|
162
|
-
build_xml_hash(elements)
|
163
|
-
end
|
164
|
-
|
165
|
-
# Builds a hash from a collection of XML elements
|
166
|
-
#
|
167
|
-
# ==== Required
|
168
|
-
# * <tt>elements</tt> - collection of elemenents
|
169
|
-
def build_xml_hash(elements)
|
170
|
-
data_hash = {}
|
171
|
-
|
172
|
-
elements.each do |elem|
|
173
|
-
key = elem.attributes['key']
|
174
|
-
|
175
|
-
if elem.elements.size > 0
|
176
|
-
if key.nil?
|
177
|
-
data_hash.merge!(build_xml_hash(elem.elements))
|
178
|
-
else
|
179
|
-
data_hash[key] = build_xml_hash(elem.elements)
|
180
|
-
end
|
181
|
-
else
|
182
|
-
data_hash[key] = elem.text unless key.nil?
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
data_hash
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module MooMoo
|
2
|
-
module OpenSRS
|
3
|
-
module CookieCommands
|
4
|
-
# Creates a cookie for a domain
|
5
|
-
#
|
6
|
-
# ==== Required
|
7
|
-
# * <tt>:username</tt> - username of the registrant
|
8
|
-
# * <tt>:password</tt> - password of the registrant
|
9
|
-
# * <tt>:domain</tt> - domain to set the cookie for
|
10
|
-
def set_cookie(params)
|
11
|
-
run_command :set, :cookie, {
|
12
|
-
:reg_username => params[:username],
|
13
|
-
:reg_password => params[:password],
|
14
|
-
:domain => params[:domain],
|
15
|
-
:key => 'attributes'
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
# Deletes a cookie that was previously set
|
20
|
-
#
|
21
|
-
# ==== Required
|
22
|
-
# * <tt>:cookie</tt> - cookie to delete
|
23
|
-
def delete_cookie(cookie)
|
24
|
-
run_command :delete, :cookie, {
|
25
|
-
:cookie => cookie
|
26
|
-
}, cookie
|
27
|
-
end
|
28
|
-
|
29
|
-
# Updates a cookie to be valid for a different domain
|
30
|
-
#
|
31
|
-
# ==== Required
|
32
|
-
# * <tt>:old_domain</tt> - domain the cookie is currently set for
|
33
|
-
# * <tt>:new_domain</tt> - domain to set the cookie for
|
34
|
-
# * <tt>:cookie</tt> - cookie to update
|
35
|
-
def update_cookie(attribs)
|
36
|
-
run_command :update, :cookie, {
|
37
|
-
:reg_username => MooMoo.config.user,
|
38
|
-
:reg_password => '',
|
39
|
-
:domain => attribs[:old_domain],
|
40
|
-
:domain_new => attribs[:new_domain],
|
41
|
-
:key => 'attributes'
|
42
|
-
}, attribs[:cookie]
|
43
|
-
end
|
44
|
-
|
45
|
-
# Cleanly terminates the connection
|
46
|
-
#
|
47
|
-
def quit_session
|
48
|
-
run_command :quit, :session
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,195 +0,0 @@
|
|
1
|
-
module MooMoo
|
2
|
-
module OpenSRS
|
3
|
-
module LookupCommands
|
4
|
-
# Determines whether a domain belongs to the reseller
|
5
|
-
#
|
6
|
-
# ==== Required
|
7
|
-
# * <tt>:domain</tt> - domain to check ownership of
|
8
|
-
def belongs_to_rsp?(domain)
|
9
|
-
run_command :belongs_to_rsp, :domain, {
|
10
|
-
:domain => domain,
|
11
|
-
:key => 'attributes'
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns the balance of the reseller's account
|
16
|
-
#
|
17
|
-
def get_balance
|
18
|
-
run_command :get_balance, :balance, {
|
19
|
-
:key => 'attributes'
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
# Lists domains that have been deleted due to expiration or request
|
24
|
-
#
|
25
|
-
def get_deleted_domains
|
26
|
-
run_command :get_deleted_domains, :domain, {
|
27
|
-
:key => 'attributes'
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
# Queries various types of data associated with a domain
|
32
|
-
#
|
33
|
-
# ==== Required
|
34
|
-
# * <tt>:domain</tt> - domain to query
|
35
|
-
# * <tt>:cookie</tt> - cookie for the domain
|
36
|
-
#
|
37
|
-
# ==== Optional
|
38
|
-
# * <tt>:type</tt> - type of query to perform
|
39
|
-
def get_domain(params)
|
40
|
-
params[:type] = 'all_info' unless params[:type]
|
41
|
-
|
42
|
-
run_command :get, :domain, {
|
43
|
-
:type => params[:type],
|
44
|
-
:key => 'attributes'
|
45
|
-
}, params[:cookie]
|
46
|
-
end
|
47
|
-
|
48
|
-
# Queries contact information for a list of domains
|
49
|
-
#
|
50
|
-
# ==== Required
|
51
|
-
# * <tt>:domains</tt> - domains to get contact information for
|
52
|
-
def get_domains_contacts(*domains)
|
53
|
-
domain_list = {}
|
54
|
-
domains.each_with_index do |domain, index|
|
55
|
-
domain_list[index] = domain
|
56
|
-
end
|
57
|
-
|
58
|
-
run_command :get_domains_contacts, :domain, {
|
59
|
-
:domain_list => domain_list,
|
60
|
-
:key => 'attributes'
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
# Queries the domains expiring within the specified date range
|
65
|
-
#
|
66
|
-
# ==== Required
|
67
|
-
# * <tt>:start_date</tt> - beginning date of the expiration range
|
68
|
-
# * <tt>:end_date</tt> - ending date of the expiration range
|
69
|
-
def get_domains_by_expiredate(attribs)
|
70
|
-
Args.new(attribs) do |c|
|
71
|
-
c.requires :start_date, :end_date
|
72
|
-
end
|
73
|
-
|
74
|
-
run_command :get_domains_by_expiredate, :domain, {
|
75
|
-
:exp_from => attribs[:start_date].to_s,
|
76
|
-
:exp_to => attribs[:end_date].to_s,
|
77
|
-
:key => 'attributes'
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
# Retrieves the domain notes that detail the history of the domain (renewals, transfers, etc.)
|
82
|
-
#
|
83
|
-
# ==== Required
|
84
|
-
# * <tt>:domain</tt> - domain to get the notes for
|
85
|
-
def get_notes_for_domain(domain)
|
86
|
-
run_command :get_notes, :domain, {
|
87
|
-
:domain => domain,
|
88
|
-
:type => 'domain',
|
89
|
-
:key => 'attributes'
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
# Retrieves the domain notes based on an order
|
94
|
-
#
|
95
|
-
# ==== Required
|
96
|
-
# * <tt>:domain</tt> - domain to get the notes for
|
97
|
-
# * <tt>:order_id</tt> - ID of the order
|
98
|
-
def get_notes_for_order(params)
|
99
|
-
run_command :get_notes, :domain, {
|
100
|
-
:domain => params[:domain],
|
101
|
-
:order_id => params[:order_id],
|
102
|
-
:type => 'order',
|
103
|
-
:key => 'attributes'
|
104
|
-
}
|
105
|
-
end
|
106
|
-
|
107
|
-
# Retrieves the domain notes based on a transfer ID
|
108
|
-
#
|
109
|
-
# ==== Required
|
110
|
-
# * <tt>:domain</tt> - domain to get the notes for
|
111
|
-
# * <tt>:transfer_id</tt> - ID of the transfer
|
112
|
-
def get_notes_for_transfer(params)
|
113
|
-
run_command :get_notes, :domain, {
|
114
|
-
:domain => params[:domain],
|
115
|
-
:transfer_id => params[:transfer_id],
|
116
|
-
:type => 'transfer',
|
117
|
-
:key => 'attributes'
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
# Queries all information related to an order
|
122
|
-
#
|
123
|
-
# ==== Required
|
124
|
-
# * <tt>:order_id</tt> - ID of the order
|
125
|
-
def get_order_info(order_id)
|
126
|
-
run_command :get_order_info, :domain, {
|
127
|
-
:order_id => order_id,
|
128
|
-
:key => 'attributes'
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
|
-
# Retrieves information about orders placed for a specific domain
|
133
|
-
#
|
134
|
-
# ==== Required
|
135
|
-
# * <tt>:domain</tt> - domain to get orders for
|
136
|
-
def get_orders_by_domain(domain)
|
137
|
-
run_command :get_orders_by_domain, :domain, {
|
138
|
-
:domain => domain,
|
139
|
-
:key => 'attributes'
|
140
|
-
}
|
141
|
-
end
|
142
|
-
|
143
|
-
# Queries the price of a domain
|
144
|
-
#
|
145
|
-
# ==== Required
|
146
|
-
# * <tt>:domain</tt> - domain to query the price of
|
147
|
-
def get_price(domain)
|
148
|
-
run_command :get_price, :domain, {
|
149
|
-
:domain => domain,
|
150
|
-
:key => 'attributes'
|
151
|
-
}
|
152
|
-
end
|
153
|
-
|
154
|
-
# Queries the properties of the specified Trust Service product
|
155
|
-
#
|
156
|
-
# ==== Required
|
157
|
-
# * <tt>:product_id</tt> - ID of the product
|
158
|
-
def get_product_info(product_id)
|
159
|
-
run_command :get_product_info, :trust_service, {
|
160
|
-
:product_id => product_id,
|
161
|
-
:key => 'attributes'
|
162
|
-
}
|
163
|
-
end
|
164
|
-
|
165
|
-
# Determines the availability of a domain
|
166
|
-
#
|
167
|
-
# ==== Required
|
168
|
-
# * <tt>:domain</tt> - domain to check availability of
|
169
|
-
def lookup_domain(domain)
|
170
|
-
run_command :lookup, :domain, {
|
171
|
-
:domain => domain,
|
172
|
-
:key => 'attributes'
|
173
|
-
}
|
174
|
-
end
|
175
|
-
|
176
|
-
# Provides suggestions for a domain name for the specified TLDs
|
177
|
-
#
|
178
|
-
# ==== Required
|
179
|
-
# * <tt>:domain</tt> - domain
|
180
|
-
# * <tt>:tlds</tt> - list of TLDs to make suggestions with
|
181
|
-
def name_suggest(domain, tlds)
|
182
|
-
tlds_indexed = {}
|
183
|
-
tlds.each_with_index do |tld, index|
|
184
|
-
tlds_indexed[index] = tld
|
185
|
-
end
|
186
|
-
|
187
|
-
run_command :name_suggest, :domain, {
|
188
|
-
:searchstring => domain,
|
189
|
-
:tlds => tlds_indexed,
|
190
|
-
:key => 'attributes'
|
191
|
-
}
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module MooMoo
|
2
|
-
module OpenSRS
|
3
|
-
module NameserverCommands
|
4
|
-
# Creates a nameserver
|
5
|
-
#
|
6
|
-
# ==== Required
|
7
|
-
# * <tt>:name</tt> - name of the nameserver
|
8
|
-
# * <tt>:ip</tt> - ip address for the nameserver
|
9
|
-
# * <tt>:domain</tt> - domain name to create it for
|
10
|
-
#
|
11
|
-
# ==== Optional
|
12
|
-
# * <tt>:cookie</tt> - cookie for domain
|
13
|
-
def create_nameserver(attribs)
|
14
|
-
Args.new(attribs) do |c|
|
15
|
-
c.requires :name, :ip, :domain
|
16
|
-
c.optionals :cookie
|
17
|
-
end
|
18
|
-
|
19
|
-
cookie = attribs.delete :cookie
|
20
|
-
run_command :create, :nameserver, attribs, cookie
|
21
|
-
end
|
22
|
-
|
23
|
-
# Deletes a nameserver
|
24
|
-
#
|
25
|
-
# ==== Required
|
26
|
-
# * <tt>:name</tt> - name of the nameserver
|
27
|
-
# * <tt>:ip</tt> - ip address for the nameserver
|
28
|
-
# * <tt>:domain</tt> - domain name to create it for
|
29
|
-
#
|
30
|
-
# ==== Optional
|
31
|
-
# * <tt>:cookie</tt> - cookie for domain
|
32
|
-
def delete_nameserver(attribs, cookie = nil)
|
33
|
-
Args.new(attribs) do |c|
|
34
|
-
c.requires :name, :ip, :domain
|
35
|
-
c.optionals :cookie
|
36
|
-
end
|
37
|
-
|
38
|
-
cookie = attribs.delete :cookie
|
39
|
-
run_command :delete, :nameserver, attribs, cookie
|
40
|
-
end
|
41
|
-
|
42
|
-
# Queries nameservers that exist for the given domain
|
43
|
-
#
|
44
|
-
# ==== Required
|
45
|
-
# * <tt>:domain</tt> - domain profile to query
|
46
|
-
def get_nameserver(domain)
|
47
|
-
run_command :get, :nameserver, {
|
48
|
-
:name => 'all',
|
49
|
-
:domain => domain,
|
50
|
-
:key => 'attributes'
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
# Renames a nameserver
|
55
|
-
#
|
56
|
-
# ==== Required
|
57
|
-
# * <tt>:name</tt> - current name of the nameserver
|
58
|
-
# * <tt>:ip</tt> - ip address of the name server
|
59
|
-
# * <tt>:new_name</tt> - new name for the nameserver
|
60
|
-
# * <tt>:domain</tt> - domain profile the nameserver was created for
|
61
|
-
def modify_nameserver(attribs)
|
62
|
-
Args.new(attribs) do |c|
|
63
|
-
c.requires :name, :ip, :new_name, :domain
|
64
|
-
end
|
65
|
-
|
66
|
-
run_command :modify, :nameserver, attribs
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|