Class: Ticketbai::Nodes::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/ticketbai/nodes/receiver.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Receiver

ID TYPES 02: NIF-IVA 03: Pasaporte 04: Documento oficial de identificacion expedido por el pais o territorio de residencia 05: Certificado de residencia 06: Otro documento probatorio



11
12
13
14
15
# File 'lib/ticketbai/nodes/receiver.rb', line 11

def initialize(args = {})
  @receiver_country = args[:receiver_country]
  @receiver_nif = args[:receiver_nif]
  @receiver_name = args[:receiver_name]
end

Instance Method Details

#build_xml(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ticketbai/nodes/receiver.rb', line 17

def build_xml(node)
  node = Nokogiri::XML::Builder.new if node.nil?
  node.Destinatarios do |xml|
    xml.IDDestinatario do
      if @receiver_country == 'ES'
        xml.NIF @receiver_nif
      else
        xml.IDOtro do
          xml.CodigoPais @receiver_country
          xml.IDType '04'
          xml.ID @receiver_nif
        end
      end
      xml.ApellidosNombreRazonSocial @receiver_name
    end
  end
end