class Nfe::Services::Regress::RetEvento

Attributes

id[RW]
signature[RW]

Public Instance Methods

parse!(xml) click to toggle source
# File lib/nfe/services/regress/retEvento.rb, line 30
def parse!(xml)
  doc = Nokogiri::XML(xml)

  parse_elements doc

  if doc.css("infEvento").attribute("Id").present?
    @id = doc.css("infEvento").attribute("Id").text
  end

  signature = doc.xpath("//ds:Signature", ds: Models::Signature.namespace)
  @signature.parse!(signature.to_xml) if signature.present?
end
to_xml() click to toggle source
# File lib/nfe/services/regress/retEvento.rb, line 43
def to_xml
  xml = Builder::XmlMarkup.new

  xml.retEvento(versao: versao) do |root|
    attributes = {}
    attributes[:Id] = id if id.present?

    root.infEvento(attributes) do |node|
      add_elements node
    end
  end

  xml.target!
end