rentjuicer 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/rentjuicer/listing.rb +18 -0
- data/lib/rentjuicer/listings.rb +10 -1
- data/lib/rentjuicer.rb +1 -0
- data/rentjuicer.gemspec +6 -2
- data/spec/rentjuicer/listing_spec.rb +15 -0
- data/spec/rentjuicer/listings_spec.rb +47 -5
- data/spec/responses/mls_listings.json +1719 -0
- metadata +13 -2
data/README.rdoc
CHANGED
@@ -158,7 +158,7 @@ and add require 'rentjuicer_extensions' to your config/environment.rb file.
|
|
158
158
|
Now you can call @results.properties.first.neighborhood_list to get a nice comma separated list of neighborhood names.
|
159
159
|
This class allows you to create any methods you want on a listing.
|
160
160
|
|
161
|
-
|
161
|
+
==== The second group returns Rentjuicer::Listing responses
|
162
162
|
|
163
163
|
:find_by_id - takes a rentjuice_id for a listing and returns a Rentjuicer::Listing if the property is found or nil if it is not found
|
164
164
|
@property = @listings.find_by_id(18830) # returns either nil or a Rentjuicer::Listing
|
@@ -167,11 +167,31 @@ These methods just return a Rentjuicer::Listing or an array of Rentjuicer::Listi
|
|
167
167
|
These methods work by making subsequent calls to go through the pagination of the results for you and compaction each request into a single array. Use these methods only when absolutely necessary as they are expensive to use as they will make repeated api calls through the entire set of pages, so if there are 20 listings per page and 571 pages, this will make 29 api requests which is obviously quite time consuming.
|
168
168
|
|
169
169
|
:find_all - take a hash of search params (same as :search above) and returns every result on every page of the response in an array
|
170
|
-
:find_all_by_ids - takes a comma separated string of rentjuice_ids and returns every listing in an array
|
170
|
+
:find_all_by_ids - takes a comma separated string OR an array of rentjuice_ids and returns every listing in an array
|
171
171
|
|
172
172
|
@results = @listings.find_all(:neighborhoods => 'Boston') # returns an array of every listing in Boston in a single array - no need for pagination
|
173
173
|
@results = @listings.find_all_by_ids('200306,200221,200214,200121,199646,198560,197542,197540,197538) # returns an array of all of those listings that can be found
|
174
174
|
|
175
|
+
==== Searching MLS listings
|
176
|
+
|
177
|
+
Rentjuice provides the option to return MLS listings for your account if you pass the include_mls=1 argument to the search.
|
178
|
+
|
179
|
+
Rentjuicer adds some extra methods to the Rentjuicer::Listings::SearchResponse and Rentjuicer::Listing for working with the mls listings from Rentjuice due to the requirement that you display the attribution for each property.
|
180
|
+
|
181
|
+
These attributions are typically in the following format:
|
182
|
+
|
183
|
+
"This listing courtesy of Holly Kampler at Classic Realty<br \/><br \/>The property listing data and information, or the Images, set forth herein were provided to MLS Property Information Network, Inc. from third party sources, including sellers, lessors and public records, and were compiled by MLS Property Information Network, Inc. The property listing data and information, and the Images, are for the personal, non-commercial use of consumers having a good faith interest in purchasing or leasing listed properties of the type displayed to them and may not be used for any purpose other than to identify prospective properties which such consumers may have a good faith interest in purchasing or leasing. MLS Property Information Network, Inc. and its subscribers disclaim any and all representations and warranties as to the accuracy of the property listing data and information, or as to the accuracy of any of the Images, set forth herein."
|
184
|
+
|
185
|
+
===== On Rentjuicer::Listing we have added the following methods:
|
186
|
+
|
187
|
+
:mls_listing? - return true if the listing has a #source_type and that #source_type == 'mls' (as opposed to internal)
|
188
|
+
:courtesy_of - returns the first half the attribution string after being split on the '<br /><br />'
|
189
|
+
:mls_disclaimer - returns the second half the attribution string after being split on the '<br /><br />'
|
190
|
+
|
191
|
+
===== On Rentjuicer::Listings::SearchResponse we have added the following methods:
|
192
|
+
|
193
|
+
:mls_results? - return true if and listing in the #properties array is a mls_listing (uses #mls_listing? on the listing)
|
194
|
+
:mls_disclaimers - returns a array of the uniq #mls_disclaimer responses off the listings in the #properties array
|
175
195
|
|
176
196
|
== Note on Patches/Pull Requests
|
177
197
|
|
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ begin
|
|
10
10
|
gem.email = "tom.cocca@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/tcocca/rentjuicer"
|
12
12
|
gem.authors = ["tcocca"]
|
13
|
+
gem.add_dependency "activesupport", '~> 2.3'
|
13
14
|
gem.add_dependency "httparty", ">= 0.6.1"
|
14
15
|
gem.add_dependency "hashie", ">= 0.4.0"
|
15
16
|
gem.add_dependency "rash", ">= 0.2.0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/lib/rentjuicer/listing.rb
CHANGED
@@ -53,5 +53,23 @@ module Rentjuicer
|
|
53
53
|
self.neighborhoods.first unless neighborhoods.blank?
|
54
54
|
end
|
55
55
|
|
56
|
+
def mls_listing?
|
57
|
+
source_type && source_type == "mls"
|
58
|
+
end
|
59
|
+
|
60
|
+
def mls_disclaimer
|
61
|
+
attribution_split[1] if mls_listing?
|
62
|
+
end
|
63
|
+
|
64
|
+
def courtesy_of
|
65
|
+
attribution_split[0] if mls_listing?
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def attribution_split
|
71
|
+
@attribution_parts ||= attribution.split('<br /><br />')
|
72
|
+
end
|
73
|
+
|
56
74
|
end
|
57
75
|
end
|
data/lib/rentjuicer/listings.rb
CHANGED
@@ -46,8 +46,9 @@ module Rentjuicer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def find_all_by_ids(listing_ids)
|
49
|
+
listing_ids = listing_ids.split(',') if listing_ids.is_a?(String)
|
49
50
|
all_listings = []
|
50
|
-
listing_ids.
|
51
|
+
listing_ids.in_groups_of(500, false).each do |group|
|
51
52
|
group.delete_if{|x| x.nil?}
|
52
53
|
all_listings << find_all(:rentjuice_id => group.join(','))
|
53
54
|
end
|
@@ -72,6 +73,14 @@ module Rentjuicer
|
|
72
73
|
props
|
73
74
|
end
|
74
75
|
|
76
|
+
def mls_results?
|
77
|
+
properties.any?{|property| property.mls_listing?}
|
78
|
+
end
|
79
|
+
|
80
|
+
def mls_disclaimers
|
81
|
+
properties.collect{|property| property.mls_disclaimer}.compact.uniq
|
82
|
+
end
|
83
|
+
|
75
84
|
def paginator
|
76
85
|
paginator_cache if paginator_cache
|
77
86
|
self.paginator_cache = WillPaginate::Collection.create(
|
data/lib/rentjuicer.rb
CHANGED
data/rentjuicer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rentjuicer}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["tcocca"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-08}
|
13
13
|
s.description = %q{Ruby API wrapper for rentjuice.com built with httparty}
|
14
14
|
s.email = %q{tom.cocca@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
"spec/responses/lead.json",
|
52
52
|
"spec/responses/lead_error.json",
|
53
53
|
"spec/responses/listings.json",
|
54
|
+
"spec/responses/mls_listings.json",
|
54
55
|
"spec/responses/neighborhoods.json",
|
55
56
|
"spec/responses/no_listings.json",
|
56
57
|
"spec/spec.opts",
|
@@ -81,6 +82,7 @@ Gem::Specification.new do |s|
|
|
81
82
|
s.specification_version = 3
|
82
83
|
|
83
84
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
85
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 2.3"])
|
84
86
|
s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
|
85
87
|
s.add_runtime_dependency(%q<hashie>, [">= 0.4.0"])
|
86
88
|
s.add_runtime_dependency(%q<rash>, [">= 0.2.0"])
|
@@ -88,6 +90,7 @@ Gem::Specification.new do |s|
|
|
88
90
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
89
91
|
s.add_development_dependency(%q<webmock>, [">= 1.3.4"])
|
90
92
|
else
|
93
|
+
s.add_dependency(%q<activesupport>, ["~> 2.3"])
|
91
94
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
92
95
|
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
93
96
|
s.add_dependency(%q<rash>, [">= 0.2.0"])
|
@@ -96,6 +99,7 @@ Gem::Specification.new do |s|
|
|
96
99
|
s.add_dependency(%q<webmock>, [">= 1.3.4"])
|
97
100
|
end
|
98
101
|
else
|
102
|
+
s.add_dependency(%q<activesupport>, ["~> 2.3"])
|
99
103
|
s.add_dependency(%q<httparty>, [">= 0.6.1"])
|
100
104
|
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
101
105
|
s.add_dependency(%q<rash>, [">= 0.2.0"])
|
@@ -94,4 +94,19 @@ describe Rentjuicer::Listing do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
context "mls_listing" do
|
98
|
+
before do
|
99
|
+
@listing = Rentjuicer::Listing.new(valid_listing_rash.merge({
|
100
|
+
"source_type" => "mls",
|
101
|
+
"source_name" => "MLS PIN",
|
102
|
+
"attribution" => "This listing courtesy of Holly Kampler at Classic Realty<br \/><br \/>The property listing data and information, or the Images, set forth herein were provided to MLS Property Information Network, Inc. from third party sources, including sellers, lessors and public records, and were compiled by MLS Property Information Network, Inc. The property listing data and information, and the Images, are for the personal, non-commercial use of consumers having a good faith interest in purchasing or leasing listed properties of the type displayed to them and may not be used for any purpose other than to identify prospective properties which such consumers may have a good faith interest in purchasing or leasing. MLS Property Information Network, Inc. and its subscribers disclaim any and all representations and warranties as to the accuracy of the property listing data and information, or as to the accuracy of any of the Images, set forth herein."
|
103
|
+
}))
|
104
|
+
end
|
105
|
+
|
106
|
+
it { @listing.mls_listing?.should be_true }
|
107
|
+
it { @listing.source_name.should == "MLS PIN" }
|
108
|
+
it { @listing.attribution.should == "This listing courtesy of Holly Kampler at Classic Realty<br \/><br \/>The property listing data and information, or the Images, set forth herein were provided to MLS Property Information Network, Inc. from third party sources, including sellers, lessors and public records, and were compiled by MLS Property Information Network, Inc. The property listing data and information, and the Images, are for the personal, non-commercial use of consumers having a good faith interest in purchasing or leasing listed properties of the type displayed to them and may not be used for any purpose other than to identify prospective properties which such consumers may have a good faith interest in purchasing or leasing. MLS Property Information Network, Inc. and its subscribers disclaim any and all representations and warranties as to the accuracy of the property listing data and information, or as to the accuracy of any of the Images, set forth herein."}
|
109
|
+
it { @listing.courtesy_of.should == "This listing courtesy of Holly Kampler at Classic Realty"}
|
110
|
+
it { @listing.mls_disclaimer.should == "The property listing data and information, or the Images, set forth herein were provided to MLS Property Information Network, Inc. from third party sources, including sellers, lessors and public records, and were compiled by MLS Property Information Network, Inc. The property listing data and information, and the Images, are for the personal, non-commercial use of consumers having a good faith interest in purchasing or leasing listed properties of the type displayed to them and may not be used for any purpose other than to identify prospective properties which such consumers may have a good faith interest in purchasing or leasing. MLS Property Information Network, Inc. and its subscribers disclaim any and all representations and warranties as to the accuracy of the property listing data and information, or as to the accuracy of any of the Images, set forth herein."}
|
111
|
+
end
|
97
112
|
end
|
@@ -38,6 +38,27 @@ describe Rentjuicer::Listing do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
context "mls_search" do
|
42
|
+
before do
|
43
|
+
mock_get('/listings.json', 'mls_listings.json', {
|
44
|
+
:include_mls => "1",
|
45
|
+
:order_by => "rent",
|
46
|
+
:order_direction => "asc"
|
47
|
+
})
|
48
|
+
@result = @listings.search(:include_mls => "1")
|
49
|
+
end
|
50
|
+
|
51
|
+
context "search response" do
|
52
|
+
it { @result.mls_results?.should be_true }
|
53
|
+
|
54
|
+
it "should return an array of uniq property mls_disclaimers" do
|
55
|
+
@result.mls_disclaimers.should == [
|
56
|
+
"The property listing data and information, or the Images, set forth herein were provided to MLS Property Information Network, Inc. from third party sources, including sellers, lessors and public records, and were compiled by MLS Property Information Network, Inc. The property listing data and information, and the Images, are for the personal, non-commercial use of consumers having a good faith interest in purchasing or leasing listed properties of the type displayed to them and may not be used for any purpose other than to identify prospective properties which such consumers may have a good faith interest in purchasing or leasing. MLS Property Information Network, Inc. and its subscribers disclaim any and all representations and warranties as to the accuracy of the property listing data and information, or as to the accuracy of any of the Images, set forth herein."
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
41
62
|
context "find_by_id" do
|
42
63
|
before do
|
43
64
|
mock_get('/listings.json', 'find_by_id.json', {
|
@@ -99,12 +120,33 @@ describe Rentjuicer::Listing do
|
|
99
120
|
@properties = @listings.find_all_by_ids(@find_ids.join(','))
|
100
121
|
end
|
101
122
|
|
102
|
-
|
123
|
+
context "passing a string of ids" do
|
124
|
+
before do
|
125
|
+
@properties = @listings.find_all_by_ids(@find_ids.join(','))
|
126
|
+
end
|
127
|
+
|
128
|
+
it { @properties.should be_kind_of(Array) }
|
129
|
+
|
130
|
+
it "should only return properties for requested ids" do
|
131
|
+
@property_ids = @properties.collect{|p| p.rentjuice_id}
|
132
|
+
@find_ids.each do |id|
|
133
|
+
@property_ids.should include(id)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
103
137
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
138
|
+
context "passing an array of ids" do
|
139
|
+
before do
|
140
|
+
@properties = @listings.find_all_by_ids(@find_ids)
|
141
|
+
end
|
142
|
+
|
143
|
+
it { @properties.should be_kind_of(Array) }
|
144
|
+
|
145
|
+
it "should only return properties for requested ids" do
|
146
|
+
@property_ids = @properties.collect{|p| p.rentjuice_id}
|
147
|
+
@find_ids.each do |id|
|
148
|
+
@property_ids.should include(id)
|
149
|
+
end
|
108
150
|
end
|
109
151
|
end
|
110
152
|
end
|