Class: ZillowApi::Client

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

Constant Summary collapse

BASE_URL =
'http://www.zillow.com'

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



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

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

Instance Method Details

#get_city_data(location, api_key) ⇒ Object



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

def get_city_data(location, api_key)
  response = @connection.get do |req|
    req.url "/webservice/GetDemographics.htm"
    req.headers['Accepts'] = 'application/xml'
    req.params['zws-id']   = api_key
    req.params['state']    = location[:state]
    req.params['city']     = location[:city]
  end
  response.body
end