class SacspGateway::Connection
Public Class Methods
new()
click to toggle source
# File lib/sacsp_gateway/connection.rb, line 8 def initialize @conn = Faraday.new(:url => 'http://sac.prefeitura.sp.gov.br') do |faraday| faraday.request :url_encoded faraday.response :logger faraday.use :cookie_jar faraday.use FaradayMiddleware::FollowRedirects, limit: 3 faraday.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses faraday.adapter Faraday.default_adapter end #@conn.headers[:user_agent] = 'SACSP::Gateway v0.0.1' # substituir versao aqui @conn end
Public Instance Methods
get(path)
click to toggle source
# File lib/sacsp_gateway/connection.rb, line 26 def get(path) response = @conn.get(path) doc = Nokogiri::HTML(response.body) end
post(path, data)
click to toggle source
# File lib/sacsp_gateway/connection.rb, line 21 def post(path, data) response = @conn.post(path, data) Nokogiri::HTML(response.body) end