class Rome2rio::Connection

Public Class Methods

new(opts = {}) click to toggle source
# File lib/rome2rio/connection.rb, line 3
def initialize(opts = {})
  @apikey = opts[:apikey]
  @endpoint = opts[:endpoint] || "http://free.rome2rio.com"
end

Public Instance Methods

encode_params(params) click to toggle source
# File lib/rome2rio/connection.rb, line 16
def encode_params(params)
  URI.encode_www_form(params)
end
handle_response(response) click to toggle source
# File lib/rome2rio/connection.rb, line 8
def handle_response(response)
  if response.status == 200
    SearchResponse.new(MultiJson.decode(response.body))
  else
    {:status => response.status, :body => response.body}
  end
end