Class: ZATCA::UBL::Builder

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/zatca/ubl/builder.rb

Instance Method Summary collapse

Instance Method Details

#build(canonicalized: false, spaces: 4, apply_invoice_hacks: false, remove_root_xml_tag: false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zatca/ubl/builder.rb', line 6

def build(
  canonicalized: false,
  spaces: 4,
  apply_invoice_hacks: false,
  remove_root_xml_tag: false
)
  @remove_root_xml_tag = remove_root_xml_tag

  builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
    element.build_xml(xml)
  end

  xml = if canonicalized
    canonicalized_xml(builder: builder)
  else
    uncanonicalized_xml(builder: builder, spaces: spaces)
  end

  xml = apply_hacks_to_invoice(element, xml) if apply_invoice_hacks

  xml
end