Sha256: 955727a4752006f7405d060ce089d000de4974f34ff27c4f3a9d545aa91874dc
Contents?: true
Size: 771 Bytes
Versions: 1
Compression:
Stored size: 771 Bytes
Contents
# encoding: UTF-8 require 'net/http' require 'uri' module Correios module SRO class WebService URL = "http://websro.correios.com.br/sro_bin/sroii_xml.eventos" TYPES = { :lista => "L", :intervalo => "F" } RESULTS = { :todos => "T", :ultimo => "U" } def initialize @uri = URI.parse(URL) end def request(sro) response = Net::HTTP.post_form(@uri, params_for(sro)) response.body.backward_encode("UTF-8", "ISO-8859-1") end private def params_for(sro) { :Usuario => sro.usuario, :Senha => sro.senha, :Tipo => TYPES[sro.tipo], :Resultado => RESULTS[sro.resultado], :Objetos => sro.objetos.join } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
correios-sro-xml-0.0.3 | lib/correios/sro/web_service.rb |