street_easy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +196 -5
- data/lib/street_easy/client.rb +39 -0
- data/lib/street_easy/property.rb +129 -0
- data/lib/street_easy/version.rb +1 -1
- data/spec/spec_helper.rb +0 -0
- data/spec/street_easy_helper.rb +0 -0
- data/street_easy-0.0.1.gem +0 -0
- data/street_easy.gemspec +2 -1
- metadata +12 -7
- data/.gitignore +0 -22
- data/Rakefile +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f91bc2036044cd7a42439fa7b9a9f2b2c1f93ba
|
4
|
+
data.tar.gz: a12321d5522f71e1dc1f61662f275b1a08559c8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d338eb2ffd03abd65f33c8ae2974a55dc89d5a716a4059de4638af018234b2a4d685e978273d6884d5348325779794049abb4690b10a99cac4d455b27a6518
|
7
|
+
data.tar.gz: 4dc52e8804cfef54a1f5c9f7796d7ab0e6c4740cfb5904effda95249dd6a753417c123efccd79b1f4fa47e219d305f26ea1fc109550912028f771fd1c9f6fbdf
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
# StreetEasy
|
1
|
+
# StreetEasy API Gem
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
A little gem tha integrates with the Street Easy API (beta).
|
6
|
+
|
7
|
+
API Documentation available [here](http://streeteasy.com/api/info).
|
2
8
|
|
3
|
-
TODO: Write a gem description
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -16,13 +21,199 @@ Or install it yourself as:
|
|
16
21
|
|
17
22
|
$ gem install street_easy
|
18
23
|
|
19
|
-
##
|
24
|
+
## Set Up
|
25
|
+
|
26
|
+
First, register for an API key [here](http://streeteasy.com/api/info).
|
27
|
+
|
28
|
+
Then, place this code somewhere in your ruby environment.
|
29
|
+
|
30
|
+
require 'street_easy'
|
31
|
+
|
32
|
+
add your API key to the client:
|
33
|
+
|
34
|
+
StreetEasy::Client.api_key = 'your_api_key'
|
35
|
+
|
36
|
+
## Property
|
37
|
+
|
38
|
+
The `StreatEasy::Property` object has the following methods:
|
39
|
+
|
40
|
+
* .rentals
|
41
|
+
* .sales
|
42
|
+
* .order(order_type)
|
43
|
+
* .neighborhoods(list_of_neighborhoods)
|
44
|
+
* .options(list_of_options)
|
45
|
+
* .limit(int)
|
46
|
+
* .all
|
47
|
+
|
48
|
+
|
49
|
+
### Examples
|
50
|
+
* return the `200` `:most_expensive` `rentals` in all of `'nyc'` (note, the API maxes out at 200)
|
51
|
+
```ruby
|
52
|
+
properties = StreetEasy::Property.all
|
53
|
+
# or
|
54
|
+
properties = StreetEasy::Property.rentals.all
|
55
|
+
# or
|
56
|
+
properties = StreetEasy::Property.rentals.order(:most_expensive).all
|
57
|
+
```
|
58
|
+
* return the `200` `:most_expensive` `sales` in all of `'nyc'` (note, the API maxes out at 200)
|
20
59
|
|
21
|
-
|
60
|
+
```ruby
|
61
|
+
properties = StreetEasy::Property.sales.all
|
62
|
+
#or
|
63
|
+
properties = StreetEasy::Property.sales.order(:most_expensive).all
|
64
|
+
```
|
65
|
+
* return the `12` `:least_expensive` `rentals` in all of `'nyc'`.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
properties = StreetEasy::Property.order(:least_expensive).limit(12)
|
69
|
+
```
|
70
|
+
|
71
|
+
* return the `30` `:least_expensive` `rentals` in `'soho'`.
|
72
|
+
```ruby
|
73
|
+
properties = StreetEasy::Property.neighborhoods('soho').order(:least_expensive).limit(30)
|
74
|
+
```
|
75
|
+
* return the `newest` `rentals` in both `'soho'` AND `'murray-hill'` (limit 200)
|
76
|
+
```ruby
|
77
|
+
properties = StreetEasy::Property.neighborhoods('soho', 'murray-hill').order(:newest).all
|
78
|
+
# or
|
79
|
+
properties = StreetEasy::Property.neighborhoods(['soho', 'murray-hill']).order(:newest).all
|
80
|
+
```
|
81
|
+
|
82
|
+
* return the `30` `:least_expensive` `sales` in `'soho'`, `'murray hill'`, and the `'lower-east-side'`, but only return their `:price`, `:area_name`, `:description`, and `:floorplan`
|
83
|
+
```ruby
|
84
|
+
properties = StreetEasy::Property.sales
|
85
|
+
.neighborhoods('soho', 'murray-hill', 'lower-east-side')
|
86
|
+
.options(:price, :area_name, :description, :floorplan)
|
87
|
+
.order(:least_expensive)
|
88
|
+
.limit(30)
|
89
|
+
```
|
90
|
+
|
91
|
+
### full list of neighborhoods:
|
92
|
+
```ruby
|
93
|
+
'battery-park-city'
|
94
|
+
'chelsea'
|
95
|
+
'west-chelsea'
|
96
|
+
'chinatown'
|
97
|
+
'two-bridges'
|
98
|
+
'civic-center'
|
99
|
+
'east-village'
|
100
|
+
'financial-district'
|
101
|
+
'fulton/seaport'
|
102
|
+
'flatiron'
|
103
|
+
'nomad'
|
104
|
+
'gramercy-park'
|
105
|
+
'greenwich-village'
|
106
|
+
'noho'
|
107
|
+
'little-italy'
|
108
|
+
'lower-east-side'
|
109
|
+
'nolita'
|
110
|
+
'soho'
|
111
|
+
'stuyvesant-town/pcv'
|
112
|
+
'tribeca'
|
113
|
+
'west-village'
|
114
|
+
'all-midtown'
|
115
|
+
'central-park-south'
|
116
|
+
'midtown'
|
117
|
+
'midtown-east'
|
118
|
+
'kips-bay'
|
119
|
+
'murray-hill'
|
120
|
+
'sutton-place'
|
121
|
+
'turtle-bay'
|
122
|
+
'beekman'
|
123
|
+
'midtown-south'
|
124
|
+
'midtown-west'
|
125
|
+
'roosevelt-island'
|
126
|
+
'all-upper-east-side'
|
127
|
+
'carnegie-hill'
|
128
|
+
'lenox-hill'
|
129
|
+
'upper-carnegie-hill'
|
130
|
+
'upper-east-side'
|
131
|
+
'yorkville'
|
132
|
+
'all-upper-west-side'
|
133
|
+
'lincoln-square'
|
134
|
+
'manhattan-valley'
|
135
|
+
'morningside-heights'
|
136
|
+
'upper-west-side'
|
137
|
+
'all-upper-manhattan'
|
138
|
+
'central-harlem'
|
139
|
+
'east-harlem'
|
140
|
+
'hamilton-heights'
|
141
|
+
'inwood'
|
142
|
+
'manhattanville'
|
143
|
+
'washington-heights'
|
144
|
+
'fort-george'
|
145
|
+
'hudson-heights'
|
146
|
+
'west-harlem'
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
### list of .order options
|
151
|
+
```ruby
|
152
|
+
:most_expensive # default
|
153
|
+
:least_expensive
|
154
|
+
:newest
|
155
|
+
```
|
156
|
+
|
157
|
+
### list of .option parameters
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
|
161
|
+
# default attributes
|
162
|
+
:title
|
163
|
+
:area_name
|
164
|
+
:price
|
165
|
+
:bedrooms
|
166
|
+
:bathrooms
|
167
|
+
:size_sqft
|
168
|
+
:url
|
169
|
+
:medium_image_uri
|
170
|
+
|
171
|
+
# additional attributes
|
172
|
+
:source_label
|
173
|
+
:clean_address
|
174
|
+
:description
|
175
|
+
:half_baths
|
176
|
+
:rooms_description
|
177
|
+
:addr_street
|
178
|
+
:addr_unit
|
179
|
+
:normalized_addr_unit
|
180
|
+
:addr_city
|
181
|
+
:addr_lat
|
182
|
+
:addr_lon
|
183
|
+
:size_sqft_num
|
184
|
+
:lot_size
|
185
|
+
:size_description
|
186
|
+
:ppsf
|
187
|
+
:ppsf_num
|
188
|
+
:ppsf_description
|
189
|
+
:created_at
|
190
|
+
:unit_type
|
191
|
+
:unit_type_label
|
192
|
+
:status
|
193
|
+
:price_cur
|
194
|
+
:floorplan
|
195
|
+
:open_house_start
|
196
|
+
:open_house_end
|
197
|
+
:sourceid
|
198
|
+
```
|
22
199
|
|
23
200
|
## Contributing
|
24
201
|
|
25
|
-
|
202
|
+
PLEASE CONTRIBUTE! This is my first ruby gem, and my first contribution to the open source movement! Therefore, there's a lot of room for improvement :)
|
203
|
+
|
204
|
+
TODO:
|
205
|
+
* tests (oh the travis-ci!)
|
206
|
+
* error handling
|
207
|
+
* refactor
|
208
|
+
* add other classes like `StreetEasy::NeighborhoodData`, `StreetEasy::Geo`, and others.
|
209
|
+
|
210
|
+
THOUGHTS:
|
211
|
+
* extract `StreetEasy::Property` into `StreetEasy::Property::Rental` and `StreetEasy::Property::Sale`?
|
212
|
+
* return objects instead of hashes?
|
213
|
+
* add a `.first` method? Other methods?
|
214
|
+
* don't implement method chaining?
|
215
|
+
|
216
|
+
1. Fork it ( https://github.com/cblokker/street_easy/fork )
|
26
217
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
218
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
219
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module StreetEasy
|
2
|
+
class Client
|
3
|
+
BASE_URI = "http://www.streeteasy.com/nyc/api/"
|
4
|
+
|
5
|
+
def self.api_key
|
6
|
+
@api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.api_key=(key)
|
10
|
+
@api_key = key
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.construct_url(query)
|
14
|
+
uri = URI(
|
15
|
+
"#{BASE_URI}" +
|
16
|
+
"#{query[:property_type]}/" +
|
17
|
+
"search?criteria=" +
|
18
|
+
"area=#{query[:neighborhoods]}&" +
|
19
|
+
"limit=#{query[:limit]}&" +
|
20
|
+
"order=#{query[:order]}&" +
|
21
|
+
"key=#{@api_key}&" +
|
22
|
+
"format=json"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.construct_url(query)
|
27
|
+
uri = URI(
|
28
|
+
"#{BASE_URI}" +
|
29
|
+
"#{query[:property_type]}/" +
|
30
|
+
"search?criteria=" +
|
31
|
+
"area=#{query[:neighborhoods]}&" +
|
32
|
+
"limit=#{query[:limit]}&" +
|
33
|
+
"order=#{query[:order]}&" +
|
34
|
+
"key=#{@api_key}&" +
|
35
|
+
"format=json"
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module StreetEasy
|
5
|
+
class Property < Client
|
6
|
+
@property_type = 'rentals'
|
7
|
+
@options = [
|
8
|
+
:title,
|
9
|
+
:area_name,
|
10
|
+
:price,
|
11
|
+
:bedrooms,
|
12
|
+
:bathrooms,
|
13
|
+
:size_sqft,
|
14
|
+
:url
|
15
|
+
]
|
16
|
+
|
17
|
+
|
18
|
+
OPTIONS = [
|
19
|
+
:title,
|
20
|
+
:area_name,
|
21
|
+
:price,
|
22
|
+
:bedrooms,
|
23
|
+
:bathrooms,
|
24
|
+
:size_sqft,
|
25
|
+
:url,
|
26
|
+
:medium_image_uri,
|
27
|
+
|
28
|
+
:source_label,
|
29
|
+
:clean_address,
|
30
|
+
:description,
|
31
|
+
:half_baths,
|
32
|
+
:rooms_description,
|
33
|
+
:addr_street,
|
34
|
+
:addr_unit,
|
35
|
+
:normalized_addr_unit,
|
36
|
+
:addr_city,
|
37
|
+
:addr_lat,
|
38
|
+
:addr_lon,
|
39
|
+
:size_sqft_num,
|
40
|
+
:lot_size,
|
41
|
+
:size_description,
|
42
|
+
:ppsf,
|
43
|
+
:ppsf_num,
|
44
|
+
:ppsf_description,
|
45
|
+
:created_at,
|
46
|
+
:unit_type,
|
47
|
+
:unit_type_label,
|
48
|
+
:status,
|
49
|
+
:price_cur,
|
50
|
+
:floorplan,
|
51
|
+
:open_house_start,
|
52
|
+
:open_house_end,
|
53
|
+
:sourceid
|
54
|
+
]
|
55
|
+
|
56
|
+
class << self
|
57
|
+
def neighborhoods(*neighborhood)
|
58
|
+
@neighborhoods = neighborhood.join(',') if neighborhood.kind_of?(Array)
|
59
|
+
@neighborhoods = neighborhood if neighborhood.kind_of?(String)
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def rentals
|
64
|
+
@property_type = 'rentals'
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
def sales
|
69
|
+
@property_type = 'sales'
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
def options(*options)
|
74
|
+
@options = options.kind_of?(Array) ? options.flatten : options
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
def order(sort_type)
|
79
|
+
case sort_type
|
80
|
+
when :most_expensive then @sort_type = "price_desc"
|
81
|
+
when :least_expensive then @sort_type = "price_asc"
|
82
|
+
when :newest then @sort_type = "listed_desc"
|
83
|
+
end
|
84
|
+
self
|
85
|
+
end
|
86
|
+
|
87
|
+
def limit(limit)
|
88
|
+
@limit = limit
|
89
|
+
generate_properties
|
90
|
+
end
|
91
|
+
|
92
|
+
def all
|
93
|
+
@limit = 200 # the api limit
|
94
|
+
generate_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def generate_properties
|
99
|
+
parsed_reply = get_parsed_reply
|
100
|
+
properties = []
|
101
|
+
|
102
|
+
(0..@limit - 1).each do |i|
|
103
|
+
break if parsed_reply['listings'][i] == nil
|
104
|
+
rental = {}
|
105
|
+
OPTIONS.each do |option|
|
106
|
+
rental[option] = parsed_reply['listings'][i][option.to_s] if @options.include?(option)
|
107
|
+
end
|
108
|
+
|
109
|
+
properties << rental
|
110
|
+
end
|
111
|
+
|
112
|
+
properties
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def get_parsed_reply
|
117
|
+
uri = StreetEasy::Client.construct_url({
|
118
|
+
property_type: @property_type,
|
119
|
+
neighborhoods: @neighborhoods,
|
120
|
+
limit: @limit,
|
121
|
+
order: @sort_type
|
122
|
+
})
|
123
|
+
|
124
|
+
reply = uri.read
|
125
|
+
parsed_reply = JSON.parse(reply)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/lib/street_easy/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
File without changes
|
File without changes
|
Binary file
|
data/street_easy.gemspec
CHANGED
@@ -9,7 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Chase Blokker"]
|
10
10
|
spec.email = ["chaseblokker@yahoo.com"]
|
11
11
|
spec.summary = %q{A ruby wrapper for the street easy API}
|
12
|
-
spec.
|
12
|
+
spec.description = %q{A ruby wrapper for the street easy API}
|
13
|
+
spec.homepage = "https://rubygems.org/gems/street_easy"
|
13
14
|
spec.license = "MIT"
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: street_easy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chase Blokker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -52,22 +52,25 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: A ruby wrapper for the street easy API
|
56
56
|
email:
|
57
57
|
- chaseblokker@yahoo.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- .gitignore
|
63
62
|
- Gemfile
|
64
63
|
- LICENSE.txt
|
65
64
|
- README.md
|
66
|
-
- Rakefile
|
67
65
|
- lib/street_easy.rb
|
66
|
+
- lib/street_easy/client.rb
|
67
|
+
- lib/street_easy/property.rb
|
68
68
|
- lib/street_easy/version.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
- spec/street_easy_helper.rb
|
71
|
+
- street_easy-0.0.1.gem
|
69
72
|
- street_easy.gemspec
|
70
|
-
homepage:
|
73
|
+
homepage: https://rubygems.org/gems/street_easy
|
71
74
|
licenses:
|
72
75
|
- MIT
|
73
76
|
metadata: {}
|
@@ -91,4 +94,6 @@ rubygems_version: 2.2.2
|
|
91
94
|
signing_key:
|
92
95
|
specification_version: 4
|
93
96
|
summary: A ruby wrapper for the street easy API
|
94
|
-
test_files:
|
97
|
+
test_files:
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/street_easy_helper.rb
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
require 'rake/testtask'
|
4
|
-
Rake::TestTask.new do |test|
|
5
|
-
test.libs << 'lib' << 'test'
|
6
|
-
test.ruby_opts << "-rubygems"
|
7
|
-
test.pattern = 'test/**/*_test.rb'
|
8
|
-
test.verbose = true
|
9
|
-
end
|
10
|
-
|
11
|
-
# test/helper.rb
|
12
|
-
require 'street_easy'
|
13
|
-
require 'minitest/spec'
|
14
|
-
require 'minitest/autorun'
|
15
|
-
|