zillow4r 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/Gemfile +18 -0
  2. data/Gemfile.lock +23 -0
  3. data/README.md +69 -0
  4. data/Rakefile +53 -0
  5. data/VERSION +1 -0
  6. data/lib/zillow4r.rb +49 -0
  7. data/lib/zillow4r/api.rb +25 -0
  8. data/lib/zillow4r/api/base.rb +5 -0
  9. data/lib/zillow4r/api/chart.rb +12 -0
  10. data/lib/zillow4r/api/comps.rb +13 -0
  11. data/lib/zillow4r/api/deep_comps.rb +13 -0
  12. data/lib/zillow4r/api/deep_search_results.rb +12 -0
  13. data/lib/zillow4r/api/demographics.rb +38 -0
  14. data/lib/zillow4r/api/region_chart.rb +12 -0
  15. data/lib/zillow4r/api/region_children.rb +14 -0
  16. data/lib/zillow4r/api/search_results.rb +12 -0
  17. data/lib/zillow4r/api/updated_property_details.rb +52 -0
  18. data/lib/zillow4r/api/zestimate.rb +15 -0
  19. data/lib/zillow4r/models.rb +189 -0
  20. data/test/fixtures/chart.xml +19 -0
  21. data/test/fixtures/comps.xml +189 -0
  22. data/test/fixtures/deep_comps.xml +536 -0
  23. data/test/fixtures/deep_search_results.xml +102 -0
  24. data/test/fixtures/demographics.xml +849 -0
  25. data/test/fixtures/region_chart.xml +18 -0
  26. data/test/fixtures/region_children.xml +868 -0
  27. data/test/fixtures/search_results.xml +91 -0
  28. data/test/fixtures/updated_property_details.xml +75 -0
  29. data/test/fixtures/zestimate.xml +93 -0
  30. data/test/test_helper.rb +26 -0
  31. data/test/unit/chart_test.rb +18 -0
  32. data/test/unit/comps_test.rb +50 -0
  33. data/test/unit/deep_comps_test.rb +50 -0
  34. data/test/unit/deep_search_results_test.rb +28 -0
  35. data/test/unit/demographics_test.rb +39 -0
  36. data/test/unit/region_chart_test.rb +18 -0
  37. data/test/unit/region_children_test.rb +41 -0
  38. data/test/unit/search_results_test.rb +28 -0
  39. data/test/unit/updated_property_details_test.rb +65 -0
  40. data/test/unit/zestimate_test.rb +52 -0
  41. data/zillow4r.gemspec +105 -0
  42. metadata +183 -0
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class RegionChartTest < ZillowTest
4
+
5
+ def test_webservice_url
6
+ path = Zillow4r.build_path(Zillow4r::Api::RegionChart, "unit-type" => "percent", :city => "seattle", :state => "WA", :width => 300, :height => 150)
7
+ assert_equal("/webservice/GetRegionChart.htm?zws-id=TEST_ZWS_ID&unit-type=percent&city=seattle&state=WA&width=300&height=150", path)
8
+ end
9
+
10
+ def test_parsing
11
+ # mock response
12
+ mock_http_response("region_chart.xml")
13
+
14
+ response = Zillow4r.fetch_region_chart("unit-type" => "percent", :city => "seattle", :state => "WA", :width => 300, :height => 150)
15
+ assert_equal("http://www.zillow.com/app?chartDuration=1year&chartType=partner&cityRegionId=5470&countyRegionId=0&height=150&nationRegionId=0&page=webservice%2FGetRegionChart&service=chart&showCity=true&showPercent=true&stateRegionId=0&width=300&zipRegionId=0", response.chart_url)
16
+ end
17
+
18
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class RegionChildrenTest < ZillowTest
4
+
5
+ def test_webservice_url
6
+ path = Zillow4r.build_path(Zillow4r::Api::RegionChildren, :city => "seattle", :state => "WA", :childtype => "neighborhood")
7
+ assert_equal("/webservice/GetRegionChildren.htm?zws-id=TEST_ZWS_ID&city=seattle&state=WA&childtype=neighborhood", path)
8
+ end
9
+
10
+ def test_parsing
11
+ # mock response
12
+ mock_http_response("region_children.xml")
13
+
14
+ response = Zillow4r.fetch_region_children(:city => "seattle", :state => "WA", :childtype => "neighborhood")
15
+
16
+ assert_equal("neighborhood", response.subregion_type)
17
+
18
+ # test region
19
+ region = response.region
20
+ assert(region)
21
+ assert_equal(Zillow4r::Region, region.class)
22
+ assert_equal(16037, region.id)
23
+ assert_equal("Washington", region.state)
24
+ assert_equal("Seattle", region.city)
25
+ assert_equal(47.590955, region.latitude)
26
+ assert_equal(-122.382608, region.longitude)
27
+
28
+ # test children
29
+ children = response.children
30
+ assert(children.is_a?(Array))
31
+ assert_equal(106, children.length)
32
+ children.each do |child|
33
+ assert_equal(Zillow4r::Region, child.class)
34
+ assert(child.name)
35
+ assert(child.url)
36
+ assert(child.latitude)
37
+ assert(child.longitude)
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class SearchResultsTest < ZillowTest
4
+
5
+ def test_webservice_url
6
+ path = Zillow4r.build_path(Zillow4r::Api::SearchResults, :address => "2114 Bigelow Ave", :citystatezip => "Seattle, WA")
7
+ assert_equal("/webservice/GetSearchResults.htm?zws-id=TEST_ZWS_ID&address=2114+Bigelow+Ave&citystatezip=Seattle%2C+WA", path)
8
+ end
9
+
10
+ def test_parsing
11
+ # mock response
12
+ mock_http_response("search_results.xml")
13
+
14
+ response = Zillow4r.fetch_search_results(:address => "2114 Bigelow Ave", :citystatezip => "Seattle, WA")
15
+
16
+ # test results
17
+ results = response.results
18
+ assert_equal(1, results.length)
19
+
20
+ result = results.first
21
+ assert_equal(Zillow4r::Property, result.class)
22
+ assert_equal(48749425, result.zpid)
23
+ assert(result.links.links.length > 0)
24
+ assert(result.address.street)
25
+ assert(result.zestimate.amount)
26
+ end
27
+
28
+ end
@@ -0,0 +1,65 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class UpdatedPropertyDetailsTest < ZillowTest
4
+
5
+ def test_webservice_url
6
+ path = Zillow4r.build_path(Zillow4r::Api::UpdatedPropertyDetails, :zpid => 48749425)
7
+ assert_equal("/webservice/GetUpdatedPropertyDetails.htm?zws-id=TEST_ZWS_ID&zpid=48749425", path)
8
+ end
9
+
10
+ def test_parsing
11
+ # mock response
12
+ mock_http_response("updated_property_details.xml")
13
+
14
+ response = Zillow4r.fetch_updated_property_details(:zpid => 48749425)
15
+
16
+ assert_equal(172, response.page_view_count_month)
17
+ assert_equal(4149, response.page_view_count_total)
18
+ assert_equal("2114 Bigelow Ave N", response.address.street)
19
+
20
+ # test posting
21
+ posting = response.posting
22
+ assert_equal(Zillow4r::Posting, posting.class)
23
+ assert_equal("John Blacksmith", posting.agent_name)
24
+ assert_equal("/profile/John.Blacksmith", posting.agent_profile_url)
25
+ assert_equal("Lake and Company Real Estate", posting.brokerage)
26
+ assert_equal("For sale by agent", posting.type)
27
+ assert_equal("2008-06-05 10:28:00.0", posting.last_updated_date)
28
+ assert_equal("http://mls.lakere.com/srch_mls/detail.php?mode=ag&LN=28097669&t=listings&l=", posting.external_url)
29
+ assert_equal(28097669, posting.mls)
30
+
31
+ assert_equal(1290000, response.price)
32
+ assert_equal("USD", response.price_currency)
33
+
34
+ assert(response.links.links.length > 0)
35
+ assert(response.images.images.length > 0)
36
+
37
+ # test facts
38
+ assert_equal("Single family", response.use_code)
39
+ assert_equal(4, response.bedrooms)
40
+ assert_equal(3.0, response.bathrooms)
41
+ assert_equal(3470, response.finished_sq_ft)
42
+ assert_equal(4680, response.lot_sq_ft)
43
+ assert_equal(1924, response.year_built)
44
+ assert_equal(2003, response.year_updated)
45
+ assert_equal(2, response.floors)
46
+ assert_equal("Finished", response.basement)
47
+ assert_equal("Composition", response.roof)
48
+ assert_equal("Water, City, Mountain", response.view)
49
+ assert_equal("Off-street", response.parking_type)
50
+ assert_equal("Gas", response.heating_sources)
51
+ assert_equal("Forced air", response.heating_system)
52
+ assert_equal("Dishwasher, Dryer, Freezer, Garbage disposal, Microwave, Range / Oven, Refrigerator, Washer", response.appliances)
53
+ assert_equal("Hardwood, Carpet, Tile", response.floor_covering)
54
+ assert_equal("Laundry room, Walk-in closet, Master bath, Office, Dining room, Family room, Breakfast nook", response.rooms)
55
+
56
+ # test general info
57
+ assert_equal("Bright, spacious, 4 bedroom/3 bath Craftsman, with stunning, expansive views, on one of Queen Anne's finest streets. Views of Lk Union, Lk Washington,the Cascades from Mt. Baker to Mt. Rainier, and the city-from two levels and 2 view decks. Craftsman charm intact: hardwood floors, cove moldings, crystal doorknobs, Batchelder tile fireplace. Huge gourmet eat-in kitchen with slab granite countertops, deluxe master suite, theater-like media room, level rear yard with garden space and covered patio.", response.home_description)
58
+ assert_equal("Queen Anne", response.neighborhood)
59
+ assert_equal("Seattle", response.school_district)
60
+ assert_equal("John Hay", response.elementary_school)
61
+ assert_equal("McClure", response.middle_school)
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class ZestimateTest < ZillowTest
4
+
5
+ def test_webservice_url
6
+ path = Zillow4r.build_path(Zillow4r::Api::Zestimate, :zpid => 48749425)
7
+ assert_equal("/webservice/GetZestimate.htm?zws-id=TEST_ZWS_ID&zpid=48749425", path)
8
+ end
9
+
10
+ def test_parsing
11
+ # mock response
12
+ mock_http_response("zestimate.xml")
13
+
14
+ response = Zillow4r.fetch_zestimate(:zpid => 48749425)
15
+
16
+ assert_equal(0, response.response_code)
17
+ assert_equal("Request successfully processed", response.response_message)
18
+
19
+ # check the zestimate data
20
+ zestimate = response.zestimate
21
+ assert(zestimate)
22
+ assert_equal(Zillow4r::Zestimate, zestimate.class)
23
+
24
+ assert_equal(1219500, zestimate.amount)
25
+ assert_equal("USD", zestimate.amount_currency)
26
+ assert_equal("11/03/2009", zestimate.last_updated)
27
+
28
+ assert_equal(-41500, zestimate.value_change)
29
+ assert_equal("30", zestimate.value_change_duration)
30
+ assert_equal("USD", zestimate.value_change_currency)
31
+
32
+ assert_equal(1024380, zestimate.valuation_low)
33
+ assert_equal("USD", zestimate.valuation_low_currency)
34
+ assert_equal(1378035, zestimate.valuation_high)
35
+ assert_equal("USD", zestimate.valuation_high_currency)
36
+
37
+ assert_equal(95, zestimate.percentile)
38
+
39
+ # check the address data
40
+ address = response.address
41
+ assert(address)
42
+ assert_equal(Zillow4r::Address, address.class)
43
+
44
+ assert_equal("2114 Bigelow Ave N", address.street)
45
+ assert_equal("98109", address.zipcode)
46
+ assert_equal("Seattle", address.city)
47
+ assert_equal("WA", address.state)
48
+ assert_equal(47.63793, address.latitude)
49
+ assert_equal(-122.347936, address.longitude)
50
+ end
51
+
52
+ end
data/zillow4r.gemspec ADDED
@@ -0,0 +1,105 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{zillow4r}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jeff Ching"]
12
+ s.date = %q{2010-12-15}
13
+ s.description = %q{Simple ruby interface for the Zillow API. See http://www.zillow.com/howto/api/APIOverview.htm}
14
+ s.email = %q{ching.jeff@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/zillow4r.rb",
25
+ "lib/zillow4r/api.rb",
26
+ "lib/zillow4r/api/base.rb",
27
+ "lib/zillow4r/api/chart.rb",
28
+ "lib/zillow4r/api/comps.rb",
29
+ "lib/zillow4r/api/deep_comps.rb",
30
+ "lib/zillow4r/api/deep_search_results.rb",
31
+ "lib/zillow4r/api/demographics.rb",
32
+ "lib/zillow4r/api/region_chart.rb",
33
+ "lib/zillow4r/api/region_children.rb",
34
+ "lib/zillow4r/api/search_results.rb",
35
+ "lib/zillow4r/api/updated_property_details.rb",
36
+ "lib/zillow4r/api/zestimate.rb",
37
+ "lib/zillow4r/models.rb",
38
+ "test/fixtures/chart.xml",
39
+ "test/fixtures/comps.xml",
40
+ "test/fixtures/deep_comps.xml",
41
+ "test/fixtures/deep_search_results.xml",
42
+ "test/fixtures/demographics.xml",
43
+ "test/fixtures/region_chart.xml",
44
+ "test/fixtures/region_children.xml",
45
+ "test/fixtures/search_results.xml",
46
+ "test/fixtures/updated_property_details.xml",
47
+ "test/fixtures/zestimate.xml",
48
+ "test/test_helper.rb",
49
+ "test/unit/chart_test.rb",
50
+ "test/unit/comps_test.rb",
51
+ "test/unit/deep_comps_test.rb",
52
+ "test/unit/deep_search_results_test.rb",
53
+ "test/unit/demographics_test.rb",
54
+ "test/unit/region_chart_test.rb",
55
+ "test/unit/region_children_test.rb",
56
+ "test/unit/search_results_test.rb",
57
+ "test/unit/updated_property_details_test.rb",
58
+ "test/unit/zestimate_test.rb",
59
+ "zillow4r.gemspec"
60
+ ]
61
+ s.homepage = %q{http://github.com/chingor13/zillow4r}
62
+ s.licenses = ["MIT"]
63
+ s.require_paths = ["lib"]
64
+ s.rubygems_version = %q{1.3.7}
65
+ s.summary = %q{Simple ruby interface for the Zillow API}
66
+ s.test_files = [
67
+ "test/test_helper.rb",
68
+ "test/unit/chart_test.rb",
69
+ "test/unit/comps_test.rb",
70
+ "test/unit/deep_comps_test.rb",
71
+ "test/unit/deep_search_results_test.rb",
72
+ "test/unit/demographics_test.rb",
73
+ "test/unit/region_chart_test.rb",
74
+ "test/unit/region_children_test.rb",
75
+ "test/unit/search_results_test.rb",
76
+ "test/unit/updated_property_details_test.rb",
77
+ "test/unit/zestimate_test.rb"
78
+ ]
79
+
80
+ if s.respond_to? :specification_version then
81
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
82
+ s.specification_version = 3
83
+
84
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
86
+ s.add_development_dependency(%q<mocha>, [">= 0"])
87
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
88
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
89
+ s.add_development_dependency(%q<rcov>, [">= 0"])
90
+ else
91
+ s.add_dependency(%q<nokogiri>, [">= 0"])
92
+ s.add_dependency(%q<mocha>, [">= 0"])
93
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
94
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
95
+ s.add_dependency(%q<rcov>, [">= 0"])
96
+ end
97
+ else
98
+ s.add_dependency(%q<nokogiri>, [">= 0"])
99
+ s.add_dependency(%q<mocha>, [">= 0"])
100
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
101
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
102
+ s.add_dependency(%q<rcov>, [">= 0"])
103
+ end
104
+ end
105
+
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zillow4r
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jeff Ching
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-15 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: nokogiri
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: mocha
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 1
55
+ - 0
56
+ - 0
57
+ version: 1.0.0
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: jeweler
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 5
71
+ - 1
72
+ version: 1.5.1
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: rcov
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: *id005
89
+ description: Simple ruby interface for the Zillow API. See http://www.zillow.com/howto/api/APIOverview.htm
90
+ email: ching.jeff@gmail.com
91
+ executables: []
92
+
93
+ extensions: []
94
+
95
+ extra_rdoc_files:
96
+ - README.md
97
+ files:
98
+ - Gemfile
99
+ - Gemfile.lock
100
+ - README.md
101
+ - Rakefile
102
+ - VERSION
103
+ - lib/zillow4r.rb
104
+ - lib/zillow4r/api.rb
105
+ - lib/zillow4r/api/base.rb
106
+ - lib/zillow4r/api/chart.rb
107
+ - lib/zillow4r/api/comps.rb
108
+ - lib/zillow4r/api/deep_comps.rb
109
+ - lib/zillow4r/api/deep_search_results.rb
110
+ - lib/zillow4r/api/demographics.rb
111
+ - lib/zillow4r/api/region_chart.rb
112
+ - lib/zillow4r/api/region_children.rb
113
+ - lib/zillow4r/api/search_results.rb
114
+ - lib/zillow4r/api/updated_property_details.rb
115
+ - lib/zillow4r/api/zestimate.rb
116
+ - lib/zillow4r/models.rb
117
+ - test/fixtures/chart.xml
118
+ - test/fixtures/comps.xml
119
+ - test/fixtures/deep_comps.xml
120
+ - test/fixtures/deep_search_results.xml
121
+ - test/fixtures/demographics.xml
122
+ - test/fixtures/region_chart.xml
123
+ - test/fixtures/region_children.xml
124
+ - test/fixtures/search_results.xml
125
+ - test/fixtures/updated_property_details.xml
126
+ - test/fixtures/zestimate.xml
127
+ - test/test_helper.rb
128
+ - test/unit/chart_test.rb
129
+ - test/unit/comps_test.rb
130
+ - test/unit/deep_comps_test.rb
131
+ - test/unit/deep_search_results_test.rb
132
+ - test/unit/demographics_test.rb
133
+ - test/unit/region_chart_test.rb
134
+ - test/unit/region_children_test.rb
135
+ - test/unit/search_results_test.rb
136
+ - test/unit/updated_property_details_test.rb
137
+ - test/unit/zestimate_test.rb
138
+ - zillow4r.gemspec
139
+ has_rdoc: true
140
+ homepage: http://github.com/chingor13/zillow4r
141
+ licenses:
142
+ - MIT
143
+ post_install_message:
144
+ rdoc_options: []
145
+
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ hash: 3794204408486395298
154
+ segments:
155
+ - 0
156
+ version: "0"
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ requirements: []
166
+
167
+ rubyforge_project:
168
+ rubygems_version: 1.3.7
169
+ signing_key:
170
+ specification_version: 3
171
+ summary: Simple ruby interface for the Zillow API
172
+ test_files:
173
+ - test/test_helper.rb
174
+ - test/unit/chart_test.rb
175
+ - test/unit/comps_test.rb
176
+ - test/unit/deep_comps_test.rb
177
+ - test/unit/deep_search_results_test.rb
178
+ - test/unit/demographics_test.rb
179
+ - test/unit/region_chart_test.rb
180
+ - test/unit/region_children_test.rb
181
+ - test/unit/search_results_test.rb
182
+ - test/unit/updated_property_details_test.rb
183
+ - test/unit/zestimate_test.rb