Class: Nfe::Services::Dispatch::EnviNFe

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Helpers::XmlModel::NfeModel
Defined in:
lib/nfe/services/dispatch/enviNFe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::XmlModel::NfeModel

#add_elements, #check_present, included, #parse!, #parse_elements, #present?, #validate_optional_attributes, #validate_required_attributes

Constructor Details

#initialize(nfe, lote, version) ⇒ EnviNFe

Returns a new instance of EnviNFe.



19
20
21
22
23
# File 'lib/nfe/services/dispatch/enviNFe.rb', line 19

def initialize(nfe, lote, version)
  @nfe = nfe
  @lote = lote
  @versao = version
end

Instance Attribute Details

#loteObject

Returns the value of attribute lote.



8
9
10
# File 'lib/nfe/services/dispatch/enviNFe.rb', line 8

def lote
  @lote
end

#nfeObject

Returns the value of attribute nfe.



8
9
10
# File 'lib/nfe/services/dispatch/enviNFe.rb', line 8

def nfe
  @nfe
end

#versaoObject

Returns the value of attribute versao.



8
9
10
# File 'lib/nfe/services/dispatch/enviNFe.rb', line 8

def versao
  @versao
end

Instance Method Details

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/nfe/services/dispatch/enviNFe.rb', line 25

def to_xml
  xml = Builder::XmlMarkup.new

  xml.enviNFe(xmlns: Models::NFe.namespace, versao: versao) do |env|

    env.idLote @lote

    env.indSinc SYNCHRONOUS

    env << @nfe.to_xml
  end

  xml.target!
end