Class: CompaniesHouseInputGateway::XmlFormsBinder

Inherits:
Object
  • Object
show all
Defined in:
lib/companies_house_input_gateway/xml_forms_binder.rb

Instance Method Summary collapse

Constructor Details

#initialize(request_type, config, request_data = {}) ⇒ XmlFormsBinder

Returns a new instance of XmlFormsBinder.



5
6
7
8
9
# File 'lib/companies_house_input_gateway/xml_forms_binder.rb', line 5

def initialize(request_type, config, request_data = {})
  @request_type = request_type
  @request_data = request_data
  @config = config
end

Instance Method Details

#build_request_xml(submission_form, transaction_id = (Time.now.to_f * 100).to_i) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/companies_house_input_gateway/xml_forms_binder.rb', line 11

def build_request_xml(submission_form, transaction_id = (Time.now.to_f * 100).to_i)
  # transaction_id = (Time.now.to_f * 100).to_i
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.GovTalkMessage(header_namespace) do
      xml.EnvelopeVersion '1.0'
      xml.Header do
        message_details(xml, request_type, transaction_id)
        sender_authentication(xml)
      end
      xml.GovTalkDetails do
        xml.Keys
      end
      xml.Body do
        build_form(xml, request_type, @request_data, submission_form)
      end
    end
  end
  builder.doc
end