epp-ruby 3.0.0
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 +7 -0
- data/.gitignore +24 -0
- data/.simplecov +16 -0
- data/.travis.yml +11 -0
- data/.yardopts +4 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +21 -0
- data/README.md +95 -0
- data/Rakefile +20 -0
- data/epp-ruby.gemspec +22 -0
- data/examples/contact_create.rb +28 -0
- data/examples/domain_check.rb +11 -0
- data/examples/domain_create.rb +19 -0
- data/examples/domain_info.rb +9 -0
- data/examples/host_create.rb +14 -0
- data/gemfiles/Gemfile.ruby18 +14 -0
- data/lib/epp-client/client.rb +172 -0
- data/lib/epp-client/commands/check.rb +11 -0
- data/lib/epp-client/commands/command.rb +24 -0
- data/lib/epp-client/commands/create.rb +11 -0
- data/lib/epp-client/commands/delete.rb +11 -0
- data/lib/epp-client/commands/info.rb +11 -0
- data/lib/epp-client/commands/login.rb +40 -0
- data/lib/epp-client/commands/logout.rb +11 -0
- data/lib/epp-client/commands/poll.rb +28 -0
- data/lib/epp-client/commands/read_write_command.rb +18 -0
- data/lib/epp-client/commands/renew.rb +11 -0
- data/lib/epp-client/commands/transfer.rb +25 -0
- data/lib/epp-client/commands/transfer_handshake.rb +43 -0
- data/lib/epp-client/commands/update.rb +11 -0
- data/lib/epp-client/contact/check.rb +23 -0
- data/lib/epp-client/contact/check_response.rb +41 -0
- data/lib/epp-client/contact/command.rb +106 -0
- data/lib/epp-client/contact/create.rb +34 -0
- data/lib/epp-client/contact/create_response.rb +14 -0
- data/lib/epp-client/contact/delete.rb +21 -0
- data/lib/epp-client/contact/delete_response.rb +9 -0
- data/lib/epp-client/contact/info.rb +21 -0
- data/lib/epp-client/contact/info_response.rb +74 -0
- data/lib/epp-client/contact/response.rb +34 -0
- data/lib/epp-client/contact/transfer.rb +21 -0
- data/lib/epp-client/contact/transfer_response.rb +26 -0
- data/lib/epp-client/contact/update.rb +80 -0
- data/lib/epp-client/contact/update_response.rb +9 -0
- data/lib/epp-client/domain/check.rb +23 -0
- data/lib/epp-client/domain/check_response.rb +41 -0
- data/lib/epp-client/domain/command.rb +92 -0
- data/lib/epp-client/domain/create.rb +75 -0
- data/lib/epp-client/domain/create_response.rb +29 -0
- data/lib/epp-client/domain/delete.rb +21 -0
- data/lib/epp-client/domain/delete_response.rb +9 -0
- data/lib/epp-client/domain/info.rb +21 -0
- data/lib/epp-client/domain/info_response.rb +72 -0
- data/lib/epp-client/domain/list.rb +36 -0
- data/lib/epp-client/domain/renew.rb +38 -0
- data/lib/epp-client/domain/renew_response.rb +14 -0
- data/lib/epp-client/domain/response.rb +34 -0
- data/lib/epp-client/domain/transfer.rb +37 -0
- data/lib/epp-client/domain/transfer_response.rb +29 -0
- data/lib/epp-client/domain/update.rb +81 -0
- data/lib/epp-client/domain/update_response.rb +9 -0
- data/lib/epp-client/host/check.rb +23 -0
- data/lib/epp-client/host/check_response.rb +41 -0
- data/lib/epp-client/host/command.rb +47 -0
- data/lib/epp-client/host/create.rb +24 -0
- data/lib/epp-client/host/create_response.rb +14 -0
- data/lib/epp-client/host/delete.rb +21 -0
- data/lib/epp-client/host/delete_response.rb +9 -0
- data/lib/epp-client/host/info.rb +21 -0
- data/lib/epp-client/host/info_response.rb +42 -0
- data/lib/epp-client/host/response.rb +34 -0
- data/lib/epp-client/host/update.rb +76 -0
- data/lib/epp-client/host/update_response.rb +9 -0
- data/lib/epp-client/old_server.rb +25 -0
- data/lib/epp-client/request.rb +51 -0
- data/lib/epp-client/requests/abstract.rb +30 -0
- data/lib/epp-client/requests/command.rb +28 -0
- data/lib/epp-client/requests/extension.rb +28 -0
- data/lib/epp-client/requests/hello.rb +12 -0
- data/lib/epp-client/response.rb +100 -0
- data/lib/epp-client/response_error.rb +15 -0
- data/lib/epp-client/response_helper.rb +25 -0
- data/lib/epp-client/server.rb +330 -0
- data/lib/epp-client/testing.rb +59 -0
- data/lib/epp-client/version.rb +3 -0
- data/lib/epp-client/xml_helper.rb +71 -0
- data/lib/epp-client.rb +103 -0
- data/lib/epp-ruby.rb +1 -0
- data/test/commands/test_check_command.rb +33 -0
- data/test/commands/test_create_command.rb +53 -0
- data/test/commands/test_delete_command.rb +28 -0
- data/test/commands/test_info_command.rb +28 -0
- data/test/commands/test_login_command.rb +56 -0
- data/test/commands/test_logout_command.rb +22 -0
- data/test/commands/test_poll_command.rb +54 -0
- data/test/commands/test_renew_command.rb +39 -0
- data/test/commands/test_transfer_command.rb +37 -0
- data/test/commands/test_update_command.rb +60 -0
- data/test/contact/test_contact_check.rb +33 -0
- data/test/contact/test_contact_check_response.rb +88 -0
- data/test/contact/test_contact_create.rb +71 -0
- data/test/contact/test_contact_create_response.rb +33 -0
- data/test/contact/test_contact_delete.rb +28 -0
- data/test/contact/test_contact_delete_response.rb +23 -0
- data/test/contact/test_contact_info.rb +28 -0
- data/test/contact/test_contact_info_response.rb +100 -0
- data/test/contact/test_contact_transfer.rb +28 -0
- data/test/contact/test_contact_transfer_response.rb +100 -0
- data/test/contact/test_contact_update.rb +84 -0
- data/test/contact/test_contact_update_response.rb +23 -0
- data/test/domain/test_domain_check.rb +33 -0
- data/test/domain/test_domain_check_response.rb +88 -0
- data/test/domain/test_domain_create.rb +108 -0
- data/test/domain/test_domain_create_response.rb +70 -0
- data/test/domain/test_domain_delete.rb +28 -0
- data/test/domain/test_domain_delete_response.rb +23 -0
- data/test/domain/test_domain_info.rb +28 -0
- data/test/domain/test_domain_info_response.rb +146 -0
- data/test/domain/test_domain_renew.rb +91 -0
- data/test/domain/test_domain_renew_response.rb +32 -0
- data/test/domain/test_domain_transfer.rb +89 -0
- data/test/domain/test_domain_transfer_response.rb +112 -0
- data/test/domain/test_domain_update.rb +73 -0
- data/test/domain/test_domain_update_response.rb +23 -0
- data/test/fixtures/responses/contact/check-single.xml +20 -0
- data/test/fixtures/responses/contact/check.xml +27 -0
- data/test/fixtures/responses/contact/create.xml +19 -0
- data/test/fixtures/responses/contact/delete.xml +12 -0
- data/test/fixtures/responses/contact/info.xml +49 -0
- data/test/fixtures/responses/contact/transfer-query.xml +23 -0
- data/test/fixtures/responses/contact/transfer-request.xml +23 -0
- data/test/fixtures/responses/contact/update.xml +12 -0
- data/test/fixtures/responses/domain/check-single.xml +20 -0
- data/test/fixtures/responses/domain/check.xml +27 -0
- data/test/fixtures/responses/domain/create-pending.xml +12 -0
- data/test/fixtures/responses/domain/create.xml +20 -0
- data/test/fixtures/responses/domain/delete.xml +12 -0
- data/test/fixtures/responses/domain/info-no-exDate.xml +38 -0
- data/test/fixtures/responses/domain/info-ns-hostAttr-name-only.xml +34 -0
- data/test/fixtures/responses/domain/info-ns-hostAttr.xml +38 -0
- data/test/fixtures/responses/domain/info.xml +40 -0
- data/test/fixtures/responses/domain/renew.xml +19 -0
- data/test/fixtures/responses/domain/transfer-query.xml +24 -0
- data/test/fixtures/responses/domain/transfer-request.xml +24 -0
- data/test/fixtures/responses/domain/update.xml +12 -0
- data/test/fixtures/responses/greeting.xml +25 -0
- data/test/fixtures/responses/host/check-single.xml +20 -0
- data/test/fixtures/responses/host/check.xml +27 -0
- data/test/fixtures/responses/host/create.xml +19 -0
- data/test/fixtures/responses/host/delete.xml +12 -0
- data/test/fixtures/responses/host/info.xml +30 -0
- data/test/fixtures/responses/host/update.xml +12 -0
- data/test/helper.rb +100 -0
- data/test/host/test_host_check.rb +33 -0
- data/test/host/test_host_check_response.rb +88 -0
- data/test/host/test_host_create.rb +37 -0
- data/test/host/test_host_create_response.rb +33 -0
- data/test/host/test_host_delete.rb +28 -0
- data/test/host/test_host_delete_response.rb +23 -0
- data/test/host/test_host_info.rb +28 -0
- data/test/host/test_host_info_response.rb +72 -0
- data/test/host/test_host_update.rb +68 -0
- data/test/host/test_host_update_response.rb +23 -0
- data/test/requests/test_command_request.rb +16 -0
- data/test/requests/test_extension_request.rb +55 -0
- data/test/requests/test_hello_request.rb +15 -0
- data/test/support/schemas/all.xsd +21 -0
- data/test/support/schemas/contact-1.0.xsd +387 -0
- data/test/support/schemas/domain-1.0.xsd +432 -0
- data/test/support/schemas/epp-1.0.xsd +403 -0
- data/test/support/schemas/eppcom-1.0.xsd +93 -0
- data/test/support/schemas/host-1.0.xsd +240 -0
- data/test/test_client.rb +64 -0
- data/test/test_request.rb +15 -0
- data/test/test_server.rb +67 -0
- metadata +322 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Domain
|
|
5
|
+
class Update < Command
|
|
6
|
+
ADD_REM_ORDER = [:ns, :contact, :status]
|
|
7
|
+
CHG_ORDER = [:registrant, :auth_info]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# @option [Hash] :status A Hash of status value to text. Text may optionally be an array in the form ["Text", "lang"] if a custom language value needs to be set.
|
|
11
|
+
def initialize(name, options = {})
|
|
12
|
+
@name = name
|
|
13
|
+
@add = options.delete(:add) || {}
|
|
14
|
+
@rem = options.delete(:rem) || {}
|
|
15
|
+
@chg = options.delete(:chg) || {}
|
|
16
|
+
|
|
17
|
+
@add.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
|
|
18
|
+
@rem.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
|
|
19
|
+
@chg.delete_if { |k,_| !CHG_ORDER.include?(k) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def name
|
|
23
|
+
'update'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_xml
|
|
27
|
+
node = super
|
|
28
|
+
node << domain_node('name', @name)
|
|
29
|
+
|
|
30
|
+
unless @add.empty?
|
|
31
|
+
node << add = domain_node('add')
|
|
32
|
+
add_rem_to_xml(add, @add)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
unless @rem.empty?
|
|
36
|
+
node << rem = domain_node('rem')
|
|
37
|
+
add_rem_to_xml(rem, @rem)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
unless @chg.empty?
|
|
41
|
+
node << chg = domain_node('chg')
|
|
42
|
+
CHG_ORDER.each do |key|
|
|
43
|
+
value = @chg[key]
|
|
44
|
+
next if value.nil?
|
|
45
|
+
|
|
46
|
+
case key
|
|
47
|
+
when :registrant
|
|
48
|
+
chg << domain_node('registrant', value)
|
|
49
|
+
when :auth_info
|
|
50
|
+
chg << auth_info_to_xml(value)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
node
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
def add_rem_to_xml(node, hash)
|
|
60
|
+
ADD_REM_ORDER.each do |key|
|
|
61
|
+
value = hash[key]
|
|
62
|
+
next if value.nil? || value.empty?
|
|
63
|
+
|
|
64
|
+
case key
|
|
65
|
+
when :ns
|
|
66
|
+
node << nameservers_to_xml(value)
|
|
67
|
+
when :contact
|
|
68
|
+
contacts_to_xml(node, value)
|
|
69
|
+
when :status
|
|
70
|
+
value.each do |status, text|
|
|
71
|
+
text, lang = Array(text)
|
|
72
|
+
node << s = domain_node('status', text)
|
|
73
|
+
s['lang'] = lang if lang
|
|
74
|
+
s['s'] = status.to_s
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class Check < Command
|
|
6
|
+
def initialize(*names)
|
|
7
|
+
@names = names.flatten
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'check'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
@names.each do |name|
|
|
17
|
+
node << host_node('name', name)
|
|
18
|
+
end
|
|
19
|
+
node
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class CheckResponse < Response
|
|
6
|
+
def available?(name = nil)
|
|
7
|
+
return availability[name] if name
|
|
8
|
+
|
|
9
|
+
if name.nil? && availability.count == 1
|
|
10
|
+
return availability.values.first
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
raise ArgumentError, "name must be specified if more than one host checked"
|
|
14
|
+
end
|
|
15
|
+
def unavailable?(name = nil)
|
|
16
|
+
!available?(name)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def names
|
|
20
|
+
availability.keys
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def name
|
|
24
|
+
raise "name unavailable when more than one host checked, use #names" if count != 1
|
|
25
|
+
names.first
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def count
|
|
29
|
+
availability.count
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
def availability
|
|
34
|
+
@availability ||= nodes_for_xpath('//host:name').inject({}) do |hash, node|
|
|
35
|
+
hash[node.content.strip] = node['avail'] == '1'
|
|
36
|
+
hash
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
module Host
|
|
3
|
+
class Command
|
|
4
|
+
include XMLHelpers
|
|
5
|
+
attr_reader :namespaces
|
|
6
|
+
|
|
7
|
+
def set_namespaces(namespaces)
|
|
8
|
+
@namespaces = namespaces
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def name
|
|
12
|
+
raise NotImplementedError, "#name must be implemented in subclasses"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_xml
|
|
16
|
+
@namespaces ||= {}
|
|
17
|
+
node = host_node(name)
|
|
18
|
+
|
|
19
|
+
xattr = XML::Attr.new(node, "schemaLocation", SCHEMA_LOCATION)
|
|
20
|
+
xattr.namespaces.namespace = @namespaces['xsi'] || XML::Namespace.new(node, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
|
|
21
|
+
|
|
22
|
+
node
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
def host_node(name, value = nil)
|
|
27
|
+
node = xml_node(name, value)
|
|
28
|
+
node.namespaces.namespace = host_namespace(node)
|
|
29
|
+
node
|
|
30
|
+
end
|
|
31
|
+
def host_namespace(node)
|
|
32
|
+
return @namespaces['host'] if @namespaces.has_key?('host')
|
|
33
|
+
@namespaces['host'] = xml_namespace(node, 'host', NAMESPACE)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def addrs_to_xml(node, addrs)
|
|
37
|
+
addrs.each do |key, values|
|
|
38
|
+
ip = key.to_s.sub('ip', '')
|
|
39
|
+
Array(values).each do |value|
|
|
40
|
+
node << addr = host_node('addr', value)
|
|
41
|
+
addr['ip'] = ip
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class Create < Command
|
|
6
|
+
def initialize(name, addrs = {})
|
|
7
|
+
@name = name
|
|
8
|
+
@addrs = addrs
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def name
|
|
12
|
+
'create'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_xml
|
|
16
|
+
node = super
|
|
17
|
+
node << host_node('name', @name)
|
|
18
|
+
addrs_to_xml(node, @addrs)
|
|
19
|
+
|
|
20
|
+
node
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class CreateResponse < Response
|
|
6
|
+
def name
|
|
7
|
+
@name ||= value_for_xpath('//host:name')
|
|
8
|
+
end
|
|
9
|
+
def creation_date
|
|
10
|
+
@crdate ||= value_for_xpath('//host:crDate') && Time.parse(value_for_xpath('//host:crDate'))
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class Delete < Command
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@name = name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'delete'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << host_node('name', @name)
|
|
17
|
+
node
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class Info < Command
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@name = name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'info'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << host_node('name', @name)
|
|
17
|
+
node
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class InfoResponse < Response
|
|
6
|
+
def name
|
|
7
|
+
@name ||= value_for_xpath('//host:name')
|
|
8
|
+
end
|
|
9
|
+
def roid
|
|
10
|
+
@roid ||= value_for_xpath('//host:roid')
|
|
11
|
+
end
|
|
12
|
+
def status
|
|
13
|
+
@status ||= values_for_xpath('//host:status/@s')
|
|
14
|
+
end
|
|
15
|
+
def addresses
|
|
16
|
+
@addresses ||= nodes_for_xpath('//host:addr').inject({}) do |hash, node|
|
|
17
|
+
hash["ip#{node['ip']}"] ||= Array.new
|
|
18
|
+
hash["ip#{node['ip']}"] << node.content.strip
|
|
19
|
+
hash
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
def client_id
|
|
23
|
+
@clid ||= value_for_xpath('//host:clID')
|
|
24
|
+
end
|
|
25
|
+
def creator_id
|
|
26
|
+
@crid ||= value_for_xpath('//host:crID')
|
|
27
|
+
end
|
|
28
|
+
def created_date
|
|
29
|
+
@crdate ||= value_for_xpath('//host:crDate') && Time.parse(value_for_xpath('//host:crDate'))
|
|
30
|
+
end
|
|
31
|
+
def updator_id
|
|
32
|
+
@upid ||= value_for_xpath('//host:upID')
|
|
33
|
+
end
|
|
34
|
+
def updated_date
|
|
35
|
+
@update ||= value_for_xpath('//host:upDate') && Time.parse(value_for_xpath('//host:upDate'))
|
|
36
|
+
end
|
|
37
|
+
def transfer_date
|
|
38
|
+
@trdate ||= value_for_xpath('//host:trDate') && Time.parse(value_for_xpath('//host:trDate'))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
module Host
|
|
3
|
+
class Response
|
|
4
|
+
include ResponseHelper
|
|
5
|
+
|
|
6
|
+
def initialize(response)
|
|
7
|
+
@response = response
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def method_missing(meth, *args, &block)
|
|
11
|
+
return super unless @response.respond_to?(meth)
|
|
12
|
+
@response.send(meth, *args, &block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def respond_to_missing?(method, include_private)
|
|
16
|
+
@response.respond_to?(method, include_private)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
unless RUBY_VERSION >= "1.9.2"
|
|
20
|
+
def respond_to?(method, include_private = false)
|
|
21
|
+
respond_to_missing?(method, include_private) || super
|
|
22
|
+
end
|
|
23
|
+
def method(sym)
|
|
24
|
+
respond_to_missing?(sym, true) ? @response.method(sym) : super
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
protected
|
|
29
|
+
def namespaces
|
|
30
|
+
{'host' => NAMESPACE}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Host
|
|
5
|
+
class Update < Command
|
|
6
|
+
ADD_REM_ORDER = [:addr, :status]
|
|
7
|
+
CHG_ORDER = [:name]
|
|
8
|
+
|
|
9
|
+
# @option [Hash] :status A Hash of status value to text. Text may optionally be an array in the form ["Text", "lang"] if a custom language value needs to be set.
|
|
10
|
+
def initialize(name, options = {})
|
|
11
|
+
@name = name
|
|
12
|
+
@add = options.delete(:add) || {}
|
|
13
|
+
@rem = options.delete(:rem) || {}
|
|
14
|
+
@chg = options.delete(:chg) || {}
|
|
15
|
+
|
|
16
|
+
@add.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
|
|
17
|
+
@rem.delete_if { |k,_| !ADD_REM_ORDER.include?(k) }
|
|
18
|
+
@chg.delete_if { |k,_| !CHG_ORDER.include?(k) }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def name
|
|
22
|
+
'update'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def to_xml
|
|
26
|
+
node = super
|
|
27
|
+
node << host_node('name', @name)
|
|
28
|
+
|
|
29
|
+
unless @add.empty?
|
|
30
|
+
node << add = host_node('add')
|
|
31
|
+
add_rem_to_xml(add, @add)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
unless @rem.empty?
|
|
35
|
+
node << rem = host_node('rem')
|
|
36
|
+
add_rem_to_xml(rem, @rem)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
unless @chg.empty?
|
|
40
|
+
node << chg = host_node('chg')
|
|
41
|
+
CHG_ORDER.each do |key|
|
|
42
|
+
value = @chg[key]
|
|
43
|
+
next if value.nil?
|
|
44
|
+
|
|
45
|
+
case key
|
|
46
|
+
when :name
|
|
47
|
+
chg << host_node('name', value)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
node
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
protected
|
|
56
|
+
def add_rem_to_xml(node, hash)
|
|
57
|
+
ADD_REM_ORDER.each do |key|
|
|
58
|
+
value = hash[key]
|
|
59
|
+
next if value.nil? || value.empty?
|
|
60
|
+
|
|
61
|
+
case key
|
|
62
|
+
when :addr
|
|
63
|
+
addrs_to_xml(node, value)
|
|
64
|
+
when :status
|
|
65
|
+
value.each do |status, text|
|
|
66
|
+
text, lang = Array(text)
|
|
67
|
+
node << s = host_node('status', text)
|
|
68
|
+
s['lang'] = lang if lang
|
|
69
|
+
s['s'] = status.to_s
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
# Handles sending and receiving data to older EPP servers.
|
|
3
|
+
#
|
|
4
|
+
# These servers transmit the payload with CRLF at the end
|
|
5
|
+
# and recieve one byte at a time until EOF is reached.
|
|
6
|
+
class OldServer < Server
|
|
7
|
+
# Sends frame using old method
|
|
8
|
+
#
|
|
9
|
+
# @param [String] xml XML payload to send
|
|
10
|
+
def send_frame(xml)
|
|
11
|
+
@sock.write(xml + "\r\n")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Receives frame using old method
|
|
15
|
+
#
|
|
16
|
+
# @return [String] XML Payload response
|
|
17
|
+
def recv_frame
|
|
18
|
+
data = ''
|
|
19
|
+
until @sock.eof?
|
|
20
|
+
data << @sock.read(1)
|
|
21
|
+
end
|
|
22
|
+
data
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
# An EPP XML Request
|
|
3
|
+
class Request
|
|
4
|
+
include XMLHelpers
|
|
5
|
+
|
|
6
|
+
# Create and return a new EPP Request Payload
|
|
7
|
+
#
|
|
8
|
+
# @param [EPP::Request]
|
|
9
|
+
def initialize(request)
|
|
10
|
+
@request = request
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def namespaces
|
|
14
|
+
@namespaces
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Receiver in XML form
|
|
18
|
+
# @return [XML::Document] XML of the receiver
|
|
19
|
+
def to_xml
|
|
20
|
+
doc = XML::Document.new('1.0')
|
|
21
|
+
doc.root = XML::Node.new('epp')
|
|
22
|
+
root = doc.root
|
|
23
|
+
|
|
24
|
+
epp_ns = XML::Namespace.new(root, nil, 'urn:ietf:params:xml:ns:epp-1.0')
|
|
25
|
+
root.namespaces.namespace = epp_ns
|
|
26
|
+
|
|
27
|
+
xsi_ns = XML::Namespace.new(root, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
|
|
28
|
+
xsi_sL = XML::Attr.new(root, 'schemaLocation', 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd')
|
|
29
|
+
xsi_sL.namespaces.namespace = xsi_ns
|
|
30
|
+
|
|
31
|
+
@namespaces = {'epp' => epp_ns, 'xsi' => xsi_ns}
|
|
32
|
+
|
|
33
|
+
@request.set_namespaces(@namespaces) if @request.respond_to?(:set_namespaces)
|
|
34
|
+
root << @request.to_xml
|
|
35
|
+
|
|
36
|
+
doc
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Convert the receiver to a string
|
|
40
|
+
#
|
|
41
|
+
# @param [Hash] opts Formatting options, passed to the XML::Document
|
|
42
|
+
def to_s(opts = {})
|
|
43
|
+
to_xml.to_s({:indent => false}.merge(opts))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @see Object#inspect
|
|
47
|
+
# def inspect
|
|
48
|
+
# "#<#{self.class}>"
|
|
49
|
+
# end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
module Requests
|
|
3
|
+
# @note Abstract class, do not instanciate manually
|
|
4
|
+
class Abstract
|
|
5
|
+
include XMLHelpers
|
|
6
|
+
attr_reader :namespaces
|
|
7
|
+
|
|
8
|
+
def set_namespaces(namespaces)
|
|
9
|
+
@namespaces = namespaces
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def name
|
|
13
|
+
raise NotImplementedError, "#name must be overriden by subclasses"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Receiver in XML form
|
|
17
|
+
# @return [XML::Document] XML of the receiver
|
|
18
|
+
def to_xml
|
|
19
|
+
epp_node(name, @namespaces || {})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Convert the receiver to a string
|
|
23
|
+
#
|
|
24
|
+
# @param [Hash] opts Formatting options, passed to the XML::Document
|
|
25
|
+
def to_s(opts = {})
|
|
26
|
+
to_xml.to_s({:indent => false}.merge(opts))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.expand_path('../abstract', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Requests
|
|
5
|
+
class Command < Abstract
|
|
6
|
+
def initialize(tid, command, extension = nil)
|
|
7
|
+
@tid, @command, @extension = tid, command, extension
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'command'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
|
|
17
|
+
@command.set_namespaces(@namespaces) if @command.respond_to?(:set_namespaces)
|
|
18
|
+
@extension.set_namespaces(@namespaces) if @extension && @extension.respond_to?(:set_namespaces)
|
|
19
|
+
|
|
20
|
+
node << as_xml(@command)
|
|
21
|
+
node << as_xml(@extension) if @extension
|
|
22
|
+
node << epp_node('clTRID', @tid, @namespaces)
|
|
23
|
+
|
|
24
|
+
node
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.expand_path('../abstract', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Requests
|
|
5
|
+
class Extension < Abstract
|
|
6
|
+
def initialize(*extensions)
|
|
7
|
+
raise ArgumentError, "you must provide at least one extension" if extensions.compact.empty?
|
|
8
|
+
@extensions = extensions.compact
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def name
|
|
12
|
+
'extension'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_xml
|
|
16
|
+
node = super
|
|
17
|
+
|
|
18
|
+
Array(@extensions).each do |extension|
|
|
19
|
+
next if extension.nil?
|
|
20
|
+
extension.set_namespaces(@namespaces) if extension.respond_to?(:set_namespaces)
|
|
21
|
+
node << as_xml(extension)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
node
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|