Class: Nfe::Services::Regress::ProtNFe
- Inherits:
-
Object
- Object
- Nfe::Services::Regress::ProtNFe
- Includes:
- ActiveModel::Model
- Defined in:
- lib/nfe/services/regress/protNFe.rb
Instance Attribute Summary collapse
-
#chNFe ⇒ Object
Returns the value of attribute chNFe.
-
#cStat ⇒ Object
Returns the value of attribute cStat.
-
#dhRecbto ⇒ Object
Returns the value of attribute dhRecbto.
-
#digVal ⇒ Object
Returns the value of attribute digVal.
-
#id ⇒ Object
Returns the value of attribute id.
-
#nProt ⇒ Object
Returns the value of attribute nProt.
-
#tpAmb ⇒ Object
Returns the value of attribute tpAmb.
-
#verAplic ⇒ Object
Returns the value of attribute verAplic.
-
#versao ⇒ Object
Returns the value of attribute versao.
-
#xMotivo ⇒ Object
Returns the value of attribute xMotivo.
Instance Method Summary collapse
Instance Attribute Details
#chNFe ⇒ Object
Returns the value of attribute chNFe.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def chNFe @chNFe end |
#cStat ⇒ Object
Returns the value of attribute cStat.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def cStat @cStat end |
#dhRecbto ⇒ Object
Returns the value of attribute dhRecbto.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def dhRecbto @dhRecbto end |
#digVal ⇒ Object
Returns the value of attribute digVal.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def digVal @digVal end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def id @id end |
#nProt ⇒ Object
Returns the value of attribute nProt.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def nProt @nProt end |
#tpAmb ⇒ Object
Returns the value of attribute tpAmb.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def tpAmb @tpAmb end |
#verAplic ⇒ Object
Returns the value of attribute verAplic.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def verAplic @verAplic end |
#versao ⇒ Object
Returns the value of attribute versao.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def versao @versao end |
#xMotivo ⇒ Object
Returns the value of attribute xMotivo.
7 8 9 |
# File 'lib/nfe/services/regress/protNFe.rb', line 7 def xMotivo @xMotivo end |
Instance Method Details
#parse!(xml) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nfe/services/regress/protNFe.rb', line 10 def parse!(xml) doc = Nokogiri::XML(xml) @versao = doc.root.attribute("versao").text if doc.css("infProt").attribute("Id").present? @id = doc.css("infProt").attribute("Id").text end @tpAmb = doc.css("infProt > tpAmb").text @verAplic = doc.css("infProt > verAplic").text @chNFe = doc.css("infProt > chNFe").text @dhRecbto = DateTime.strptime(doc.css("infProt > dhRecbto").text, "%Y-%m-%dT%H:%M:%S%:z") @nProt = doc.css("infProt > nProt").text @digVal = doc.css("infProt > digVal").text @cStat = doc.css("infProt > cStat").text.to_i @xMotivo = doc.css("infProt > xMotivo").text end |
#to_xml ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nfe/services/regress/protNFe.rb', line 29 def to_xml xml = Builder::XmlMarkup.new xml.protNFe(versao: versao) do |root| attributes = {} attributes[:Id] = @id if @id.present? root.infProt(attributes) do |node| node.tpAmb @tpAmb node.verAplic @verAplic node.chNFe @chNFe node.dhRecbto @dhRecbto.strftime("%Y-%m-%dT%H:%M:%S%:z") node.nProt @nProt node.digVal @digVal node.cStat @cStat node.xMotivo @xMotivo end end xml.target! end |