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,40 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Commands
|
|
5
|
+
class Login < Command
|
|
6
|
+
def initialize(tag, passwd, config)
|
|
7
|
+
@tag, @passwd, @config = tag, passwd, config
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'login'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << epp_node('clID', @tag, @namespaces || {})
|
|
17
|
+
node << epp_node('pw', @passwd, @namespaces || {})
|
|
18
|
+
|
|
19
|
+
options = epp_node('options', @namespaces || {})
|
|
20
|
+
options << epp_node('version', @config[:version], @namespaces || {})
|
|
21
|
+
options << epp_node('lang', @config[:lang], @namespaces || {})
|
|
22
|
+
node << options
|
|
23
|
+
|
|
24
|
+
svcs = epp_node('svcs', @namespaces || {})
|
|
25
|
+
@config[:services].each { |uri| svcs << epp_node('objURI', uri, @namespaces || {}) }
|
|
26
|
+
node << svcs
|
|
27
|
+
|
|
28
|
+
unless @config[:extensions].empty?
|
|
29
|
+
ext = epp_node('svcExtension', @namespaces || {})
|
|
30
|
+
@config[:extensions].each do |uri|
|
|
31
|
+
ext << epp_node('extURI', uri, @namespaces || {})
|
|
32
|
+
end
|
|
33
|
+
svcs << ext
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
node
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Commands
|
|
5
|
+
class Poll < Command
|
|
6
|
+
def initialize(msgID = nil)
|
|
7
|
+
@msgID = msgID
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'poll'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
|
|
17
|
+
if @msgID
|
|
18
|
+
node['op'] = 'ack'
|
|
19
|
+
node['msgID'] = @msgID
|
|
20
|
+
else
|
|
21
|
+
node['op'] = 'req'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
node
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Commands
|
|
5
|
+
class ReadWriteCommand < Command
|
|
6
|
+
def initialize(command)
|
|
7
|
+
@command = command
|
|
8
|
+
end
|
|
9
|
+
def to_xml
|
|
10
|
+
node = super
|
|
11
|
+
|
|
12
|
+
@command.set_namespaces(@namespaces) if @command.respond_to?(:set_namespaces)
|
|
13
|
+
node << as_xml(@command)
|
|
14
|
+
node
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.expand_path('../read_write_command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Commands
|
|
5
|
+
class Transfer < ReadWriteCommand
|
|
6
|
+
OPERATIONS = %w(approve cancel query reject request)
|
|
7
|
+
|
|
8
|
+
def initialize(op, command)
|
|
9
|
+
raise ArgumentError, "op must be one of #{OPERATIONS.join(', ')}" unless OPERATIONS.include?(op)
|
|
10
|
+
|
|
11
|
+
super command
|
|
12
|
+
@op = op
|
|
13
|
+
end
|
|
14
|
+
def name
|
|
15
|
+
'transfer'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_xml
|
|
19
|
+
node = super
|
|
20
|
+
node['op'] = @op
|
|
21
|
+
node
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Commands
|
|
5
|
+
class TransferHandshake < Command
|
|
6
|
+
NAMESPACE = 'http://www.nominet.org.uk/epp/xml/std-handshake-1.0'
|
|
7
|
+
SCHEMA_LOCATION = 'http://www.nominet.org.uk/epp/xml/std-handshake-1.0 std-handshake-1.0.xsd'
|
|
8
|
+
|
|
9
|
+
def initialize(case_id, handshake: 'accept')
|
|
10
|
+
raise 'Unsupported handshack command' unless handshake.in? %w(accept reject)
|
|
11
|
+
|
|
12
|
+
@case_id = case_id
|
|
13
|
+
@handshake = handshake
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def name
|
|
17
|
+
'update'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_xml
|
|
21
|
+
@namespaces ||= {}
|
|
22
|
+
|
|
23
|
+
node = super
|
|
24
|
+
node << handshake_node
|
|
25
|
+
node
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def handshake_node
|
|
31
|
+
node = xml_node(@handshake)
|
|
32
|
+
node.namespaces.namespace = handshake_namespace(node)
|
|
33
|
+
node << xml_node('h:caseId', @case_id)
|
|
34
|
+
node
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def handshake_namespace(node)
|
|
38
|
+
return @namespaces['h'] if @namespaces.has_key?('h')
|
|
39
|
+
@namespaces['h'] = xml_namespace(node, 'h', NAMESPACE)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class Check < Command
|
|
6
|
+
def initialize(*ids)
|
|
7
|
+
@ids = ids.flatten
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'check'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
@ids.each do |id|
|
|
17
|
+
node << contact_node('id', id)
|
|
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 Contact
|
|
5
|
+
class CheckResponse < Response
|
|
6
|
+
def available?(id = nil)
|
|
7
|
+
return availability[id] if id
|
|
8
|
+
|
|
9
|
+
if id.nil? && availability.count == 1
|
|
10
|
+
return availability.values.first
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
raise ArgumentError, "id must be specified if more than one contact checked"
|
|
14
|
+
end
|
|
15
|
+
def unavailable?(id = nil)
|
|
16
|
+
!available?(id)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def ids
|
|
20
|
+
availability.keys
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def id
|
|
24
|
+
raise "id unavailable when more than one contact checked, use #ids" if count != 1
|
|
25
|
+
ids.first
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def count
|
|
29
|
+
availability.count
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
def availability
|
|
34
|
+
@availability ||= nodes_for_xpath('//contact:id').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,106 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
module Contact
|
|
3
|
+
class Command
|
|
4
|
+
include XMLHelpers
|
|
5
|
+
attr_reader :namespaces
|
|
6
|
+
|
|
7
|
+
DISCLOSE_ORDER = ['name', 'org', 'addr', 'voice', 'fax', 'email']
|
|
8
|
+
MAX_STREETS = 3
|
|
9
|
+
|
|
10
|
+
class TooManyStreetLines < RuntimeError
|
|
11
|
+
attr_reader :streets
|
|
12
|
+
def initialize(streets)
|
|
13
|
+
super("too many streets, #{streets[MAX_STREETS..-1]} would be excluded")
|
|
14
|
+
@streets = streets
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_namespaces(namespaces)
|
|
19
|
+
@namespaces = namespaces
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def name
|
|
23
|
+
raise NotImplementedError, "#name must be implemented in subclasses"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_xml
|
|
27
|
+
@namespaces ||= {}
|
|
28
|
+
node = contact_node(name)
|
|
29
|
+
|
|
30
|
+
xattr = XML::Attr.new(node, "schemaLocation", SCHEMA_LOCATION)
|
|
31
|
+
xattr.namespaces.namespace = @namespaces['xsi'] || XML::Namespace.new(node, 'xsi', 'http://www.w3.org/2001/XMLSchema-instance')
|
|
32
|
+
|
|
33
|
+
node
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
protected
|
|
37
|
+
def contact_node(name, value = nil)
|
|
38
|
+
node = xml_node(name, value)
|
|
39
|
+
node.namespaces.namespace = contact_namespace(node)
|
|
40
|
+
node
|
|
41
|
+
end
|
|
42
|
+
def contact_namespace(node)
|
|
43
|
+
return @namespaces['contact'] if @namespaces.has_key?('contact')
|
|
44
|
+
@namespaces['contact'] = xml_namespace(node, 'contact', NAMESPACE)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def postal_info_to_xml(postal_info)
|
|
48
|
+
node = contact_node('postalInfo')
|
|
49
|
+
node['type'] = 'loc'
|
|
50
|
+
|
|
51
|
+
node << contact_node('name', postal_info[:name]) if postal_info[:name]
|
|
52
|
+
node << contact_node('org', postal_info[:org]) if postal_info[:org]
|
|
53
|
+
node << addr_to_xml(postal_info[:addr]) if postal_info[:addr]
|
|
54
|
+
|
|
55
|
+
node
|
|
56
|
+
end
|
|
57
|
+
def addr_to_xml(addr)
|
|
58
|
+
node = contact_node('addr')
|
|
59
|
+
|
|
60
|
+
if addr[:street]
|
|
61
|
+
streets = addr[:street].split("\n")
|
|
62
|
+
if streets.count > MAX_STREETS
|
|
63
|
+
raise TooManyStreetLines.new(streets)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
streets.each do |street|
|
|
67
|
+
node << contact_node('street', street)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
node << contact_node('city', addr[:city])
|
|
72
|
+
node << contact_node('sp', addr[:sp]) if addr[:sp]
|
|
73
|
+
node << contact_node('pc', addr[:pc]) if addr[:pc]
|
|
74
|
+
node << contact_node('cc', addr[:cc])
|
|
75
|
+
|
|
76
|
+
node
|
|
77
|
+
end
|
|
78
|
+
def disclose_to_xml(disclose)
|
|
79
|
+
flag = disclose.keys.first
|
|
80
|
+
node = contact_node('disclose')
|
|
81
|
+
node['flag'] = flag
|
|
82
|
+
|
|
83
|
+
DISCLOSE_ORDER.each do |name|
|
|
84
|
+
next unless disclose[flag].include?(name)
|
|
85
|
+
node << n = contact_node(name)
|
|
86
|
+
n['type'] = 'loc' if ['name', 'org', 'addr'].include?(name)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
node
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def auth_info_to_xml(auth_info)
|
|
93
|
+
a = contact_node('authInfo')
|
|
94
|
+
|
|
95
|
+
if auth_info.has_key?(:pw)
|
|
96
|
+
a << pw = contact_node('pw', auth_info[:pw])
|
|
97
|
+
pw['roid'] = auth_info[:roid] if auth_info.has_key?(:roid)
|
|
98
|
+
elsif auth_info.has_key?(:ext)
|
|
99
|
+
a << contact_node('ext', auth_info[:ext])
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
a
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class Create < Command
|
|
6
|
+
def initialize(id, options = {})
|
|
7
|
+
@id = id
|
|
8
|
+
|
|
9
|
+
@postal_info = options.delete(:postal_info)
|
|
10
|
+
@voice = options.delete(:voice)
|
|
11
|
+
@fax = options.delete(:fax)
|
|
12
|
+
@email = options.delete(:email)
|
|
13
|
+
@auth_info = options.delete(:auth_info)
|
|
14
|
+
@disclose = options.delete(:disclose)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def name
|
|
18
|
+
'create'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_xml
|
|
22
|
+
node = super
|
|
23
|
+
node << contact_node('id', @id)
|
|
24
|
+
node << postal_info_to_xml(@postal_info)
|
|
25
|
+
node << contact_node('voice', @voice) if @voice
|
|
26
|
+
node << contact_node('fax', @fax) if @fax
|
|
27
|
+
node << contact_node('email', @email)
|
|
28
|
+
node << auth_info_to_xml(@auth_info)
|
|
29
|
+
node << disclose_to_xml(@disclose) if @disclose
|
|
30
|
+
node
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class CreateResponse < Response
|
|
6
|
+
def id
|
|
7
|
+
@id ||= value_for_xpath('//contact:id')
|
|
8
|
+
end
|
|
9
|
+
def creation_date
|
|
10
|
+
@crdate ||= value_for_xpath('//contact:crDate') && Time.parse(value_for_xpath('//contact: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 Contact
|
|
5
|
+
class Delete < Command
|
|
6
|
+
def initialize(id)
|
|
7
|
+
@id = id
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'delete'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << contact_node('id', @id)
|
|
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 Contact
|
|
5
|
+
class Info < Command
|
|
6
|
+
def initialize(id)
|
|
7
|
+
@id = id
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'info'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << contact_node('id', @id)
|
|
17
|
+
node
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class InfoResponse < Response
|
|
6
|
+
def id
|
|
7
|
+
@id ||= value_for_xpath('//contact:id')
|
|
8
|
+
end
|
|
9
|
+
def roid
|
|
10
|
+
@roid ||= value_for_xpath('//contact:roid')
|
|
11
|
+
end
|
|
12
|
+
def status
|
|
13
|
+
@status ||= values_for_xpath('//contact:status/@s')
|
|
14
|
+
end
|
|
15
|
+
def email
|
|
16
|
+
@email ||= value_for_xpath('//contact:email')
|
|
17
|
+
end
|
|
18
|
+
def fax
|
|
19
|
+
@fax ||= value_for_xpath('//contact:fax') do |node|
|
|
20
|
+
[node.content.strip, node['x']].compact.join(".")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
def voice
|
|
24
|
+
@voice ||= value_for_xpath('//contact:voice') do |node|
|
|
25
|
+
[node.content.strip, node['x']].compact.join(".")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
def postal_info
|
|
29
|
+
@postal_info ||= {
|
|
30
|
+
:name => value_for_xpath('//contact:postalInfo/contact:name'),
|
|
31
|
+
:org => value_for_xpath('//contact:postalInfo/contact:org'),
|
|
32
|
+
:addr => {
|
|
33
|
+
:street => values_for_xpath('//contact:postalInfo/contact:addr/contact:street').join("\n"),
|
|
34
|
+
:city => value_for_xpath('//contact:postalInfo/contact:addr/contact:city'),
|
|
35
|
+
:sp => value_for_xpath('//contact:postalInfo/contact:addr/contact:sp'),
|
|
36
|
+
:pc => value_for_xpath('//contact:postalInfo/contact:addr/contact:pc'),
|
|
37
|
+
:cc => value_for_xpath('//contact:postalInfo/contact:addr/contact:cc')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
def client_id
|
|
42
|
+
@clid ||= value_for_xpath('//contact:clID')
|
|
43
|
+
end
|
|
44
|
+
def creator_id
|
|
45
|
+
@crid ||= value_for_xpath('//contact:crID')
|
|
46
|
+
end
|
|
47
|
+
def created_date
|
|
48
|
+
@crdate ||= value_for_xpath('//contact:crDate') && Time.parse(value_for_xpath('//contact:crDate'))
|
|
49
|
+
end
|
|
50
|
+
def updator_id
|
|
51
|
+
@upid ||= value_for_xpath('//contact:upID')
|
|
52
|
+
end
|
|
53
|
+
def updated_date
|
|
54
|
+
@update ||= value_for_xpath('//contact:upDate') && Time.parse(value_for_xpath('//contact:upDate'))
|
|
55
|
+
end
|
|
56
|
+
def transfer_date
|
|
57
|
+
@trdate ||= value_for_xpath('//contact:trDate') && Time.parse(value_for_xpath('//contact:trDate'))
|
|
58
|
+
end
|
|
59
|
+
def auth_info
|
|
60
|
+
@auth_info ||= begin
|
|
61
|
+
{ 'pw' => value_for_xpath('//contact:authInfo/contact:pw') }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
def disclose
|
|
65
|
+
@disclose ||= begin
|
|
66
|
+
nodes_for_xpath('//contact:disclose').inject({}) do |hash, node|
|
|
67
|
+
hash[node['flag'].to_s] = node.children.reject{|n| n.empty?}.map { |child| child.name }
|
|
68
|
+
hash
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module EPP
|
|
2
|
+
module Contact
|
|
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
|
+
{'contact' => NAMESPACE}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.expand_path('../command', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class Transfer < Command
|
|
6
|
+
def initialize(id)
|
|
7
|
+
@id = id
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def name
|
|
11
|
+
'transfer'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_xml
|
|
15
|
+
node = super
|
|
16
|
+
node << contact_node('id', @id)
|
|
17
|
+
node
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path('../response', __FILE__)
|
|
2
|
+
|
|
3
|
+
module EPP
|
|
4
|
+
module Contact
|
|
5
|
+
class TransferResponse < Response
|
|
6
|
+
def id
|
|
7
|
+
@id ||= value_for_xpath('//contact:id')
|
|
8
|
+
end
|
|
9
|
+
def status
|
|
10
|
+
@trStatus ||= value_for_xpath('//contact:trStatus')
|
|
11
|
+
end
|
|
12
|
+
def requested_id
|
|
13
|
+
@reID ||= value_for_xpath('//contact:reID')
|
|
14
|
+
end
|
|
15
|
+
def requested_date
|
|
16
|
+
@reDate ||= value_for_xpath('//contact:reDate') && Time.parse(value_for_xpath('//contact:reDate'))
|
|
17
|
+
end
|
|
18
|
+
def action_id
|
|
19
|
+
@acID ||= value_for_xpath('//contact:acID')
|
|
20
|
+
end
|
|
21
|
+
def action_date
|
|
22
|
+
@acDate ||= value_for_xpath('//contact:acDate') && Time.parse(value_for_xpath('//contact:acDate'))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|