Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename Tour model to Contact

  • Loading branch information...
commit 4291edeaf324fd943208f7e818c80660f5670833 1 parent eab492c
@darrennix darrennix authored
View
2  lib/mls.rb
@@ -444,7 +444,7 @@ def self.parse(json) # TODO: testme
require 'mls/models/photo'
require 'mls/models/video'
require 'mls/models/pdf'
-require 'mls/models/tour'
+require 'mls/models/contact'
require 'mls/models/flyer'
require 'mls/models/floorplan'
require 'mls/models/region'
View
26 lib/mls/models/tour.rb → lib/mls/models/contact.rb
@@ -1,4 +1,4 @@
-class MLS::Tour < MLS::Resource
+class MLS::Contact < MLS::Resource
property :id, Fixnum
property :status, String
property :client_id, Fixnum
@@ -14,16 +14,16 @@ class MLS::Tour < MLS::Resource
def claim(agent)
self.agent_id = agent.id
- MLS.post("/tours/#{token}/claim", {:agent_id => agent.id})
+ MLS.post("/contacts/#{token}/claim", {:agent_id => agent.id})
end
def decline(notes=nil)
self.agent_comments = notes
- MLS.post("/tours/#{token}/decline", {:agent_comments => notes})
+ MLS.post("/contacts/#{token}/decline", {:agent_comments => notes})
end
def view
- MLS.post("/tours/#{token}/view")
+ MLS.post("/contacts/#{token}/view")
end
def viewed?
@@ -40,25 +40,25 @@ def declined?
class << self
def get_all_for_account
- response = MLS.get('/account/tours')
- MLS::Tour::Parser.parse_collection(response.body)
+ response = MLS.get('/account/contacts')
+ MLS::Contact::Parser.parse_collection(response.body)
end
def find_by_token(token)
- response = MLS.get("/tours/#{token}")
- MLS::Tour::Parser.parse(response.body)
+ response = MLS.get("/contacts/#{token}")
+ MLS::Contact::Parser.parse(response.body)
end
- def create(listing_id, account, tour={})
- params = {:account => account, :tour => tour}
- response = MLS.post("/listings/#{listing_id}/tours", params)
- return MLS::Tour::Parser.parse(response.body)
+ def create(listing_id, account, contact={})
+ params = {:account => account, :contact => contact}
+ response = MLS.post("/listings/#{listing_id}/contacts", params)
+ return MLS::Contact::Parser.parse(response.body)
end
end
end
-class MLS::Tour::Parser < MLS::Parser
+class MLS::Contact::Parser < MLS::Parser
def listing=(listing)
@object.listing = MLS::Listing::Parser.build(listing)
View
16 lib/mls/models/listing.rb
@@ -135,14 +135,14 @@ def space_name
- # Creates a tour request for the listing.
+ # Creates a contact request for the listing.
#
# Paramaters::
#
# * +account+ - A +Hash+ of the user account. Valid keys are:
- # * +:name+ - Name of the User requesting the tour (Required)
- # * +:email+ - Email of the User requesting the tour (Required)
- # * +:phone+ - Phone of the User requesting the tour
+ # * +:name+ - Name of the User requesting the contact (Required)
+ # * +:email+ - Email of the User requesting the contact (Required)
+ # * +:phone+ - Phone of the User requesting the contact
# * +info+ - A optional +Hash+ of *company* info. Valid keys are:
# * +:message+ - Overrides the default message on the email sent to the broker
# * +:company+ - The name of the company that is interested in the space
@@ -154,11 +154,11 @@ def space_name
# #!ruby
# listing = MLS::Listing.find(@id)
# info => {:company => 'name', :population => 10, :funding => 'string', :move_id => '2012-09-12'}
- # listing.request_tour('name', 'email@address.com', info) # => #<MLS::Tour>
+ # listing.request_contact('name', 'email@address.com', info) # => #<MLS::Tour>
#
- # listing.request_tour('', 'emai', info) # => #<MLS::Tour> will have errors on account
- def request_tour(account, tour={})
- MLS::Tour.create(id, account, tour)
+ # listing.request_contact('', 'emai', info) # => #<MLS::Tour> will have errors on account
+ def request_contact(account, contact={})
+ MLS::Tour.create(id, account, contact)
end
View
2  test/factories/tour.rb → test/factories/contact.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
- factory :tour, :class => MLS::Tour do
+ factory :contact, :class => MLS::Tour do
message { Faker::Lorem.paragraph }
company { Faker::Company.email }
population { Kernel.rand(2..200) }
View
0  test/units/models/test_tour.rb → test/units/models/test_contact.rb
File renamed without changes
View
44 test/units/models/test_listing.rb
@@ -60,11 +60,11 @@ def test_class_methods
assert MLS::Listing.respond_to?(:find)
end
- test '#request_tour for email without an account' do
+ test '#request_contact for email without an account' do
@listing = FactoryGirl.create(:listing)
@name = Faker::Name.name
@email = Faker::Internet.email
- tr = @listing.request_tour(@name, @email)
+ tr = @listing.request_contact(@name, @email)
assert_equal({}, tr.errors)
@@ -73,66 +73,66 @@ def test_class_methods
assert tr.id
end
- test '#request_tour for email on a ghost account' do
+ test '#request_contact for email on a ghost account' do
@account = FactoryGirl.create(:ghost_account)
@listing = FactoryGirl.create(:listing)
- tr = @listing.request_tour(@account.name, @account.email)
+ tr = @listing.request_contact(@account.name, @account.email)
assert_equal({}, tr.errors)
assert_equal({}, tr.account.errors)
# TODO assert_equal({}, tr.listing.errors)
assert tr.id
end
- test '#request_tour for email on an account' do
+ test '#request_contact for email on an account' do
@account = FactoryGirl.create(:account)
@listing = FactoryGirl.create(:listing)
- tr = @listing.request_tour(@account.name, @account.email)
+ tr = @listing.request_contact(@account.name, @account.email)
assert_equal({}, tr.errors)
assert_equal({}, tr.account.errors)
# TODO assert_equal({}, tr.listing.errors)
assert tr.id
end
- test '#request_tour for an non-existant listing' do
+ test '#request_contact for an non-existant listing' do
@listing = FactoryGirl.build(:listing, :id => 94332)
assert_raises(MLS::Exception::NotFound) do
- @listing.request_tour(Faker::Name.name, Faker::Internet.email)
+ @listing.request_contact(Faker::Name.name, Faker::Internet.email)
end
end
- test '#request_tour without and account name' do
+ test '#request_contact without and account name' do
@listing = FactoryGirl.create(:listing)
- tr = @listing.request_tour('', Faker::Internet.email)
+ tr = @listing.request_contact('', Faker::Internet.email)
assert !tr.id
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
- tr = @listing.request_tour(nil, Faker::Internet.email)
+ tr = @listing.request_contact(nil, Faker::Internet.email)
assert !tr.id
assert_equal({:name => ["can't be blank"]}, tr.account.errors)
end
- test '#request_tour without an account email' do
+ test '#request_contact without an account email' do
@listing = FactoryGirl.create(:listing)
- tr = @listing.request_tour(Faker::Name.name, '')
+ tr = @listing.request_contact(Faker::Name.name, '')
assert !tr.id
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
- tr = @listing.request_tour(Faker::Name.name, nil)
+ tr = @listing.request_contact(Faker::Name.name, nil)
assert !tr.id
# assert !tr.persisted? #TODO move to persisted being based of id?
assert_equal({:email => ["can't be blank", "is invalid"]}, tr.account.errors)
end
- test '#request_tour with an account email' do
+ test '#request_contact with an account email' do
@account = FactoryGirl.create(:account)
@listing = FactoryGirl.create(:listing)
- tr = @listing.request_tour('', @account.email) # TODO should this try to set the name of the account?
+ tr = @listing.request_contact('', @account.email) # TODO should this try to set the name of the account?
assert_equal({}, tr.errors)
assert_equal({}, tr.account.errors)
# TODO assert_equal({}, tr.listing.errors)
@@ -140,17 +140,17 @@ def test_class_methods
assert tr.persisted?
end
- test '#request_tour multiple times for a listing' do
+ test '#request_contact multiple times for a listing' do
@account = FactoryGirl.create(:account)
@listing = FactoryGirl.create(:listing)
- tr1 = @listing.request_tour(@account.name, @account.email)
+ tr1 = @listing.request_contact(@account.name, @account.email)
assert_equal({}, tr1.errors) # TODO should errors be here for account?
assert_equal({}, tr1.account.errors)
# TODO assert_equal({}, tr.listing.errors)
assert tr1.persisted?
- tr2 = @listing.request_tour(@account.name, @account.email)
+ tr2 = @listing.request_contact(@account.name, @account.email)
assert_equal({}, tr2.errors)
assert_equal({}, tr2.account.errors)
# TODO assert_equal({}, tr.listing.errors)
@@ -159,11 +159,11 @@ def test_class_methods
assert_not_equal tr1.id, tr2.id
end
- test '#request_tour with optional info' do
+ test '#request_contact with optional info' do
@listing = FactoryGirl.create(:listing)
info = {:company => '42Floors', :population => 10, :funding => 'string thing', :move_in_date => '2012-09-12'}
- tr = @listing.request_tour(Faker::Name.name, Faker::Internet.email, info)
+ tr = @listing.request_contact(Faker::Name.name, Faker::Internet.email, info)
assert tr.id
assert_equal '42Floors', info[:company]
@@ -171,7 +171,7 @@ def test_class_methods
assert_equal 'string thing', info[:funding]
assert_equal '2012-09-12', info[:move_in_date]
- tr = @listing.request_tour('', nil, info)
+ tr = @listing.request_contact('', nil, info)
assert !tr.id
assert_equal '42Floors', info[:company]
assert_equal 10, info[:population]
Please sign in to comment.
Something went wrong with that request. Please try again.