class Nfe::Services::Regress::ProtNFe
Attributes
cStat[RW]
chNFe[RW]
dhRecbto[RW]
digVal[RW]
id[RW]
nProt[RW]
tpAmb[RW]
verAplic[RW]
versao[RW]
xMotivo[RW]
Public Instance Methods
parse!(xml)
click to toggle source
# 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()
click to toggle source
# 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