Class: CompaniesHouseInputGateway::Forms::FormSubmission

Inherits:
FormAbstractBuilder show all
Defined in:
lib/companies_house_input_gateway/forms/form_submission.rb

Instance Attribute Summary

Attributes inherited from FormAbstractBuilder

#data, #xml

Instance Method Summary collapse

Methods inherited from FormAbstractBuilder

#generate_xml_from_incoming_data, #initialize

Constructor Details

This class inherits a constructor from CompaniesHouseInputGateway::Forms::FormAbstractBuilder

Instance Method Details

#build_form(request_type, requested_form = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/companies_house_input_gateway/forms/form_submission.rb', line 6

def build_form(request_type, requested_form = nil)
  FormValidator.validate(data, Util.demodulize(self.class))

  xml.FormSubmission(submission_namespace) do
    form_header(xml, request_type, data)
    xml.DateSigned data[:date_signed] # "2015-07-01"
    xml.Form do
      requested_form.build_form(request_type, xml)
    end
  end
end

#form_header(root_xml, request_type, data) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/companies_house_input_gateway/forms/form_submission.rb', line 27

def form_header(root_xml, request_type, data)
  root_xml.FormHeader do
    root_xml.CompanyNumber data[:company_number]
    root_xml.CompanyName data[:company_name]
    root_xml.CompanyAuthenticationCode data[:company_authentication_code]
    root_xml.PackageReference data[:package_reference]
    root_xml.FormIdentifier Util.camelize(request_type)
    root_xml.SubmissionNumber data[:submission_number]
  end
end

#submission_namespaceObject



18
19
20
21
22
23
24
25
# File 'lib/companies_house_input_gateway/forms/form_submission.rb', line 18

def submission_namespace
  {
    'xmlns' => 'http://xmlgw.companieshouse.gov.uk/Header',
    'xmlns:bs' => 'http://xmlgw.companieshouse.gov.uk',
    'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
    'xsi:schemaLocation' => 'http://xmlgw.companieshouse.gov.uk/Header http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/FormSubmission-v2-9.xsd'
  }
end