Sha256: 0359afb4072dfd04ef9c0ac87dbe86098fdcb62292bf5956ba4ab4e91174724d
Contents?: true
Size: 733 Bytes
Versions: 1
Compression:
Stored size: 733 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", :intervalor => "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 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.1 | lib/correios/sro/web_service.rb |