Class: RealPage::Utils::RequestGenerator
- Inherits:
-
Object
- Object
- RealPage::Utils::RequestGenerator
- Defined in:
- lib/real_page/utils/request_generator.rb
Overview
Generate a SOAP request for a specific action and sections
Constant Summary collapse
- ENVELOPE =
{ 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:tem' => 'http://tempuri.org/' }.freeze
Instance Method Summary collapse
-
#body ⇒ String
The XML request for the specified action and sections.
- #headers ⇒ Object
-
#initialize(soap_action, sections) ⇒ RequestGenerator
constructor
A new instance of RequestGenerator.
Constructor Details
#initialize(soap_action, sections) ⇒ RequestGenerator
Returns a new instance of RequestGenerator.
17 18 19 20 |
# File 'lib/real_page/utils/request_generator.rb', line 17 def initialize(soap_action, sections) @soap_action = soap_action @sections = sections end |
Instance Method Details
#body ⇒ String
Returns the XML request for the specified action and sections.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/real_page/utils/request_generator.rb', line 23 def body Nokogiri::XML::Builder.new do |xml_builder| xml_builder.Envelope(ENVELOPE) do namespace = xml_builder.parent.namespace_definitions.first xml_builder.parent.namespace = namespace xml_builder['soapenv'].Header xml_builder['soapenv'].Body do xml_builder['tem'].send(soap_action.downcase) do sections.each do |section| section.generate(xml_builder['tem']) end end end end end.to_xml end |
#headers ⇒ Object
40 41 42 43 44 45 |
# File 'lib/real_page/utils/request_generator.rb', line 40 def headers { 'Content-Type' => 'text/xml; charset=utf-8', 'SOAPAction' => "http://tempuri.org/IRPXService/#{soap_action.downcase}" } end |