Module: Nfcom::Helpers::Consulta
- Defined in:
- lib/nfcom/helpers/consulta.rb
Class Method Summary collapse
-
.chave_from_xml(xml) ⇒ String
Optional: parse the chave from a full XML string.
-
.url(chave:, ambiente: Nfcom.configuration.ambiente) ⇒ String
Returns the URL to confirm an already-authorized NFCom.
Class Method Details
.chave_from_xml(xml) ⇒ String
Optional: parse the chave from a full XML string
22 23 24 25 |
# File 'lib/nfcom/helpers/consulta.rb', line 22 def self.chave_from_xml(xml) doc = Nokogiri::XML(xml) doc.at_xpath('//NFCom/infNFCom/@Id')&.value&.sub(/^NFCom/, '') end |
.url(chave:, ambiente: Nfcom.configuration.ambiente) ⇒ String
Returns the URL to confirm an already-authorized NFCom
11 12 13 14 15 16 |
# File 'lib/nfcom/helpers/consulta.rb', line 11 def self.url(chave:, ambiente: Nfcom.configuration.ambiente) raise ArgumentError, 'Chave de acesso inválida' unless chave&.length == 44 tp_amb = (ambiente == :producao ? 1 : 2) "https://dfe-portal.svrs.rs.gov.br/nfcom/qrcode?chNFCom=#{chave}&tpAmb=#{tp_amb}" end |