Class: Ticketbai::Documents::ApiPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/ticketbai/documents/api_payload.rb

Constant Summary collapse

ROOT_NAME_MAPPING =
{
  issuance: 'lrpjfecsgap:LROEPJ240FacturasEmitidasConSGAltaPeticion',
  annulment: 'lrpjfecsgap:LROEPJ240FacturasEmitidasConSGAnulacionPeticion',
  issuance_unsigned: 'lrpjfecsgap:LROEPJ240FacturasEmitidasSinSGAltaModifPeticion'
}.freeze
SCHEME_MAPPING =
{
  issuance: 'https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PJ_240_1_1_FacturasEmitidas_ConSG_AltaPeticion_V1_0_2.xsd',
  annulment: 'https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PJ_240_1_1_FacturasEmitidas_ConSG_AnulacionPeticion_V1_0_0.xsd',
  issuance_unsigned: 'https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PJ_240_1_2_FacturasEmitidas_SinSG_AltaModifPeticion_V1_0_1.xsd'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ ApiPayload

Returns a new instance of ApiPayload.

Parameters:



20
21
22
23
24
# File 'lib/ticketbai/documents/api_payload.rb', line 20

def initialize(**args)
  @lroe_header = args[:lroe_header]
  @lroe_issued_invoices = args[:lroe_issued_invoices]
  @operation = args[:operation]
end

Instance Method Details

#createNokogiri::XML::Builder

Returns:

  • (Nokogiri::XML::Builder)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ticketbai/documents/api_payload.rb', line 27

def create
  builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
    xml.ROOT_NAME('xmlns:lrpjfecsgap' => SCHEME_MAPPING[@operation]) do
      @lroe_header.build_xml(xml)
      @lroe_issued_invoices.build_xml(xml)
    end
  end

  modify_xml_root_name(builder)

  builder.to_xml
end