mls 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a331b7024dd4a8a7511c62cdada76b4cf718d9a1
4
- data.tar.gz: a5f2066901baacf9976b43c8648c23d6c68357df
3
+ metadata.gz: 7f5dfd975d3d0cc9ba0190506aa6d4993ad7ca01
4
+ data.tar.gz: 223e2d92063fe87ce64a320d1ffb273b7d3dcc4b
5
5
  SHA512:
6
- metadata.gz: 4efe6ad46a1c9f8a5fc2eb8510f9cce67597d467c1e019ab551b0eff79b0ae5870b8eae54ae3b8391feb629616bd3a393ba331e774f8514d2951d5a955ddff6f
7
- data.tar.gz: 956edb5fded23ff4dcdd15fc3a5ad10440ba574c10a0aac975733595a12e42e18633e366c50b50ca38e38d87f22dcb5ed36f9bf4a46eaed1140d941c6d38a7cf
6
+ metadata.gz: 6f0a8e9ebb340379c972ef2ffc5f62e1e5a225dd39e8b81e780feb6e34e2ee670789c5ac2e72b6fc485304c196a3ac4d69d800a9e82226283d127689ea1a18ed
7
+ data.tar.gz: 10f4622fc2236477fb933ca20f3ccc6939b3598bd4680628d6db593d83cee4d55c5fe4131969aabedadb8a88511ce914bf693d14062f069114ba2dc7728a10ee
@@ -1,6 +1,7 @@
1
1
  class MLS::Listing < MLS::Resource
2
2
 
3
- STATES = %w(processing listed leased expired)
3
+ WORKFLOW_STATES = %w(visible processing invisible expired)
4
+ LEASE_STATES = %w(listed leased)
4
5
  TYPES = %w(lease sublease coworking_space)
5
6
  SPACE_TYPES = %w(unit floor building)
6
7
  LEASE_TERMS = ['Full Service', 'NNN', 'Modified Gross']
@@ -8,7 +9,7 @@ class MLS::Listing < MLS::Resource
8
9
  USES = ["Office", "Creative", "Loft", "Medical Office", "Flex Space", "R&D", "Office Showroom", "Industrial", "Retail"]
9
10
  SOURCE_TYPES = %w(website flyer)
10
11
  CHANNELS = %w(excavator mls staircase broker_dashboard)
11
-
12
+
12
13
  property :id, Fixnum, :serialize => :false
13
14
  property :address_id, Fixnum, :serialize => :false
14
15
  property :slug, String, :serialize => :false
@@ -20,16 +21,16 @@ class MLS::Listing < MLS::Resource
20
21
  property :source_type, String, :serialize => :if_present
21
22
  property :channel, String, :serialize => :if_present
22
23
  property :photo_ids, Array, :serialize => :if_present
23
-
24
+
24
25
  property :name, String
25
26
  property :type, String, :default => 'lease'
26
- property :state, String, :default => 'listed'
27
- property :visible, Boolean, :default => true
27
+ property :workflow_state, String, :default => 'visible'
28
+ property :lease_state, String, :default => 'listed'
28
29
  property :space_type, String, :default => 'unit'
29
30
  property :unit, String
30
31
  property :floor, Fixnum
31
32
  property :description, String
32
-
33
+
33
34
  property :size, Fixnum
34
35
  property :maximum_contiguous_size, Fixnum
35
36
  property :minimum_divisible_size, Fixnum
@@ -41,7 +42,7 @@ class MLS::Listing < MLS::Resource
41
42
  property :low_rate, Decimal, :serialize => :false
42
43
  property :high_rate, Decimal, :serialize => :false
43
44
  property :sublease_expiration, DateTime
44
-
45
+
45
46
  property :forecast_rate_per_year, Decimal, :serialize => :false
46
47
  property :forecast_rate_per_month, Decimal, :serialize => :false
47
48
  property :forecast_rate_per_sqft_per_month, Decimal, :serialize => :false
@@ -55,7 +56,7 @@ class MLS::Listing < MLS::Resource
55
56
  property :offices, Fixnum
56
57
  property :conference_rooms, Fixnum
57
58
  property :bathrooms, Fixnum
58
-
59
+
59
60
  property :kitchen, Boolean
60
61
  property :showers, Boolean
61
62
  property :patio, Boolean
@@ -64,7 +65,7 @@ class MLS::Listing < MLS::Resource
64
65
  property :furniture_available, Boolean
65
66
  property :natural_light, Boolean
66
67
  property :high_ceilings, Boolean
67
-
68
+
68
69
  property :created_at, DateTime, :serialize => :false
69
70
  property :updated_at, DateTime, :serialize => :false
70
71
  property :touched_at, DateTime, :serialize => :false
@@ -72,17 +73,17 @@ class MLS::Listing < MLS::Resource
72
73
  property :photography_requested_on, DateTime, :serialize => :false
73
74
 
74
75
  property :awesome_score, Fixnum
75
- property :awesome_needs, Array, :serialize => :if_present
76
+ property :awesome_needs, Array, :serialize => :if_present
76
77
  property :awesome_label, String
77
78
 
78
79
  property :flyer_id, Fixnum, :serialize => :if_present
79
80
  property :floorplan_id, Fixnum, :serialize => :if_present
80
-
81
+
81
82
  property :avatar_digest, String, :serialize => false
82
-
83
+
83
84
  # Counter Caches
84
85
  property :photos_count, Fixnum, :serialize => :false
85
-
86
+
86
87
  attr_accessor :address, :agents, :account, :photos, :flyer, :floorplan, :videos, :similar_photos
87
88
 
88
89
  def avatar(size='150x100#', protocol='http')
@@ -92,27 +93,42 @@ class MLS::Listing < MLS::Resource
92
93
  address.avatar(size, protocol)
93
94
  end
94
95
  end
95
-
96
+
97
+ def processing?
98
+ workflow_state == 'processing'
99
+ end
100
+
101
+ def leased?
102
+ lease_state == 'leased'
103
+ end
104
+
105
+ def active?
106
+ lease_state == 'listed' && workflow_state == 'visible'
107
+ end
108
+
109
+ def inactive?
110
+ !self.active?
111
+ end
112
+
96
113
  def lease?
97
114
  type == 'lease'
98
115
  end
116
+
99
117
  def sublease?
100
118
  type == 'sublease'
101
119
  end
120
+
102
121
  def coworking?
103
122
  type == 'coworking_space'
104
123
  end
105
124
 
106
- def leased?
107
- state == 'leased'
108
- end
109
-
125
+
110
126
  def space_name
111
127
  return name if !name.nil?
112
-
128
+
113
129
  case space_type
114
130
  when 'unit'
115
- if unit
131
+ if unit
116
132
  "Unit #{unit}"
117
133
  elsif floor
118
134
  "#{floor.ordinalize} Floor"
@@ -124,7 +140,7 @@ class MLS::Listing < MLS::Resource
124
140
  when 'floor'
125
141
  if floor
126
142
  "#{floor.ordinalize} Floor"
127
- elsif unit
143
+ elsif unit
128
144
  "Unit #{unit}"
129
145
  else
130
146
  "Floor Lease"
@@ -149,7 +165,7 @@ class MLS::Listing < MLS::Resource
149
165
  else
150
166
  raise "Invalid rate conversion (#{rate_units} => #{units})"
151
167
  end
152
-
168
+
153
169
  elsif rate_units == '/sqft/yr'
154
170
  if units == '/sqft/mo'
155
171
  @rate / 12.0
@@ -164,7 +180,7 @@ class MLS::Listing < MLS::Resource
164
180
  else
165
181
  raise "Invalid rate conversion (#{rate_units} => #{units})"
166
182
  end
167
-
183
+
168
184
  elsif rate_units == '/mo'
169
185
  if units == '/sqft/mo'
170
186
  @rate / @size.to_f
@@ -194,7 +210,7 @@ class MLS::Listing < MLS::Resource
194
210
  else
195
211
  raise "Invalid rate conversion (#{rate_units} => #{units})"
196
212
  end
197
-
213
+
198
214
  elsif rate_units == '/desk/mo'
199
215
  if units == '/sqft/mo'
200
216
  @rate / 200.0
@@ -209,7 +225,7 @@ class MLS::Listing < MLS::Resource
209
225
  else
210
226
  raise "Invalid rate conversion (#{rate_units} => #{units})"
211
227
  end
212
-
228
+
213
229
  end
214
230
  end
215
231
 
@@ -233,13 +249,13 @@ class MLS::Listing < MLS::Resource
233
249
  # listing = MLS::Listing.find(@id)
234
250
  # info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
235
251
  # listing.request_tour('name', 'email@address.com', info) # => #<MLS::Tour>
236
- #
252
+ #
237
253
  # listing.request_tour('', 'emai', info) # => #<MLS::Tour> will have errors on account
238
254
  def request_tour(account, tour={})
239
255
  MLS::Tour.create(id, account, tour)
240
256
  end
241
-
242
-
257
+
258
+
243
259
  def create
244
260
  MLS.post('/listings', {:listing => to_hash}, 201, 400) do |response, code|
245
261
  raise MLS::Exception::UnexpectedResponse if ![201, 400].include?(code)
@@ -252,7 +268,7 @@ class MLS::Listing < MLS::Resource
252
268
  MLS.put("/listings/#{id}", {:listing => to_hash}, 400) do |response, code|
253
269
  if code == 200 || code == 400
254
270
  MLS::Listing::Parser.update(self, response.body)
255
- code == 200
271
+ code == 200
256
272
  else
257
273
  raise MLS::Exception::UnexpectedResponse, code
258
274
  end
@@ -267,7 +283,7 @@ class MLS::Listing < MLS::Resource
267
283
  hash[:videos_attributes] = videos.map(&:to_hash) unless videos.blank?
268
284
  hash
269
285
  end
270
-
286
+
271
287
  def to_param
272
288
  "#{address.to_param}/#{id}"
273
289
  end
@@ -292,7 +308,7 @@ class MLS::Listing < MLS::Resource
292
308
  result
293
309
  end
294
310
 
295
- def similar
311
+ def similar
296
312
  [] # Similar Listings not supported for now
297
313
  end
298
314
 
@@ -303,7 +319,7 @@ class MLS::Listing < MLS::Resource
303
319
  MLS::Listing::Parser.parse(response.body)
304
320
  end
305
321
 
306
- # currently supported options are filters, page, per_page, offset, order
322
+ # currently supported options are filters, page, per_page, offset, order
307
323
  def all(options={})
308
324
  response = MLS.get('/listings', options)
309
325
  MLS::Listing::Parser.parse_collection(response.body)
@@ -329,7 +345,7 @@ end
329
345
 
330
346
 
331
347
  class MLS::Listing::Parser < MLS::Parser
332
-
348
+
333
349
  def photos=(photos)
334
350
  @object.photos = photos.map {|p| MLS::Photo::Parser.build(p)}
335
351
  end
@@ -351,13 +367,12 @@ class MLS::Listing::Parser < MLS::Parser
351
367
  def flyer=(flyer)
352
368
  @object.flyer = MLS::Flyer::Parser.build(flyer)
353
369
  end
354
-
370
+
355
371
  def address=(address)
356
372
  @object.address = MLS::Address::Parser.build(address)
357
373
  end
358
-
374
+
359
375
  def agents=(agents)
360
376
  @object.agents = agents.map {|a| MLS::Account::Parser.build(a) }
361
377
  end
362
-
363
378
  end
data/mls.gemspec CHANGED
@@ -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.9.0'
6
+ s.version = '0.9.1'
7
7
  s.authors = ["James R. Bracy", "Jon Bracy"]
8
8
  s.email = ["james@42floors.com"]
9
9
  s.homepage = "http://mls.42floors.com"
@@ -4,7 +4,7 @@ class TestListing < ::Test::Unit::TestCase
4
4
 
5
5
  def test_properties
6
6
  listing = MLS::Listing.new
7
-
7
+
8
8
  assert listing.respond_to?(:id)
9
9
  assert listing.respond_to?(:address_id)
10
10
  assert listing.respond_to?(:use)
@@ -40,20 +40,20 @@ class TestListing < ::Test::Unit::TestCase
40
40
  assert listing.respond_to?(:created_at)
41
41
  assert listing.respond_to?(:updated_at)
42
42
  end
43
-
43
+
44
44
  def test_attr_accessors
45
45
  listing = MLS::Listing.new
46
-
46
+
47
47
  assert listing.respond_to?(:address)
48
48
  assert listing.respond_to?(:agents)
49
49
  end
50
-
50
+
51
51
  def test_instance_methods
52
52
  listing = MLS::Listing.new
53
-
53
+
54
54
  assert listing.respond_to?(:photos)
55
55
  end
56
-
56
+
57
57
  def test_class_methods
58
58
  assert MLS::Listing.respond_to?(:find)
59
59
  end
@@ -63,8 +63,8 @@ class TestListing < ::Test::Unit::TestCase
63
63
  @name = Faker::Name.name
64
64
  @email = Faker::Internet.email
65
65
  tr = @listing.request_tour(@name, @email)
66
-
67
-
66
+
67
+
68
68
  assert_equal({}, tr.errors)
69
69
  assert_equal({}, tr.account.errors)
70
70
  # TODO assert_equal({}, tr.listing.errors)
@@ -85,7 +85,7 @@ class TestListing < ::Test::Unit::TestCase
85
85
  test '#request_tour for email on an account' do
86
86
  @account = FactoryGirl.create(:account)
87
87
  @listing = FactoryGirl.create(:listing)
88
-
88
+
89
89
  tr = @listing.request_tour(@account.name, @account.email)
90
90
  assert_equal({}, tr.errors)
91
91
  assert_equal({}, tr.account.errors)
@@ -162,7 +162,7 @@ class TestListing < ::Test::Unit::TestCase
162
162
 
163
163
  info = {:company => '42Floors', :population => 10, :funding => 'string thing', :move_in_date => '2012-09-12'}
164
164
  tr = @listing.request_tour(Faker::Name.name, Faker::Internet.email, info)
165
-
165
+
166
166
  assert tr.id
167
167
  assert_equal '42Floors', info[:company]
168
168
  assert_equal 10, info[:population]
@@ -190,10 +190,10 @@ class TestListing < ::Test::Unit::TestCase
190
190
  listing.rate('/random')
191
191
  end
192
192
  end
193
-
193
+
194
194
  def test_rate_per_sqft_per_year
195
195
  listing = MLS::Listing.new(:rate => 126, :rate_units => '/sqft/yr', :size => 5)
196
-
196
+
197
197
  assert_equal 10.5, listing.rate
198
198
  assert_equal 10.5, listing.rate('/sqft/mo')
199
199
  assert_equal 126, listing.rate('/sqft/yr')
@@ -204,10 +204,10 @@ class TestListing < ::Test::Unit::TestCase
204
204
  listing.rate('/random')
205
205
  end
206
206
  end
207
-
207
+
208
208
  def test_rate_per_month
209
209
  listing = MLS::Listing.new(:rate => 52.5, :rate_units => '/mo', :size => 5)
210
-
210
+
211
211
  assert_equal 10.5, listing.rate
212
212
  assert_equal 10.5, listing.rate('/sqft/mo')
213
213
  assert_equal 126, listing.rate('/sqft/yr')
@@ -218,10 +218,10 @@ class TestListing < ::Test::Unit::TestCase
218
218
  listing.rate('/random')
219
219
  end
220
220
  end
221
-
221
+
222
222
  def test_rate_per_year
223
223
  listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
224
-
224
+
225
225
  assert_equal 10.5, listing.rate
226
226
  assert_equal 10.5, listing.rate('/sqft/mo')
227
227
  assert_equal 126, listing.rate('/sqft/yr')
@@ -232,10 +232,10 @@ class TestListing < ::Test::Unit::TestCase
232
232
  listing.rate('/random')
233
233
  end
234
234
  end
235
-
235
+
236
236
  def test_rate_per_desk_per_month
237
237
  listing = MLS::Listing.new(:rate => 630, :rate_units => '/yr', :size => 5)
238
-
238
+
239
239
  assert_equal 10.5, listing.rate
240
240
  assert_equal 10.5, listing.rate('/sqft/mo')
241
241
  assert_equal 126, listing.rate('/sqft/yr')
@@ -246,5 +246,5 @@ class TestListing < ::Test::Unit::TestCase
246
246
  listing.rate('/random')
247
247
  end
248
248
  end
249
-
249
+
250
250
  end
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James R. Bracy