Class: WalkscoreApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/walkscore/client.rb

Constant Summary collapse

BASE_URL =
'http://api.walkscore.com'

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
9
# File 'lib/walkscore/client.rb', line 7

def initialize
  @connection = Faraday.new(BASE_URL)
end

Instance Method Details

#make_connection(location, api_key) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/walkscore/client.rb', line 11

def make_connection(location, api_key)
  response = @connection.get do |req|
    req.url '/score'
    req.headers['Accepts'] = 'application/json'
    req.params['format'] = 'json'
    req.params['lat'] = location[:lat]
    req.params['lon'] = location[:long]
    req.params['wsapikey'] = api_key
  end
  response.body
end