Class: EppXml

Inherits:
Object
  • Object
show all
Includes:
ClientTransactionId
Defined in:
lib/epp-xml.rb,
lib/epp-xml/domain.rb,
lib/epp-xml/contact.rb,
lib/epp-xml/session.rb,
lib/epp-xml/keyrelay.rb

Defined Under Namespace

Classes: Contact, Domain, Keyrelay, Session

Instance Attribute Summary

Attributes included from ClientTransactionId

#cl_trid, #cl_trid_prefix

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClientTransactionId

#clTRID, #initialize

Class Method Details

.custom_ext(xml, custom_params) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/epp-xml.rb', line 58

def custom_ext(xml, custom_params)
  xml.extension do
    xml.tag!('eis:extdata',
      'xmlns:eis' => 'https://epp.tld.ee/schema/eis-1.0.xsd') do
      EppXml.generate_xml_from_hash(custom_params, xml, 'eis:')
    end if custom_params.any?
  end if custom_params.any?
end

.generate_xml_from_hash(xml_params, xml, ns = '') ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/epp-xml.rb', line 29

def generate_xml_from_hash(xml_params, xml, ns = '')
  xml_params.each do |k, v|
    # Value is a hash which has string type value
    if v.is_a?(Hash) && v[:value].is_a?(String)
      xml.tag!("#{ns}#{k}", v[:value], v[:attrs])
    # Value is a hash which is nested
    elsif v.is_a?(Hash)
      attrs = v.delete(:attrs)
      value = v.delete(:value) || v
      xml.tag!("#{ns}#{k}", attrs) do
        generate_xml_from_hash(value, xml, ns)
      end
    # Value is an array
    elsif v.is_a?(Array)
      if k.to_s.start_with?('_')
        v.each do |x|
          generate_xml_from_hash(x, xml, ns)
        end
      else
        xml.tag!("#{ns}#{k}") do
          v.each do |x|
            generate_xml_from_hash(x, xml, ns)
          end
        end
      end
    end
  end
end

Instance Method Details

#contactObject



16
17
18
# File 'lib/epp-xml.rb', line 16

def contact
  @cached_contact ||= EppXml::Contact.new(cl_trid: cl_trid, cl_trid_prefix: cl_trid_prefix)
end

#domainObject



12
13
14
# File 'lib/epp-xml.rb', line 12

def domain
  @cached_domain ||= EppXml::Domain.new(cl_trid: cl_trid, cl_trid_prefix: cl_trid_prefix)
end

#keyrelayObject



24
25
26
# File 'lib/epp-xml.rb', line 24

def keyrelay
  @cached_keyrelay ||= EppXml::Keyrelay.new(cl_trid: cl_trid, cl_trid_prefix: cl_trid_prefix)
end

#sessionObject



20
21
22
# File 'lib/epp-xml.rb', line 20

def session
  @cached_session ||= EppXml::Session.new(cl_trid: cl_trid, cl_trid_prefix: cl_trid_prefix)
end