mls 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mls/models/listing.rb +50 -35
- data/mls.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0238b89c67be7c1edb92e93c8f7f8679ba0728eb
|
4
|
+
data.tar.gz: ae42cc8446967251336c714fb277504ef026785e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526627382897b88bc1fe1fc2137a09ff7786f2e2b256941bfae0236a1e3a3132af3c9e473db237202ce890d92c0ec653132742ac38b95dbba33edf6fc1ae3cbc
|
7
|
+
data.tar.gz: e5c6cf46883d6e4249466f0c0f0291a91d0ae2c8dca2e4bf73722cbfa590a17806258b2fa26835aea56f00bee927aee98299436ae41ebc1c5a3291b36e707069
|
data/lib/mls/models/listing.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class MLS::Listing < MLS::Resource
|
2
2
|
|
3
|
-
|
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 :
|
27
|
-
property :
|
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
|
@@ -42,10 +43,10 @@ class MLS::Listing < MLS::Resource
|
|
42
43
|
property :high_rate, Decimal, :serialize => :false
|
43
44
|
property :rate_per_sqft_per_month, Decimal, :serialize => :false # need to make write methods for these that set rate to the according rate units. not accepted on api
|
44
45
|
property :rate_per_sqft_per_year, Decimal, :serialize => :false
|
45
|
-
property :rate_per_month, Decimal, :serialize => :false
|
46
|
+
property :rate_per_month, Decimal, :serialize => :false
|
46
47
|
property :rate_per_year, Decimal, :serialize => :false
|
47
48
|
property :sublease_expiration, DateTime
|
48
|
-
|
49
|
+
|
49
50
|
property :forecast_rate_per_year, Decimal, :serialize => :false
|
50
51
|
property :forecast_rate_per_month, Decimal, :serialize => :false
|
51
52
|
property :forecast_rate_per_sqft_per_month, Decimal, :serialize => :false
|
@@ -59,7 +60,7 @@ class MLS::Listing < MLS::Resource
|
|
59
60
|
property :offices, Fixnum
|
60
61
|
property :conference_rooms, Fixnum
|
61
62
|
property :bathrooms, Fixnum
|
62
|
-
|
63
|
+
|
63
64
|
property :kitchen, Boolean
|
64
65
|
property :showers, Boolean
|
65
66
|
property :patio, Boolean
|
@@ -68,7 +69,7 @@ class MLS::Listing < MLS::Resource
|
|
68
69
|
property :furniture_available, Boolean
|
69
70
|
property :natural_light, Boolean
|
70
71
|
property :high_ceilings, Boolean
|
71
|
-
|
72
|
+
|
72
73
|
property :created_at, DateTime, :serialize => :false
|
73
74
|
property :updated_at, DateTime, :serialize => :false
|
74
75
|
property :touched_at, DateTime, :serialize => :false
|
@@ -76,17 +77,17 @@ class MLS::Listing < MLS::Resource
|
|
76
77
|
property :photography_requested_on, DateTime, :serialize => :false
|
77
78
|
|
78
79
|
property :awesome_score, Fixnum
|
79
|
-
property :awesome_needs, Array, :serialize => :if_present
|
80
|
+
property :awesome_needs, Array, :serialize => :if_present
|
80
81
|
property :awesome_label, String
|
81
82
|
|
82
83
|
property :flyer_id, Fixnum, :serialize => :if_present
|
83
84
|
property :floorplan_id, Fixnum, :serialize => :if_present
|
84
|
-
|
85
|
+
|
85
86
|
property :avatar_digest, String, :serialize => false
|
86
|
-
|
87
|
+
|
87
88
|
# Counter Caches
|
88
89
|
property :photos_count, Fixnum, :serialize => :false
|
89
|
-
|
90
|
+
|
90
91
|
attr_accessor :address, :agents, :account, :photos, :flyer, :floorplan, :videos, :similar_photos
|
91
92
|
|
92
93
|
def avatar(size='150x100#', protocol='http')
|
@@ -96,27 +97,42 @@ class MLS::Listing < MLS::Resource
|
|
96
97
|
address.avatar(size, protocol)
|
97
98
|
end
|
98
99
|
end
|
99
|
-
|
100
|
+
|
101
|
+
def processing?
|
102
|
+
workflow_state == 'processing'
|
103
|
+
end
|
104
|
+
|
105
|
+
def leased?
|
106
|
+
lease_state == 'leased'
|
107
|
+
end
|
108
|
+
|
109
|
+
def active?
|
110
|
+
lease_state == 'listed' && workflow_state == 'visible'
|
111
|
+
end
|
112
|
+
|
113
|
+
def inactive?
|
114
|
+
!self.active?
|
115
|
+
end
|
116
|
+
|
100
117
|
def lease?
|
101
118
|
type == 'lease'
|
102
119
|
end
|
120
|
+
|
103
121
|
def sublease?
|
104
122
|
type == 'sublease'
|
105
123
|
end
|
124
|
+
|
106
125
|
def coworking?
|
107
126
|
type == 'coworking_space'
|
108
127
|
end
|
109
128
|
|
110
|
-
|
111
|
-
state == 'leased'
|
112
|
-
end
|
113
|
-
|
129
|
+
|
114
130
|
def space_name
|
115
131
|
return name if !name.nil?
|
116
|
-
|
132
|
+
|
117
133
|
case space_type
|
118
134
|
when 'unit'
|
119
|
-
if unit
|
135
|
+
if unit
|
120
136
|
"Unit #{unit}"
|
121
137
|
elsif floor
|
122
138
|
"#{floor.ordinalize} Floor"
|
@@ -128,7 +144,7 @@ class MLS::Listing < MLS::Resource
|
|
128
144
|
when 'floor'
|
129
145
|
if floor
|
130
146
|
"#{floor.ordinalize} Floor"
|
131
|
-
elsif unit
|
147
|
+
elsif unit
|
132
148
|
"Unit #{unit}"
|
133
149
|
else
|
134
150
|
"Floor Lease"
|
@@ -136,8 +152,8 @@ class MLS::Listing < MLS::Resource
|
|
136
152
|
end
|
137
153
|
end
|
138
154
|
|
139
|
-
|
140
|
-
|
155
|
+
|
156
|
+
|
141
157
|
# Creates a tour request for the listing.
|
142
158
|
#
|
143
159
|
# Paramaters::
|
@@ -158,13 +174,13 @@ class MLS::Listing < MLS::Resource
|
|
158
174
|
# listing = MLS::Listing.find(@id)
|
159
175
|
# info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
|
160
176
|
# listing.request_tour('name', 'email@address.com', info) # => #<MLS::Tour>
|
161
|
-
#
|
177
|
+
#
|
162
178
|
# listing.request_tour('', 'emai', info) # => #<MLS::Tour> will have errors on account
|
163
179
|
def request_tour(account, tour={})
|
164
180
|
MLS::Tour.create(id, account, tour)
|
165
181
|
end
|
166
|
-
|
167
|
-
|
182
|
+
|
183
|
+
|
168
184
|
def create
|
169
185
|
MLS.post('/listings', {:listing => to_hash}, 201, 400) do |response, code|
|
170
186
|
raise MLS::Exception::UnexpectedResponse if ![201, 400].include?(code)
|
@@ -177,7 +193,7 @@ class MLS::Listing < MLS::Resource
|
|
177
193
|
MLS.put("/listings/#{id}", {:listing => to_hash}, 400) do |response, code|
|
178
194
|
if code == 200 || code == 400
|
179
195
|
MLS::Listing::Parser.update(self, response.body)
|
180
|
-
code == 200
|
196
|
+
code == 200
|
181
197
|
else
|
182
198
|
raise MLS::Exception::UnexpectedResponse, code
|
183
199
|
end
|
@@ -192,7 +208,7 @@ class MLS::Listing < MLS::Resource
|
|
192
208
|
hash[:videos_attributes] = videos.map(&:to_hash) unless videos.blank?
|
193
209
|
hash
|
194
210
|
end
|
195
|
-
|
211
|
+
|
196
212
|
def to_param
|
197
213
|
"#{address.to_param}/#{id}"
|
198
214
|
end
|
@@ -217,7 +233,7 @@ class MLS::Listing < MLS::Resource
|
|
217
233
|
result
|
218
234
|
end
|
219
235
|
|
220
|
-
def similar
|
236
|
+
def similar
|
221
237
|
[] # Similar Listings not supported for now
|
222
238
|
end
|
223
239
|
|
@@ -228,7 +244,7 @@ class MLS::Listing < MLS::Resource
|
|
228
244
|
MLS::Listing::Parser.parse(response.body)
|
229
245
|
end
|
230
246
|
|
231
|
-
# currently supported options are filters, page, per_page, offset, order
|
247
|
+
# currently supported options are filters, page, per_page, offset, order
|
232
248
|
def all(options={})
|
233
249
|
response = MLS.get('/listings', options)
|
234
250
|
MLS::Listing::Parser.parse_collection(response.body)
|
@@ -254,7 +270,7 @@ end
|
|
254
270
|
|
255
271
|
|
256
272
|
class MLS::Listing::Parser < MLS::Parser
|
257
|
-
|
273
|
+
|
258
274
|
def photos=(photos)
|
259
275
|
@object.photos = photos.map {|p| MLS::Photo::Parser.build(p)}
|
260
276
|
end
|
@@ -276,13 +292,12 @@ class MLS::Listing::Parser < MLS::Parser
|
|
276
292
|
def flyer=(flyer)
|
277
293
|
@object.flyer = MLS::Flyer::Parser.build(flyer)
|
278
294
|
end
|
279
|
-
|
295
|
+
|
280
296
|
def address=(address)
|
281
297
|
@object.address = MLS::Address::Parser.build(address)
|
282
298
|
end
|
283
|
-
|
299
|
+
|
284
300
|
def agents=(agents)
|
285
301
|
@object.agents = agents.map {|a| MLS::Account::Parser.build(a) }
|
286
302
|
end
|
287
|
-
|
288
303
|
end
|
data/mls.gemspec
CHANGED