mls 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mls.rb +1 -1
- data/lib/mls/models/{tour.rb → contact.rb} +13 -13
- data/lib/mls/models/listing.rb +8 -8
- data/lib/mls/models/region.rb +0 -1
- data/mls.gemspec +1 -1
- data/test/factories/{tour.rb → contact.rb} +1 -1
- data/test/units/models/{test_tour.rb → test_contact.rb} +6 -6
- data/test/units/models/test_listing.rb +22 -22
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e7b94b3481a3cc79638043772e3ef0b37f2edce
|
4
|
+
data.tar.gz: 18c406b48b04203b4bec4286bbcd3230d8bb7a12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a1af89e8d290f0dc52ff7900dd19d96e83c7f2d15313799c39d5a9943a99f3b76c6896f6aa9ed367ce038bbc4233944d6bc18231fc2686c11f64d68dfcf9722
|
7
|
+
data.tar.gz: ed4d7835472a05591ad641e25943fa3b58fb18753f064da168782a701aafaae0663ac91e41fca9e6169aab0d32fa2ed4742ffd55e596a61a0da0a42df3237f04
|
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/contact'
|
438
438
|
require 'mls/models/flyer'
|
439
439
|
require 'mls/models/floorplan'
|
440
440
|
require 'mls/models/region'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class MLS::
|
1
|
+
class MLS::Contact < MLS::Resource
|
2
2
|
property :id, Fixnum
|
3
3
|
property :status, String
|
4
4
|
property :client_id, Fixnum
|
@@ -14,16 +14,16 @@ class MLS::Tour < MLS::Resource
|
|
14
14
|
|
15
15
|
def claim(agent)
|
16
16
|
self.agent_id = agent.id
|
17
|
-
MLS.post("/
|
17
|
+
MLS.post("/contacts/#{token}/claim", {:agent_id => agent.id})
|
18
18
|
end
|
19
19
|
|
20
20
|
def decline(notes=nil)
|
21
21
|
self.agent_comments = notes
|
22
|
-
MLS.post("/
|
22
|
+
MLS.post("/contacts/#{token}/decline", {:agent_comments => notes})
|
23
23
|
end
|
24
24
|
|
25
25
|
def view
|
26
|
-
MLS.post("/
|
26
|
+
MLS.post("/contacts/#{token}/view")
|
27
27
|
end
|
28
28
|
|
29
29
|
def viewed?
|
@@ -40,25 +40,25 @@ class MLS::Tour < MLS::Resource
|
|
40
40
|
|
41
41
|
class << self
|
42
42
|
def get_all_for_account
|
43
|
-
response = MLS.get('/account/
|
44
|
-
MLS::
|
43
|
+
response = MLS.get('/account/contacts')
|
44
|
+
MLS::Contact::Parser.parse_collection(response.body)
|
45
45
|
end
|
46
46
|
|
47
47
|
def find_by_token(token)
|
48
|
-
response = MLS.get("/
|
49
|
-
MLS::
|
48
|
+
response = MLS.get("/contacts/#{token}")
|
49
|
+
MLS::Contact::Parser.parse(response.body)
|
50
50
|
end
|
51
51
|
|
52
|
-
def create(listing_id, account,
|
53
|
-
params = {:account => account, :
|
54
|
-
response = MLS.post("/listings/#{listing_id}/
|
55
|
-
return MLS::
|
52
|
+
def create(listing_id, account, contact={})
|
53
|
+
params = {:account => account, :contact => contact}
|
54
|
+
response = MLS.post("/listings/#{listing_id}/contacts", params)
|
55
|
+
return MLS::Contact::Parser.parse(response.body)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
60
60
|
|
61
|
-
class MLS::
|
61
|
+
class MLS::Contact::Parser < MLS::Parser
|
62
62
|
|
63
63
|
def listing=(listing)
|
64
64
|
@object.listing = MLS::Listing::Parser.build(listing)
|
data/lib/mls/models/listing.rb
CHANGED
@@ -137,14 +137,14 @@ class MLS::Listing < MLS::Resource
|
|
137
137
|
|
138
138
|
|
139
139
|
|
140
|
-
# Creates a
|
140
|
+
# Creates a contact request for the listing.
|
141
141
|
#
|
142
142
|
# Paramaters::
|
143
143
|
#
|
144
144
|
# * +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
|
145
|
+
# * +:name+ - Name of the User requesting the contact (Required)
|
146
|
+
# * +:email+ - Email of the User requesting the contact (Required)
|
147
|
+
# * +:phone+ - Phone of the User requesting the contact
|
148
148
|
# * +info+ - A optional +Hash+ of *company* info. Valid keys are:
|
149
149
|
# * +:message+ - Overrides the default message on the email sent to the broker
|
150
150
|
# * +:company+ - The name of the company that is interested in the space
|
@@ -156,11 +156,11 @@ class MLS::Listing < MLS::Resource
|
|
156
156
|
# #!ruby
|
157
157
|
# listing = MLS::Listing.find(@id)
|
158
158
|
# info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
|
159
|
-
# listing.
|
159
|
+
# listing.request_contact('name', 'email@address.com', info) # => #<MLS::Contact>
|
160
160
|
#
|
161
|
-
# listing.
|
162
|
-
def
|
163
|
-
MLS::
|
161
|
+
# listing.request_contact('', 'emai', info) # => #<MLS::Contact> will have errors on account
|
162
|
+
def request_contact(account, contact={})
|
163
|
+
MLS::Contact.create(id, account, contact)
|
164
164
|
end
|
165
165
|
|
166
166
|
|
data/lib/mls/models/region.rb
CHANGED
@@ -4,7 +4,6 @@ class MLS::Region < MLS::Resource
|
|
4
4
|
property :name, String, :serialize => false
|
5
5
|
property :proper_name, String, :serialize => :if_present
|
6
6
|
property :common_name, String, :serialize => :if_present
|
7
|
-
property :description, String, :serialize => :if_present
|
8
7
|
property :code, String, :serialize => :if_present
|
9
8
|
property :type, String, :serialize => :if_present
|
10
9
|
property :source, String, :serialize => :if_present
|
data/mls.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestContact < ::Test::Unit::TestCase
|
4
4
|
|
5
5
|
# def test_properties
|
6
|
-
# tr = MLS::
|
6
|
+
# tr = MLS::Contact.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::Contact.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::Contact.respond_to?(:get_all_for_account)
|
19
|
+
# assert MLS::Contact.respond_to?(:create)
|
20
20
|
# end
|
21
21
|
#
|
22
22
|
# def test_parser
|
23
|
-
# assert defined?(MLS::
|
23
|
+
# assert defined?(MLS::Contact::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_contact 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_contact(@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_contact 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_contact(@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_contact 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_contact(@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_contact 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_contact(Faker::Name.name, Faker::Internet.email)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
test '#
|
106
|
+
test '#request_contact without and account name' do
|
107
107
|
@listing = FactoryGirl.create(:listing)
|
108
108
|
|
109
|
-
tr = @listing.
|
109
|
+
tr = @listing.request_contact('', 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_contact(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_contact without an account email' do
|
119
119
|
@listing = FactoryGirl.create(:listing)
|
120
120
|
|
121
|
-
tr = @listing.
|
121
|
+
tr = @listing.request_contact(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_contact(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_contact 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_contact('', @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_contact 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_contact(@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_contact(@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_contact 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_contact(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_contact('', 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.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James R. Bracy
|
@@ -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
|
198
199
|
- lib/mls/models/floorplan.rb
|
199
200
|
- lib/mls/models/flyer.rb
|
200
201
|
- lib/mls/models/listing.rb
|
201
202
|
- lib/mls/models/pdf.rb
|
202
203
|
- lib/mls/models/photo.rb
|
203
204
|
- 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
|
@@ -237,16 +237,16 @@ files:
|
|
237
237
|
- mls.gemspec
|
238
238
|
- test/factories/account.rb
|
239
239
|
- test/factories/address.rb
|
240
|
+
- test/factories/contact.rb
|
240
241
|
- test/factories/listing.rb
|
241
|
-
- test/factories/tour.rb
|
242
242
|
- test/fixtures/flyer.pdf
|
243
243
|
- test/test_helper.rb
|
244
244
|
- test/units/models/test_account.rb
|
245
245
|
- test/units/models/test_address.rb
|
246
|
+
- test/units/models/test_contact.rb
|
246
247
|
- test/units/models/test_flyer.rb
|
247
248
|
- test/units/models/test_listing.rb
|
248
249
|
- test/units/models/test_photo.rb
|
249
|
-
- test/units/models/test_tour.rb
|
250
250
|
- test/units/properties/test_boolean.rb
|
251
251
|
- test/units/test_errors.rb
|
252
252
|
- test/units/test_mls.rb
|
@@ -280,16 +280,16 @@ summary: 42Floors MLS Client
|
|
280
280
|
test_files:
|
281
281
|
- test/factories/account.rb
|
282
282
|
- test/factories/address.rb
|
283
|
+
- test/factories/contact.rb
|
283
284
|
- test/factories/listing.rb
|
284
|
-
- test/factories/tour.rb
|
285
285
|
- test/fixtures/flyer.pdf
|
286
286
|
- test/test_helper.rb
|
287
287
|
- test/units/models/test_account.rb
|
288
288
|
- test/units/models/test_address.rb
|
289
|
+
- test/units/models/test_contact.rb
|
289
290
|
- test/units/models/test_flyer.rb
|
290
291
|
- test/units/models/test_listing.rb
|
291
292
|
- test/units/models/test_photo.rb
|
292
|
-
- test/units/models/test_tour.rb
|
293
293
|
- test/units/properties/test_boolean.rb
|
294
294
|
- test/units/test_errors.rb
|
295
295
|
- test/units/test_mls.rb
|