mls 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mls.rb +1 -1
- data/lib/mls/models/listing.rb +9 -8
- data/lib/mls/models/{contact.rb → tour.rb} +13 -30
- data/mls.gemspec +1 -1
- data/test/factories/contact.rb +1 -1
- data/test/units/models/test_contact.rb +6 -6
- data/test/units/models/test_listing.rb +22 -22
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0dc41026f98df90948e20f9b52f2cc1cd7a765b
|
4
|
+
data.tar.gz: b73f3d238de76032a905a6cabe599d9cbdf80092
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 204d5a478ea5a952cd7f10d27ea3f84834d266808e747b39681af0ae2ecf0c21a7adc84300a64d11ce6cdcc727261cb2fea19b47414cbd98f5ee385e43edc50e
|
7
|
+
data.tar.gz: 706a004c693e0cb23b812619c01539237d2912f63437061cbdc1f3a4658a12bdd9b9a87119ebd8858a0343c598f22650e3ac8631c4cfc4b0187a4363a4b0d666
|
data/lib/mls.rb
CHANGED
@@ -434,7 +434,7 @@ require 'mls/models/address'
|
|
434
434
|
require 'mls/models/photo'
|
435
435
|
require 'mls/models/video'
|
436
436
|
require 'mls/models/pdf'
|
437
|
-
require 'mls/models/
|
437
|
+
require 'mls/models/tour'
|
438
438
|
require 'mls/models/flyer'
|
439
439
|
require 'mls/models/floorplan'
|
440
440
|
require 'mls/models/region'
|
data/lib/mls/models/listing.rb
CHANGED
@@ -54,6 +54,7 @@ class MLS::Listing < MLS::Resource
|
|
54
54
|
property :available_on, DateTime
|
55
55
|
property :maximum_term_length, Fixnum
|
56
56
|
property :minimum_term_length, Fixnum
|
57
|
+
property :term_length_units, String, :default => 'years'
|
57
58
|
|
58
59
|
property :offices, Fixnum
|
59
60
|
property :conference_rooms, Fixnum
|
@@ -137,14 +138,14 @@ class MLS::Listing < MLS::Resource
|
|
137
138
|
|
138
139
|
|
139
140
|
|
140
|
-
# Creates a
|
141
|
+
# Creates a tour request for the listing.
|
141
142
|
#
|
142
143
|
# Paramaters::
|
143
144
|
#
|
144
145
|
# * +account+ - A +Hash+ of the user account. Valid keys are:
|
145
|
-
# * +:name+ - Name of the User requesting the
|
146
|
-
# * +:email+ - Email of the User requesting the
|
147
|
-
# * +:phone+ - Phone of the User requesting the
|
146
|
+
# * +:name+ - Name of the User requesting the tour (Required)
|
147
|
+
# * +:email+ - Email of the User requesting the tour (Required)
|
148
|
+
# * +:phone+ - Phone of the User requesting the tour
|
148
149
|
# * +info+ - A optional +Hash+ of *company* info. Valid keys are:
|
149
150
|
# * +:message+ - Overrides the default message on the email sent to the broker
|
150
151
|
# * +:company+ - The name of the company that is interested in the space
|
@@ -156,11 +157,11 @@ class MLS::Listing < MLS::Resource
|
|
156
157
|
# #!ruby
|
157
158
|
# listing = MLS::Listing.find(@id)
|
158
159
|
# info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
|
159
|
-
# listing.
|
160
|
+
# listing.request_tour('name', 'email@address.com', info) # => #<MLS::Tour>
|
160
161
|
#
|
161
|
-
# listing.
|
162
|
-
def
|
163
|
-
MLS::
|
162
|
+
# listing.request_tour('', 'emai', info) # => #<MLS::Tour> will have errors on account
|
163
|
+
def request_tour(account, tour={})
|
164
|
+
MLS::Tour.create(id, account, tour)
|
164
165
|
end
|
165
166
|
|
166
167
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class MLS::
|
1
|
+
class MLS::Tour < MLS::Resource
|
2
2
|
property :id, Fixnum
|
3
|
-
property :
|
3
|
+
property :declined, Boolean
|
4
4
|
property :client_id, Fixnum
|
5
5
|
property :agent_id, Fixnum
|
6
6
|
property :listing_id, Fixnum
|
@@ -12,53 +12,36 @@ class MLS::Contact < MLS::Resource
|
|
12
12
|
|
13
13
|
attr_accessor :client, :listing
|
14
14
|
|
15
|
-
def claim(agent)
|
16
|
-
self.agent_id = agent.id
|
17
|
-
MLS.post("/contacts/#{token}/claim", {:agent_id => agent.id})
|
18
|
-
end
|
19
|
-
|
20
15
|
def decline(notes=nil)
|
21
16
|
self.agent_comments = notes
|
22
|
-
MLS.post("/
|
23
|
-
end
|
24
|
-
|
25
|
-
def view
|
26
|
-
MLS.post("/contacts/#{token}/view")
|
27
|
-
end
|
28
|
-
|
29
|
-
def viewed?
|
30
|
-
status != "new"
|
31
|
-
end
|
32
|
-
|
33
|
-
def claimed?
|
34
|
-
status == "claimed"
|
17
|
+
MLS.post("/tours/#{token}/decline", {:agent_comments => notes})
|
35
18
|
end
|
36
19
|
|
37
20
|
def declined?
|
38
|
-
|
21
|
+
declined
|
39
22
|
end
|
40
23
|
|
41
24
|
class << self
|
42
25
|
def get_all_for_account
|
43
|
-
response = MLS.get('/account/
|
44
|
-
MLS::
|
26
|
+
response = MLS.get('/account/tours')
|
27
|
+
MLS::Tour::Parser.parse_collection(response.body)
|
45
28
|
end
|
46
29
|
|
47
30
|
def find_by_token(token)
|
48
|
-
response = MLS.get("/
|
49
|
-
MLS::
|
31
|
+
response = MLS.get("/tours/#{token}")
|
32
|
+
MLS::Tour::Parser.parse(response.body)
|
50
33
|
end
|
51
34
|
|
52
|
-
def create(listing_id, account,
|
53
|
-
params = {:account => account, :
|
54
|
-
response = MLS.post("/listings/#{listing_id}/
|
55
|
-
return MLS::
|
35
|
+
def create(listing_id, account, tour={})
|
36
|
+
params = {:account => account, :tour => tour}
|
37
|
+
response = MLS.post("/listings/#{listing_id}/tour", params)
|
38
|
+
return MLS::Tour::Parser.parse(response.body)
|
56
39
|
end
|
57
40
|
end
|
58
41
|
|
59
42
|
end
|
60
43
|
|
61
|
-
class MLS::
|
44
|
+
class MLS::Tour::Parser < MLS::Parser
|
62
45
|
|
63
46
|
def listing=(listing)
|
64
47
|
@object.listing = MLS::Listing::Parser.build(listing)
|
data/mls.gemspec
CHANGED
data/test/factories/contact.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestTour < ::Test::Unit::TestCase
|
4
4
|
|
5
5
|
# def test_properties
|
6
|
-
# tr = MLS::
|
6
|
+
# tr = MLS::Tour.new
|
7
7
|
#
|
8
8
|
# assert tr.respond_to?(:message)
|
9
9
|
# end
|
10
10
|
#
|
11
11
|
# def test_attr_accessors
|
12
|
-
# tr = MLS::
|
12
|
+
# tr = MLS::Tour.new
|
13
13
|
#
|
14
14
|
# assert tr.respond_to?(:listing)
|
15
15
|
# end
|
16
16
|
#
|
17
17
|
# def test_class_methods
|
18
|
-
# assert MLS::
|
19
|
-
# assert MLS::
|
18
|
+
# assert MLS::Tour.respond_to?(:get_all_for_account)
|
19
|
+
# assert MLS::Tour.respond_to?(:create)
|
20
20
|
# end
|
21
21
|
#
|
22
22
|
# def test_parser
|
23
|
-
# assert defined?(MLS::
|
23
|
+
# assert defined?(MLS::Tour::Parser)
|
24
24
|
# end
|
25
25
|
|
26
26
|
test 'it' do
|
@@ -60,11 +60,11 @@ class TestListing < ::Test::Unit::TestCase
|
|
60
60
|
assert MLS::Listing.respond_to?(:find)
|
61
61
|
end
|
62
62
|
|
63
|
-
test '#
|
63
|
+
test '#request_tour for email without an account' do
|
64
64
|
@listing = FactoryGirl.create(:listing)
|
65
65
|
@name = Faker::Name.name
|
66
66
|
@email = Faker::Internet.email
|
67
|
-
tr = @listing.
|
67
|
+
tr = @listing.request_tour(@name, @email)
|
68
68
|
|
69
69
|
|
70
70
|
assert_equal({}, tr.errors)
|
@@ -73,66 +73,66 @@ class TestListing < ::Test::Unit::TestCase
|
|
73
73
|
assert tr.id
|
74
74
|
end
|
75
75
|
|
76
|
-
test '#
|
76
|
+
test '#request_tour for email on a ghost account' do
|
77
77
|
@account = FactoryGirl.create(:ghost_account)
|
78
78
|
@listing = FactoryGirl.create(:listing)
|
79
79
|
|
80
|
-
tr = @listing.
|
80
|
+
tr = @listing.request_tour(@account.name, @account.email)
|
81
81
|
assert_equal({}, tr.errors)
|
82
82
|
assert_equal({}, tr.account.errors)
|
83
83
|
# TODO assert_equal({}, tr.listing.errors)
|
84
84
|
assert tr.id
|
85
85
|
end
|
86
86
|
|
87
|
-
test '#
|
87
|
+
test '#request_tour for email on an account' do
|
88
88
|
@account = FactoryGirl.create(:account)
|
89
89
|
@listing = FactoryGirl.create(:listing)
|
90
90
|
|
91
|
-
tr = @listing.
|
91
|
+
tr = @listing.request_tour(@account.name, @account.email)
|
92
92
|
assert_equal({}, tr.errors)
|
93
93
|
assert_equal({}, tr.account.errors)
|
94
94
|
# TODO assert_equal({}, tr.listing.errors)
|
95
95
|
assert tr.id
|
96
96
|
end
|
97
97
|
|
98
|
-
test '#
|
98
|
+
test '#request_tour for an non-existant listing' do
|
99
99
|
@listing = FactoryGirl.build(:listing, :id => 94332)
|
100
100
|
|
101
101
|
assert_raises(MLS::Exception::NotFound) do
|
102
|
-
@listing.
|
102
|
+
@listing.request_tour(Faker::Name.name, Faker::Internet.email)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
test '#
|
106
|
+
test '#request_tour without and account name' do
|
107
107
|
@listing = FactoryGirl.create(:listing)
|
108
108
|
|
109
|
-
tr = @listing.
|
109
|
+
tr = @listing.request_tour('', Faker::Internet.email)
|
110
110
|
assert !tr.id
|
111
111
|
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
|
112
112
|
|
113
|
-
tr = @listing.
|
113
|
+
tr = @listing.request_tour(nil, Faker::Internet.email)
|
114
114
|
assert !tr.id
|
115
115
|
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
|
116
116
|
end
|
117
117
|
|
118
|
-
test '#
|
118
|
+
test '#request_tour without an account email' do
|
119
119
|
@listing = FactoryGirl.create(:listing)
|
120
120
|
|
121
|
-
tr = @listing.
|
121
|
+
tr = @listing.request_tour(Faker::Name.name, '')
|
122
122
|
assert !tr.id
|
123
123
|
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
|
124
124
|
|
125
|
-
tr = @listing.
|
125
|
+
tr = @listing.request_tour(Faker::Name.name, nil)
|
126
126
|
assert !tr.id
|
127
127
|
# assert !tr.persisted? #TODO move to persisted being based of id?
|
128
128
|
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
|
129
129
|
end
|
130
130
|
|
131
|
-
test '#
|
131
|
+
test '#request_tour with an account email' do
|
132
132
|
@account = FactoryGirl.create(:account)
|
133
133
|
@listing = FactoryGirl.create(:listing)
|
134
134
|
|
135
|
-
tr = @listing.
|
135
|
+
tr = @listing.request_tour('', @account.email) # TODO should this try to set the name of the account?
|
136
136
|
assert_equal({}, tr.errors)
|
137
137
|
assert_equal({}, tr.account.errors)
|
138
138
|
# TODO assert_equal({}, tr.listing.errors)
|
@@ -140,17 +140,17 @@ class TestListing < ::Test::Unit::TestCase
|
|
140
140
|
assert tr.persisted?
|
141
141
|
end
|
142
142
|
|
143
|
-
test '#
|
143
|
+
test '#request_tour multiple times for a listing' do
|
144
144
|
@account = FactoryGirl.create(:account)
|
145
145
|
@listing = FactoryGirl.create(:listing)
|
146
146
|
|
147
|
-
tr1 = @listing.
|
147
|
+
tr1 = @listing.request_tour(@account.name, @account.email)
|
148
148
|
assert_equal({}, tr1.errors) # TODO should errors be here for account?
|
149
149
|
assert_equal({}, tr1.account.errors)
|
150
150
|
# TODO assert_equal({}, tr.listing.errors)
|
151
151
|
assert tr1.persisted?
|
152
152
|
|
153
|
-
tr2 = @listing.
|
153
|
+
tr2 = @listing.request_tour(@account.name, @account.email)
|
154
154
|
assert_equal({}, tr2.errors)
|
155
155
|
assert_equal({}, tr2.account.errors)
|
156
156
|
# TODO assert_equal({}, tr.listing.errors)
|
@@ -159,11 +159,11 @@ class TestListing < ::Test::Unit::TestCase
|
|
159
159
|
assert_not_equal tr1.id, tr2.id
|
160
160
|
end
|
161
161
|
|
162
|
-
test '#
|
162
|
+
test '#request_tour with optional info' do
|
163
163
|
@listing = FactoryGirl.create(:listing)
|
164
164
|
|
165
165
|
info = {:company => '42Floors', :population => 10, :funding => 'string thing', :move_in_date => '2012-09-12'}
|
166
|
-
tr = @listing.
|
166
|
+
tr = @listing.request_tour(Faker::Name.name, Faker::Internet.email, info)
|
167
167
|
|
168
168
|
assert tr.id
|
169
169
|
assert_equal '42Floors', info[:company]
|
@@ -171,7 +171,7 @@ class TestListing < ::Test::Unit::TestCase
|
|
171
171
|
assert_equal 'string thing', info[:funding]
|
172
172
|
assert_equal '2012-09-12', info[:move_in_date]
|
173
173
|
|
174
|
-
tr = @listing.
|
174
|
+
tr = @listing.request_tour('', nil, info)
|
175
175
|
assert !tr.id
|
176
176
|
assert_equal '42Floors', info[:company]
|
177
177
|
assert_equal 10, info[:population]
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James R. Bracy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -195,13 +195,13 @@ files:
|
|
195
195
|
- lib/mls/model.rb
|
196
196
|
- lib/mls/models/account.rb
|
197
197
|
- lib/mls/models/address.rb
|
198
|
-
- lib/mls/models/contact.rb
|
199
198
|
- lib/mls/models/floorplan.rb
|
200
199
|
- lib/mls/models/flyer.rb
|
201
200
|
- lib/mls/models/listing.rb
|
202
201
|
- lib/mls/models/pdf.rb
|
203
202
|
- lib/mls/models/photo.rb
|
204
203
|
- lib/mls/models/region.rb
|
204
|
+
- lib/mls/models/tour.rb
|
205
205
|
- lib/mls/models/video.rb
|
206
206
|
- lib/mls/parser.rb
|
207
207
|
- lib/mls/properties/array.rb
|