Class: SEFAZ::Webservice::NFE::Auditor
- Inherits:
-
Object
- Object
- SEFAZ::Webservice::NFE::Auditor
- Defined in:
- lib/sefaz/webservice/nfe/auditor.rb
Overview
Auditor de XML pelo validador público da Tecnospeed
Instance Method Summary collapse
- #exec(openTimeout, readTimeout) ⇒ Object
-
#initialize(xml) ⇒ Auditor
constructor
A new instance of Auditor.
Constructor Details
#initialize(xml) ⇒ Auditor
Returns a new instance of Auditor.
9 10 11 |
# File 'lib/sefaz/webservice/nfe/auditor.rb', line 9 def initialize(xml) @xml = xml end |
Instance Method Details
#exec(openTimeout, readTimeout) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sefaz/webservice/nfe/auditor.rb', line 13 def exec(openTimeout, readTimeout) uri = URI("https://validadornfe.tecnospeed.com.br/validar") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.open_timeout = openTimeout http.read_timeout = readTimeout content = Net::HTTP::Post.new(uri.request_uri) content.set_form_data(txtXML: @xml) response = http.request(content) if response.code == "200" url = JSON(response.body)["url"] url_esc = url.to_s.sub("{", "%7B").sub("}", "%7D") txt_uri = URI(url_esc) body = CGI.unescape(Net::HTTP.get(txt_uri)) return [:ok, JSON(body)] end return [:error, {}] end |