Class: NominetEPP::Domain::Check::DirectRightsExtension
Constant Summary
collapse
- KEYS =
[:postal_info, :email, :registrant]
- NAMESPACE =
'http://www.nominet.org.uk/epp/xml/nom-direct-rights-1.0'
Instance Attribute Summary
#namespaces
Instance Method Summary
collapse
#schemaLocation, #schema_name, #set_namespaces, #x_namespace, #x_node, #x_schemaLocation, #xml_namespace, #xml_node
Constructor Details
Returns a new instance of DirectRightsExtension.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/nominet-epp/requests/domain/check.rb', line 21
def initialize(attributes)
raise ArgumentError, "must provide Hash with one of #{KEYS.map(&:inspect).join(", ")}" if attributes.nil? || attributes.empty?
if attributes.has_key?(:postal_info)
unless attributes.has_key?(:email)
raise ArgumentError, "must provide :email when using :postal_info"
end
end
if attributes.has_key?(:email)
unless attributes.has_key?(:postal_info)
raise ArgumentError, "must provide :postal_info when using :email"
end
end
if attributes.has_key?(:registrant)
if attributes.has_key?(:email) || attributes.has_key?(:postal_info)
raise ArgumentError, ":registrant must be used on its own"
end
end
@attributes = attributes
@namespaces = {}
end
|
Instance Method Details
54
55
56
57
58
59
|
# File 'lib/nominet-epp/requests/domain/check.rb', line 54
def contact_node(name, value = nil)
node = xml_node(name, value)
node.namespaces.namespace = x_namespace(node,
'contact', EPP::Contact::NAMESPACE)
node
end
|
#namespace_name ⇒ Object
50
51
52
|
# File 'lib/nominet-epp/requests/domain/check.rb', line 50
def namespace_name
'nom-direct-rights'
end
|
#namespace_uri ⇒ Object
47
48
49
|
# File 'lib/nominet-epp/requests/domain/check.rb', line 47
def namespace_uri
NAMESPACE
end
|
#to_xml ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/nominet-epp/requests/domain/check.rb', line 61
def to_xml
node = x_node('check')
x_schemaLocation(node)
KEYS.each do |key|
value = @attributes[key]
next if value.nil? || value == ''
case key
when :postal_info
node << x_node('postalInfo').tap do |postalInfo|
postalInfo['type'] = 'loc'
@namespaces['contact'] = xml_namespace(postalInfo, 'contact', EPP::Contact::NAMESPACE)
x_schemaLocation(postalInfo, EPP::Contact::SCHEMA_LOCATION)
postalInfo << contact_node('name', value[:name])
postalInfo << contact_node('org', value[:org]) if value[:org]
postalInfo << contact_node('addr').tap do |addr|
addr << contact_node('street', value[:addr][:street]) if value[:addr][:street]
addr << contact_node('city', value[:addr][:city])
addr << contact_node('sp', value[:addr][:sp]) if value[:addr][:sp]
addr << contact_node('pc', value[:addr][:pc]) if value[:addr][:pc]
addr << contact_node('cc', value[:addr][:cc])
end
end
else
name = key.to_s.gsub('_', '-')
node << x_node(name, value.to_s)
end
end
node
end
|