rillow 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +10 -0
  2. data/lib/rillow.rb +13 -6
  3. data/lib/rillow_helper.rb +32 -0
  4. metadata +3 -2
data/README CHANGED
@@ -1,6 +1,16 @@
1
1
  # This api is created by Leo Chan on 10/29/2007.
2
2
  # There is no license requirement. Use it or copy any part of the code that you want to use.
3
+ # Use it at your own risk. I am not liable for anything. Just want to share it and hope it is useful for you
3
4
  # Rillow is a simple ruby wrapper to zillow webservice api: http://www.zillow.com/howto/api/APIOverview.htm
4
5
  # It does the web service call and gets the result back for you. You don't have to know about the url request formate, url encoding or
5
6
  # parsing the result. The result object is in hash/array format. So no need to parse xml.
6
7
  # You will need to register with zillow to get the Zillow Web Service Identifier first.
8
+ # Go to http://rubyforge.org/projects/rillow/ for project details or to download the latest release
9
+ # Installation:
10
+ # gem install rillow
11
+ # Example code:
12
+ # require 'rubygems'
13
+ # require 'rillow'
14
+ # rillow = Rillow.new('your-zillow-key')
15
+ # result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
16
+ # result.to_hash
@@ -3,9 +3,11 @@ require 'net/http'
3
3
  require 'uri'
4
4
  require 'rubygems'
5
5
  require 'xmlsimple'
6
+ require 'rillow_helper'
6
7
 
7
8
  # This api is created by Leo Chan on 10/29/2007.
8
9
  # There is no license requirement. Use it or copy any part of the code that you want to use.
10
+ # Use it at your own risk. I am not liable for anything. Just want to share what I wrote. Hopefully you will find it useful.
9
11
  # Rillow is a simple ruby wrapper to zillow webservice api: http://www.zillow.com/howto/api/APIOverview.htm
10
12
  # It does the web service call and gets the result back for you. You don't have to know about the url request, url encoding or
11
13
  # parsing the result. The result object is in hash/array format. So no need to parsse xml.
@@ -16,6 +18,8 @@ require 'xmlsimple'
16
18
  # Example:
17
19
  # rillow = Rillow.new('your-zillow-service identifier')
18
20
  # result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
21
+ # result.to_hash
22
+ # result.find_attribute 'valudationRange'
19
23
  class Rillow
20
24
  @@zillow_webservice_url='http://www.zillow.com/webservice/'
21
25
 
@@ -259,12 +263,6 @@ class Rillow
259
263
  #and Zestimate for the comparable properties and the principal property for which the comparables are being retrieved.
260
264
  #This API call also returns rich property data for the comparables.
261
265
  #see: http://www.zillow.com/howto/api/GetDeepComps.htm
262
-
263
- def get_deep_comps(zpid,count)
264
- url_s=@@zillow_webservice_url+'GetDeepComps.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&count='+count.to_s
265
- fetch_result(url_s)
266
- end
267
-
268
266
  #parameters:
269
267
  #zpid The Zillow Property ID for the property for which to obtain information; the parameter type is an integer
270
268
  #count The number of comparable recent sales to obtain
@@ -272,10 +270,19 @@ class Rillow
272
270
  # rillow = Rillow.new('your-zillow-service identifier')
273
271
  # result = rillow.get_deep_comps('48749425',5)
274
272
  # result.to_hash
273
+ def get_deep_comps(zpid,count)
274
+ url_s=@@zillow_webservice_url+'GetDeepComps.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&count='+count.to_s
275
+ fetch_result(url_s)
276
+ end
277
+
275
278
  private
276
279
  def fetch_result(url_s)
277
280
  url = URI.parse(URI.escape(url_s))
278
281
  res = Net::HTTP.get_response(url)
279
282
  doc = XmlSimple.xml_in res.body
283
+ class<<doc
284
+ include RillowHelper
285
+ end
286
+ return doc
280
287
  end
281
288
  end
@@ -0,0 +1,32 @@
1
+ module RillowHelper
2
+ # The find_attribute helper method is to provide a easy eay to find a attribute within the hash and array
3
+ # Examples:
4
+ # rillow = Rillow.new ('your-zillow-service identifier')
5
+ # result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
6
+ # valuationRange = result.find_attribute 'valuationRange'
7
+ def find_attribute(key,obj=nil)
8
+ if obj==nil then
9
+ obj=self
10
+ end
11
+ if obj.is_a? Hash then
12
+ obj.each { |k,v|
13
+ if k==key then
14
+ return v
15
+ else
16
+ result = find_attribute(key,v)
17
+ if result != nil then
18
+ return result
19
+ end
20
+ end
21
+ }
22
+ elsif obj.is_a? Array then
23
+ obj.each {|o|
24
+ result = find_attribute(key,o)
25
+ if result != nil then
26
+ return result
27
+ end
28
+ }
29
+ end
30
+ return nil
31
+ end
32
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rillow
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-10-30 00:00:00 -04:00
6
+ version: 0.2.0
7
+ date: 2007-12-31 00:00:00 -05:00
8
8
  summary: Ruby wrapper api to the Zillow webservice api
9
9
  require_paths:
10
10
  - lib
@@ -30,6 +30,7 @@ authors:
30
30
  - Leo Chan
31
31
  files:
32
32
  - lib/rillow.rb
33
+ - lib/rillow_helper.rb
33
34
  - README
34
35
  test_files: []
35
36