Class: GlobalSign::RequestXmlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/global_sign/request_xml_builder.rb

Defined Under Namespace

Modules: XmlNamespace

Class Method Summary collapse

Class Method Details

.build_xml(action:, params:) ⇒ Object



11
12
13
14
15
16
# File 'lib/global_sign/request_xml_builder.rb', line 11

def build_xml(action:, params:)
  xml = xml_envelope(action).at('//Request') << xml_body(params).root.elements

  builder = Nokogiri::XML::Builder.with(xml)
  builder.doc.root.to_xml
end

.xml_body(params) ⇒ Object



34
35
36
37
38
# File 'lib/global_sign/request_xml_builder.rb', line 34

def xml_body(params)
  Nokogiri.XML(params.to_xml) do |configuration|
    configuration.default_xml.noblanks
  end
end

.xml_envelope(action) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/global_sign/request_xml_builder.rb', line 18

def xml_envelope(action)
  Nokogiri::XML(
    "<soap:Envelope xmlns:soap=\\\"\#{XmlNamespace::BODY}\\\" xmlns:ns2=\\\"\#{XmlNamespace::ACTION}\\\">\n  <soap:Body>\n    <ns2:\#{action}>\n<Request/>\n    </ns2:\#{action}>\n  </soap:Body>\n</soap:Envelope>\n    EOS\n  ) do |configuration|\n    configuration.default_xml.noblanks\n  end\nend\n"