mls 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ Listings provided by 42Floors.com.
5
5
 
6
6
  *home* - https://mls.42floors.com
7
7
 
8
- *docs* - The best way to get this is to run `rake docs`. We plan to upload this
8
+ *docs* - http://docs.42floors.com
9
9
 
10
10
  *bugs* - https://github.com/42floors/mls/issues
11
11
 
data/lib/mls.rb CHANGED
@@ -411,4 +411,4 @@ require 'mls/models/address'
411
411
  require 'mls/models/photo'
412
412
  require 'mls/models/tour_request'
413
413
  require 'mls/models/flyer'
414
- require 'mls/models/area'
414
+ require 'mls/models/region'
@@ -1,8 +1,8 @@
1
1
  class MLS::Address < MLS::Resource
2
2
 
3
- property :id, Fixnum, :serialize => :if_present
3
+ property :id, Fixnum, :serialize => :false
4
4
  property :name, String, :serialize => :false
5
- property :slug, String, :serialize => :if_present
5
+ property :slug, String, :serialize => :false
6
6
 
7
7
  property :latitude, Decimal
8
8
  property :longitude, Decimal
@@ -37,6 +37,8 @@ class MLS::Address < MLS::Resource
37
37
  property :import_listings_count, Fixnum, :serialize => :false
38
38
  property :active_listings_count, Fixnum, :serialize => :false
39
39
 
40
+ property :avatar_digest, String, :serialize => false
41
+
40
42
  attr_accessor :listings, :listing_kinds, :photos
41
43
 
42
44
  # should include an optional use address or no_image image
@@ -49,11 +51,27 @@ class MLS::Address < MLS::Resource
49
51
  :fov => 120
50
52
  }
51
53
 
52
- "#{protocol}://maps.googleapis.com/maps/api/streetview?" + params.map{|k,v| k.to_s + '=' + URI.escape(v.to_s) }.join('&')
54
+ if avatar_digest
55
+ "#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg"
56
+ else
57
+ "#{protocol}://maps.googleapis.com/maps/api/streetview?" + params.map{|k,v| k.to_s + '=' + URI.escape(v.to_s) }.join('&')
58
+ end
59
+ end
60
+
61
+ def to_hash
62
+ hash = super
63
+ hash[:photo_ids] = photos.map(&:id) if photos
64
+ hash
65
+ end
66
+
67
+ def to_hash_for_listing
68
+ hash = to_hash
69
+ hash[:slug] = slug
70
+ hash
53
71
  end
54
72
 
55
73
  def to_param
56
- [state, city, name].map(&:parameterize).join('/')
74
+ [state, city, "#{street_number} #{street}"].map(&:parameterize).join('/')
57
75
  end
58
76
 
59
77
  def url
@@ -115,6 +133,8 @@ class MLS::Address::Parser < MLS::Parser
115
133
  end
116
134
 
117
135
  def photos=(photos)
118
- @object.photos = photos.map {|d| MLS::Photo.new({:digest => d})}
136
+ @object.photos = photos.map do |p|
137
+ MLS::Photo.new(:digest => p[:digest], :id => p[:id].to_i)
138
+ end
119
139
  end
120
140
  end
@@ -5,6 +5,8 @@ class MLS::Listing < MLS::Resource
5
5
  LEASE_TYPES = ['Full Service', 'NNN', 'Gross', 'Industrial Gross', 'Modified Gross', 'Triple Net', 'Modified Net']
6
6
  RATE_UNITS = ['ft^2/year', 'ft^2/month', 'desk/month']
7
7
  USES = ["Office", "Creative", "Loft", "Medical Office", "Flex Space", "R&D", "Office Showroom", "Industrial", "Retail"]
8
+ SOURCE_TYPES = %w(website flyer)
9
+ CHANNELS = %w(excavator mls staircase broker_dashboard)
8
10
 
9
11
  property :id, Fixnum, :serialize => :false
10
12
  property :address_id, Fixnum, :serialize => :false
@@ -15,6 +17,8 @@ class MLS::Listing < MLS::Resource
15
17
  property :source, String
16
18
  property :source_url, String
17
19
  property :flyer_url, String, :serialize => false
20
+ property :source_type, String, :serialize => :if_present
21
+ property :channel, String, :serialize => :if_present
18
22
 
19
23
  property :name, String
20
24
  property :kind, String, :default => 'lease'
@@ -102,11 +106,23 @@ class MLS::Listing < MLS::Resource
102
106
 
103
107
  case space_type
104
108
  when 'unit'
105
- "Unit #{unit || 'Lease'}"
109
+ if unit
110
+ "Unit #{unit}"
111
+ elsif floor
112
+ "#{floor.ordinalize} Floor"
113
+ else
114
+ "Unit Lease"
115
+ end
106
116
  when 'building'
107
117
  "Entire Building"
108
118
  when 'floor'
109
- "Floor #{floor || 'Lease'}"
119
+ if floor
120
+ "#{floor.ordinalize} Floor"
121
+ elsif unit
122
+ "Unit #{unit}"
123
+ else
124
+ "Floor Lease"
125
+ end
110
126
  end
111
127
  end
112
128
 
@@ -170,7 +186,7 @@ class MLS::Listing < MLS::Resource
170
186
  end
171
187
 
172
188
  def to_param
173
- [address.state, address.city, address.name, id.to_s].map(&:parameterize).join('/')
189
+ "#{address.to_param}/#{id}"
174
190
  end
175
191
 
176
192
  def import #TODO test me
@@ -197,6 +213,10 @@ class MLS::Listing < MLS::Resource
197
213
  "#{address.url}/#{id}"
198
214
  end
199
215
 
216
+ def all_photos
217
+ photos + address.photos
218
+ end
219
+
200
220
  class << self
201
221
 
202
222
  def find(id)
@@ -204,7 +224,7 @@ class MLS::Listing < MLS::Resource
204
224
  MLS::Listing::Parser.parse(response.body)
205
225
  end
206
226
 
207
- def all(filters = {}, limit = nil, order = nil)
227
+ def all(filters = {}, limit = nil, order = 'listings.id')
208
228
  response = MLS.get('/listings', :filters => filters, :limit => limit, :order => order)
209
229
  MLS::Listing::Parser.parse_collection(response.body)
210
230
  end
@@ -0,0 +1,33 @@
1
+ class MLS::Region < MLS::Resource
2
+
3
+ property :id, Fixnum, :serialize => :if_present
4
+ property :name, String, :serialize => :if_present
5
+ property :common_name, String, :serialize => :if_present
6
+ property :description, String, :serialize => :if_present
7
+ property :code, String, :serialize => :if_present
8
+ property :type, String, :serialize => :if_present
9
+ property :source, String, :serialize => :if_present
10
+ property :minimum_zoom, Fixnum, :serialize => :if_present
11
+ property :maximum_zoom, Fixnum, :serialize => :if_present
12
+ property :slug, String, :serialize => false
13
+ property :geometry, Hash, :serialize => false
14
+ property :envelope, Hash, :serialize => false
15
+
16
+ # Counter caches
17
+ property :listings_count, Fixnum, :serialize => :false
18
+
19
+ class << self
20
+
21
+ def find(id)
22
+ response = MLS.get("/regions/#{id}")
23
+ MLS::Region::Parser.parse(response.body)
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+
31
+ class MLS::Region::Parser < MLS::Parser
32
+
33
+ end
@@ -18,9 +18,7 @@ class MLS::Parser
18
18
  end
19
19
 
20
20
  def update_attributes(attributes)
21
- attributes.each do |k,v|
22
- self.send("#{k}=".to_sym, v)
23
- end
21
+ attributes.each {|k,v| self.send("#{k}=".to_sym, v) } if attributes
24
22
  end
25
23
 
26
24
  def self.parse(data)
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mls"
6
- s.version = '0.2.3'
6
+ s.version = '0.2.4'
7
7
  s.authors = ["James R. Bracy"]
8
8
  s.email = ["james@42floors.com"]
9
9
  s.homepage = "http://mls.42floors.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70194752800700 !ruby/object:Gem::Requirement
16
+ requirement: &70245559798020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70194752800700
24
+ version_requirements: *70245559798020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70194752799380 !ruby/object:Gem::Requirement
27
+ requirement: &70245559797580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70194752799380
35
+ version_requirements: *70245559797580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70194752798720 !ruby/object:Gem::Requirement
38
+ requirement: &70245559797160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70194752798720
46
+ version_requirements: *70245559797160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &70194752797320 !ruby/object:Gem::Requirement
49
+ requirement: &70245559796740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70194752797320
57
+ version_requirements: *70245559796740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: turn
60
- requirement: &70194752795360 !ruby/object:Gem::Requirement
60
+ requirement: &70245559796320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70194752795360
68
+ version_requirements: *70245559796320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faker
71
- requirement: &70194747990780 !ruby/object:Gem::Requirement
71
+ requirement: &70245559795900 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70194747990780
79
+ version_requirements: *70245559795900
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: factory_girl
82
- requirement: &70194747990360 !ruby/object:Gem::Requirement
82
+ requirement: &70245559795480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70194747990360
90
+ version_requirements: *70245559795480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: fakeweb
93
- requirement: &70194747989940 !ruby/object:Gem::Requirement
93
+ requirement: &70245559795060 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70194747989940
101
+ version_requirements: *70245559795060
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: activesupport
104
- requirement: &70194747989520 !ruby/object:Gem::Requirement
104
+ requirement: &70245559794640 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70194747989520
112
+ version_requirements: *70245559794640
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: yajl-ruby
115
- requirement: &70194747989100 !ruby/object:Gem::Requirement
115
+ requirement: &70245559794220 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70194747989100
123
+ version_requirements: *70245559794220
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rest-client
126
- requirement: &70194747988680 !ruby/object:Gem::Requirement
126
+ requirement: &70245559793800 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70194747988680
134
+ version_requirements: *70245559793800
135
135
  description: Ruby library for integrating with the 42Floors MLS
136
136
  email:
137
137
  - james@42floors.com
@@ -148,10 +148,10 @@ files:
148
148
  - lib/mls/model.rb
149
149
  - lib/mls/models/account.rb
150
150
  - lib/mls/models/address.rb
151
- - lib/mls/models/area.rb
152
151
  - lib/mls/models/flyer.rb
153
152
  - lib/mls/models/listing.rb
154
153
  - lib/mls/models/photo.rb
154
+ - lib/mls/models/region.rb
155
155
  - lib/mls/models/tour_request.rb
156
156
  - lib/mls/models/use.rb
157
157
  - lib/mls/parser.rb
@@ -1,27 +0,0 @@
1
- class MLS::Area < MLS::Resource
2
-
3
- property :id, Fixnum, :serialize => :if_present
4
- property :name, String, :serialize => :if_present
5
- property :level, Fixnum, :serialize => :if_present
6
- property :type, String, :serialize => :if_present
7
- property :source, String, :serialize => :if_present
8
- property :geometry, Hash, :serialize => false
9
-
10
- # Counter caches
11
- property :listings_count, Fixnum, :serialize => :false
12
-
13
- class << self
14
-
15
- def find(id)
16
- response = MLS.get("/areas/#{id}")
17
- MLS::Area::Parser.parse(response.body)
18
- end
19
-
20
- end
21
-
22
- end
23
-
24
-
25
- class MLS::Area::Parser < MLS::Parser
26
-
27
- end