spark_api 1.0.0
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.
- data/History.txt +139 -0
- data/LICENSE +14 -0
- data/README.md +153 -0
- data/Rakefile +18 -0
- data/VERSION +1 -0
- data/bin/spark_api +8 -0
- data/bin/spark_api~ +8 -0
- data/lib/spark_api.rb +46 -0
- data/lib/spark_api/authentication.rb +55 -0
- data/lib/spark_api/authentication/api_auth.rb +104 -0
- data/lib/spark_api/authentication/api_auth.rb~ +104 -0
- data/lib/spark_api/authentication/base_auth.rb +47 -0
- data/lib/spark_api/authentication/base_auth.rb~ +47 -0
- data/lib/spark_api/authentication/oauth2.rb +198 -0
- data/lib/spark_api/authentication/oauth2.rb~ +199 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +87 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb~ +87 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_code.rb +48 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_code.rb~ +49 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_password.rb +44 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_password.rb~ +45 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb +35 -0
- data/lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb~ +36 -0
- data/lib/spark_api/authentication/oauth2_impl/middleware.rb +38 -0
- data/lib/spark_api/authentication/oauth2_impl/middleware.rb~ +39 -0
- data/lib/spark_api/authentication/oauth2_impl/password_provider.rb +24 -0
- data/lib/spark_api/authentication/oauth2_impl/password_provider.rb~ +25 -0
- data/lib/spark_api/cli.rb +158 -0
- data/lib/spark_api/cli.rb~ +158 -0
- data/lib/spark_api/cli/api_auth.rb +8 -0
- data/lib/spark_api/cli/api_auth.rb~ +8 -0
- data/lib/spark_api/cli/oauth2.rb +14 -0
- data/lib/spark_api/cli/oauth2.rb~ +14 -0
- data/lib/spark_api/cli/setup.rb +47 -0
- data/lib/spark_api/cli/setup.rb~ +47 -0
- data/lib/spark_api/client.rb +27 -0
- data/lib/spark_api/configuration.rb +54 -0
- data/lib/spark_api/configuration.rb~ +54 -0
- data/lib/spark_api/configuration/yaml.rb +101 -0
- data/lib/spark_api/configuration/yaml.rb~ +101 -0
- data/lib/spark_api/connection.rb +42 -0
- data/lib/spark_api/faraday.rb +64 -0
- data/lib/spark_api/faraday.rb~ +64 -0
- data/lib/spark_api/models.rb +33 -0
- data/lib/spark_api/models.rb~ +33 -0
- data/lib/spark_api/models/account.rb +115 -0
- data/lib/spark_api/models/account.rb~ +115 -0
- data/lib/spark_api/models/base.rb +118 -0
- data/lib/spark_api/models/base.rb~ +118 -0
- data/lib/spark_api/models/connect_prefs.rb +10 -0
- data/lib/spark_api/models/connect_prefs.rb~ +10 -0
- data/lib/spark_api/models/constraint.rb +16 -0
- data/lib/spark_api/models/constraint.rb~ +16 -0
- data/lib/spark_api/models/contact.rb +49 -0
- data/lib/spark_api/models/contact.rb~ +49 -0
- data/lib/spark_api/models/custom_fields.rb +12 -0
- data/lib/spark_api/models/custom_fields.rb~ +12 -0
- data/lib/spark_api/models/document.rb +11 -0
- data/lib/spark_api/models/document.rb~ +11 -0
- data/lib/spark_api/models/finders.rb +45 -0
- data/lib/spark_api/models/finders.rb~ +45 -0
- data/lib/spark_api/models/idx_link.rb +47 -0
- data/lib/spark_api/models/idx_link.rb~ +47 -0
- data/lib/spark_api/models/listing.rb +197 -0
- data/lib/spark_api/models/listing.rb~ +197 -0
- data/lib/spark_api/models/listing_cart.rb +72 -0
- data/lib/spark_api/models/listing_cart.rb~ +72 -0
- data/lib/spark_api/models/market_statistics.rb +33 -0
- data/lib/spark_api/models/market_statistics.rb~ +33 -0
- data/lib/spark_api/models/message.rb +21 -0
- data/lib/spark_api/models/message.rb~ +21 -0
- data/lib/spark_api/models/note.rb +41 -0
- data/lib/spark_api/models/note.rb~ +41 -0
- data/lib/spark_api/models/notification.rb +42 -0
- data/lib/spark_api/models/notification.rb~ +42 -0
- data/lib/spark_api/models/open_house.rb +24 -0
- data/lib/spark_api/models/open_house.rb~ +24 -0
- data/lib/spark_api/models/photo.rb +70 -0
- data/lib/spark_api/models/photo.rb~ +70 -0
- data/lib/spark_api/models/property_types.rb +7 -0
- data/lib/spark_api/models/property_types.rb~ +7 -0
- data/lib/spark_api/models/saved_search.rb +16 -0
- data/lib/spark_api/models/saved_search.rb~ +16 -0
- data/lib/spark_api/models/shared_listing.rb +35 -0
- data/lib/spark_api/models/shared_listing.rb~ +35 -0
- data/lib/spark_api/models/standard_fields.rb +50 -0
- data/lib/spark_api/models/standard_fields.rb~ +50 -0
- data/lib/spark_api/models/subresource.rb +19 -0
- data/lib/spark_api/models/subresource.rb~ +19 -0
- data/lib/spark_api/models/system_info.rb +14 -0
- data/lib/spark_api/models/system_info.rb~ +14 -0
- data/lib/spark_api/models/tour_of_home.rb +24 -0
- data/lib/spark_api/models/tour_of_home.rb~ +24 -0
- data/lib/spark_api/models/video.rb +16 -0
- data/lib/spark_api/models/video.rb~ +16 -0
- data/lib/spark_api/models/virtual_tour.rb +18 -0
- data/lib/spark_api/models/virtual_tour.rb~ +18 -0
- data/lib/spark_api/multi_client.rb +59 -0
- data/lib/spark_api/multi_client.rb~ +59 -0
- data/lib/spark_api/paginate.rb +109 -0
- data/lib/spark_api/paginate.rb~ +109 -0
- data/lib/spark_api/primary_array.rb +29 -0
- data/lib/spark_api/primary_array.rb~ +29 -0
- data/lib/spark_api/request.rb +96 -0
- data/lib/spark_api/request.rb~ +96 -0
- data/lib/spark_api/response.rb +70 -0
- data/lib/spark_api/response.rb~ +70 -0
- data/lib/spark_api/version.rb +4 -0
- data/lib/spark_api/version.rb~ +4 -0
- data/script/console +6 -0
- data/script/console~ +6 -0
- data/script/example.rb +27 -0
- data/script/example.rb~ +27 -0
- data/spec/fixtures/accounts/all.json +160 -0
- data/spec/fixtures/accounts/my.json +74 -0
- data/spec/fixtures/accounts/my_portal.json +20 -0
- data/spec/fixtures/accounts/my_put.json +5 -0
- data/spec/fixtures/accounts/my_save.json +5 -0
- data/spec/fixtures/accounts/office.json +142 -0
- data/spec/fixtures/accounts/password_save.json +6 -0
- data/spec/fixtures/authentication_failure.json +7 -0
- data/spec/fixtures/base.json +13 -0
- data/spec/fixtures/contacts/contacts.json +28 -0
- data/spec/fixtures/contacts/my.json +19 -0
- data/spec/fixtures/contacts/new.json +11 -0
- data/spec/fixtures/contacts/new_empty.json +8 -0
- data/spec/fixtures/contacts/new_notify.json +11 -0
- data/spec/fixtures/contacts/post.json +10 -0
- data/spec/fixtures/contacts/tags.json +11 -0
- data/spec/fixtures/count.json +10 -0
- data/spec/fixtures/empty.json +3 -0
- data/spec/fixtures/errors/expired.json +7 -0
- data/spec/fixtures/errors/failure.json +5 -0
- data/spec/fixtures/errors/failure_with_constraint.json +17 -0
- data/spec/fixtures/errors/failure_with_msg.json +7 -0
- data/spec/fixtures/generic_delete.json +1 -0
- data/spec/fixtures/generic_failure.json +5 -0
- data/spec/fixtures/listing_carts/add_listing.json +13 -0
- data/spec/fixtures/listing_carts/add_listing_post.json +5 -0
- data/spec/fixtures/listing_carts/empty.json +5 -0
- data/spec/fixtures/listing_carts/listing_cart.json +19 -0
- data/spec/fixtures/listing_carts/new.json +12 -0
- data/spec/fixtures/listing_carts/post.json +10 -0
- data/spec/fixtures/listing_carts/remove_listing.json +13 -0
- data/spec/fixtures/listings/constraints.json +18 -0
- data/spec/fixtures/listings/constraints_with_pagination.json +24 -0
- data/spec/fixtures/listings/document_index.json +19 -0
- data/spec/fixtures/listings/multiple.json +69 -0
- data/spec/fixtures/listings/no_subresources.json +38 -0
- data/spec/fixtures/listings/open_houses.json +21 -0
- data/spec/fixtures/listings/photos/index.json +469 -0
- data/spec/fixtures/listings/photos/new.json +12 -0
- data/spec/fixtures/listings/photos/post.json +20 -0
- data/spec/fixtures/listings/put.json +5 -0
- data/spec/fixtures/listings/put_expiration_date.json +5 -0
- data/spec/fixtures/listings/saved_search.json +17 -0
- data/spec/fixtures/listings/shared_listing_get.json +14 -0
- data/spec/fixtures/listings/shared_listing_new.json +9 -0
- data/spec/fixtures/listings/shared_listing_post.json +10 -0
- data/spec/fixtures/listings/tour_of_homes.json +23 -0
- data/spec/fixtures/listings/videos_index.json +18 -0
- data/spec/fixtures/listings/virtual_tours_index.json +42 -0
- data/spec/fixtures/listings/with_documents.json +52 -0
- data/spec/fixtures/listings/with_permissions.json +44 -0
- data/spec/fixtures/listings/with_photos.json +110 -0
- data/spec/fixtures/listings/with_supplement.json +39 -0
- data/spec/fixtures/listings/with_videos.json +54 -0
- data/spec/fixtures/listings/with_vtour.json +48 -0
- data/spec/fixtures/logo_fbs.png +0 -0
- data/spec/fixtures/messages/new.json +14 -0
- data/spec/fixtures/messages/new_empty.json +7 -0
- data/spec/fixtures/messages/new_with_recipients.json +15 -0
- data/spec/fixtures/messages/post.json +5 -0
- data/spec/fixtures/notes/add.json +11 -0
- data/spec/fixtures/notes/agent_shared.json +11 -0
- data/spec/fixtures/notes/agent_shared_empty.json +7 -0
- data/spec/fixtures/notes/new.json +5 -0
- data/spec/fixtures/notifications/mark_read.json +1 -0
- data/spec/fixtures/notifications/new.json +8 -0
- data/spec/fixtures/notifications/new_empty.json +7 -0
- data/spec/fixtures/notifications/notifications.json +43 -0
- data/spec/fixtures/notifications/post.json +10 -0
- data/spec/fixtures/notifications/unread.json +10 -0
- data/spec/fixtures/oauth2/access.json +3 -0
- data/spec/fixtures/oauth2/access_with_old_refresh.json +5 -0
- data/spec/fixtures/oauth2/access_with_refresh.json +5 -0
- data/spec/fixtures/oauth2/authorization_code_body.json +7 -0
- data/spec/fixtures/oauth2/error.json +3 -0
- data/spec/fixtures/oauth2/password_body.json +7 -0
- data/spec/fixtures/oauth2/refresh_body.json +7 -0
- data/spec/fixtures/oauth2_error.json +3 -0
- data/spec/fixtures/property_types/property_types.json +31 -0
- data/spec/fixtures/session.json +10 -0
- data/spec/fixtures/standardfields/city.json +1031 -0
- data/spec/fixtures/standardfields/nearby.json +53 -0
- data/spec/fixtures/standardfields/standardfields.json +188 -0
- data/spec/fixtures/standardfields/stateorprovince.json +36 -0
- data/spec/fixtures/success.json +5 -0
- data/spec/json_helper.rb +76 -0
- data/spec/mock_helper.rb +124 -0
- data/spec/oauth2_helper.rb +68 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/unit/flexmls_api_spec.rb~ +23 -0
- data/spec/unit/spark_api/authentication/api_auth_spec.rb +169 -0
- data/spec/unit/spark_api/authentication/api_auth_spec.rb~ +169 -0
- data/spec/unit/spark_api/authentication/base_auth_spec.rb +10 -0
- data/spec/unit/spark_api/authentication/base_auth_spec.rb~ +10 -0
- data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +10 -0
- data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb~ +10 -0
- data/spec/unit/spark_api/authentication/oauth2_spec.rb +205 -0
- data/spec/unit/spark_api/authentication/oauth2_spec.rb~ +205 -0
- data/spec/unit/spark_api/authentication_spec.rb +38 -0
- data/spec/unit/spark_api/authentication_spec.rb~ +38 -0
- data/spec/unit/spark_api/configuration/yaml_spec.rb +72 -0
- data/spec/unit/spark_api/configuration/yaml_spec.rb~ +72 -0
- data/spec/unit/spark_api/configuration_spec.rb +122 -0
- data/spec/unit/spark_api/configuration_spec.rb~ +122 -0
- data/spec/unit/spark_api/faraday_spec.rb +90 -0
- data/spec/unit/spark_api/faraday_spec.rb~ +90 -0
- data/spec/unit/spark_api/models/account_spec.rb +176 -0
- data/spec/unit/spark_api/models/base_spec.rb +106 -0
- data/spec/unit/spark_api/models/connect_prefs_spec.rb +9 -0
- data/spec/unit/spark_api/models/constraint_spec.rb +19 -0
- data/spec/unit/spark_api/models/contact_spec.rb +108 -0
- data/spec/unit/spark_api/models/contact_spec.rb~ +108 -0
- data/spec/unit/spark_api/models/document_spec.rb +32 -0
- data/spec/unit/spark_api/models/listing_cart_spec.rb +127 -0
- data/spec/unit/spark_api/models/listing_cart_spec.rb~ +127 -0
- data/spec/unit/spark_api/models/listing_spec.rb +320 -0
- data/spec/unit/spark_api/models/listing_spec.rb~ +320 -0
- data/spec/unit/spark_api/models/message_spec.rb +47 -0
- data/spec/unit/spark_api/models/message_spec.rb~ +47 -0
- data/spec/unit/spark_api/models/note_spec.rb +63 -0
- data/spec/unit/spark_api/models/note_spec.rb~ +63 -0
- data/spec/unit/spark_api/models/notification_spec.rb +62 -0
- data/spec/unit/spark_api/models/notification_spec.rb~ +62 -0
- data/spec/unit/spark_api/models/open_house_spec.rb +39 -0
- data/spec/unit/spark_api/models/photo_spec.rb +92 -0
- data/spec/unit/spark_api/models/property_types_spec.rb +33 -0
- data/spec/unit/spark_api/models/saved_search_spec.rb +40 -0
- data/spec/unit/spark_api/models/shared_listing_spec.rb +45 -0
- data/spec/unit/spark_api/models/shared_listing_spec.rb~ +45 -0
- data/spec/unit/spark_api/models/standard_fields_spec.rb +60 -0
- data/spec/unit/spark_api/models/system_info_spec.rb +83 -0
- data/spec/unit/spark_api/models/tour_of_home_spec.rb +44 -0
- data/spec/unit/spark_api/models/video_spec.rb +36 -0
- data/spec/unit/spark_api/models/virtual_tour_spec.rb +44 -0
- data/spec/unit/spark_api/multi_client_spec.rb +56 -0
- data/spec/unit/spark_api/multi_client_spec.rb~ +56 -0
- data/spec/unit/spark_api/paginate_spec.rb +224 -0
- data/spec/unit/spark_api/paginate_spec.rb~ +224 -0
- data/spec/unit/spark_api/primary_array_spec.rb +41 -0
- data/spec/unit/spark_api/primary_array_spec.rb~ +41 -0
- data/spec/unit/spark_api/request_spec.rb +344 -0
- data/spec/unit/spark_api/request_spec.rb~ +344 -0
- data/spec/unit/spark_api_spec.rb +23 -0
- metadata +725 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe PropertyTypes do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@proptypes = PropertyTypes.new({
|
|
6
|
+
"MlsName"=>"Residential",
|
|
7
|
+
"MlsCode"=>"A"
|
|
8
|
+
})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should respond to get" do
|
|
12
|
+
PropertyTypes.should respond_to(:get)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "/propertytypes", :support do
|
|
16
|
+
before(:each) do
|
|
17
|
+
stub_auth_request
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
on_get_it "should return a list of property types" do
|
|
21
|
+
stub_api_get("/propertytypes", "property_types/property_types.json")
|
|
22
|
+
|
|
23
|
+
types = PropertyTypes.get
|
|
24
|
+
types.should be_an(Array)
|
|
25
|
+
types.count.should be(6)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after(:each) do
|
|
30
|
+
@proptypes = nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SavedSearch do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
stub_auth_request
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
let(:id){ "20100815220615294367000000" }
|
|
10
|
+
|
|
11
|
+
context "/savedsearches", :support do
|
|
12
|
+
on_get_it "should get all SavedSearches" do
|
|
13
|
+
stub_api_get("/#{subject.class.element_name}", 'listings/saved_search.json')
|
|
14
|
+
resources = subject.class.get
|
|
15
|
+
resources.should be_an(Array)
|
|
16
|
+
resources.length.should eq(2)
|
|
17
|
+
resources.first.Id.should eq(id)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "/savedsearches/<search_id>", :support do
|
|
22
|
+
on_get_it "should get a SavedSearch" do
|
|
23
|
+
stub_api_get("/#{subject.class.element_name}/#{id}", 'listings/saved_search.json')
|
|
24
|
+
resource = subject.class.find(id)
|
|
25
|
+
resource.Id.should eq(id)
|
|
26
|
+
resource.Name.should eq("Search name here")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "/provided/savedsearches", :support do
|
|
31
|
+
on_get_it "should get provided SavedSearches" do
|
|
32
|
+
stub_api_get("/provided/#{subject.class.element_name}", 'listings/saved_search.json')
|
|
33
|
+
resources = subject.class.provided.get
|
|
34
|
+
resources.should be_an(Array)
|
|
35
|
+
resources.length.should eq(2)
|
|
36
|
+
resources.first.Id.should eq(id)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe SharedListing do
|
|
5
|
+
before(:each) do
|
|
6
|
+
stub_auth_request
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should respond to the finders" do
|
|
10
|
+
SharedListing.should respond_to(:find)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "/sharedlistings", :support do
|
|
14
|
+
on_post_it "should create shared listings" do
|
|
15
|
+
stub_api_post("/#{subject.class.element_name}", 'listings/shared_listing_new.json', 'listings/shared_listing_post.json')
|
|
16
|
+
subject.ListingIds = ["20110224152431857619000000","20110125122333785431000000"]
|
|
17
|
+
subject.ViewId = "20080125122333787615000000"
|
|
18
|
+
subject.save.should be(true)
|
|
19
|
+
subject.ResourceUri.should eq("http://www.flexmls.com/share/15Ar/3544-N-Olsen-Avenue-Tucson-AZ-85719")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
on_post_it "should fail creating" do
|
|
23
|
+
stub_api_post("/#{subject.class.element_name}",'empty.json') do |request|
|
|
24
|
+
request.to_return(:status => 400, :body => fixture('errors/failure.json'))
|
|
25
|
+
end
|
|
26
|
+
subject
|
|
27
|
+
subject.save.should be(false)
|
|
28
|
+
expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.should == 400 }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "/sharedlistings/<shared_listing_id>", :support do
|
|
33
|
+
on_get_it "should get shared listing" do
|
|
34
|
+
shared_id = '15Ar'
|
|
35
|
+
stub_api_get("/#{subject.class.element_name}/#{shared_id}",
|
|
36
|
+
'listings/shared_listing_get.json')
|
|
37
|
+
|
|
38
|
+
shared = SharedListing.find(shared_id)
|
|
39
|
+
shared.should respond_to('SharedUri')
|
|
40
|
+
shared.Mode.should eq('Public')
|
|
41
|
+
shared.ListingIds.should be_an(Array)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
describe SharedListing do
|
|
5
|
+
before(:each) do
|
|
6
|
+
stub_auth_request
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should respond to the finders" do
|
|
10
|
+
SharedListing.should respond_to(:find)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "/sharedlistings", :support do
|
|
14
|
+
on_post_it "should create shared listings" do
|
|
15
|
+
stub_api_post("/#{subject.class.element_name}", 'listings/shared_listing_new.json', 'listings/shared_listing_post.json')
|
|
16
|
+
subject.ListingIds = ["20110224152431857619000000","20110125122333785431000000"]
|
|
17
|
+
subject.ViewId = "20080125122333787615000000"
|
|
18
|
+
subject.save.should be(true)
|
|
19
|
+
subject.ResourceUri.should eq("http://www.flexmls.com/share/15Ar/3544-N-Olsen-Avenue-Tucson-AZ-85719")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
on_post_it "should fail creating" do
|
|
23
|
+
stub_api_post("/#{subject.class.element_name}",'empty.json') do |request|
|
|
24
|
+
request.to_return(:status => 400, :body => fixture('errors/failure.json'))
|
|
25
|
+
end
|
|
26
|
+
subject
|
|
27
|
+
subject.save.should be(false)
|
|
28
|
+
expect{ subject.save! }.to raise_error(FlexmlsApi::ClientError){ |e| e.status.should == 400 }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "/sharedlistings/<shared_listing_id>", :support do
|
|
33
|
+
on_get_it "should get shared listing" do
|
|
34
|
+
shared_id = '15Ar'
|
|
35
|
+
stub_api_get("/#{subject.class.element_name}/#{shared_id}",
|
|
36
|
+
'listings/shared_listing_get.json')
|
|
37
|
+
|
|
38
|
+
shared = SharedListing.find(shared_id)
|
|
39
|
+
shared.should respond_to('SharedUri')
|
|
40
|
+
shared.Mode.should eq('Public')
|
|
41
|
+
shared.ListingIds.should be_an(Array)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe StandardFields do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
stub_auth_request
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should respond to get" do
|
|
10
|
+
StandardFields.should respond_to(:get)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should find and expand all" do
|
|
14
|
+
StandardFields.should respond_to(:find_and_expand_all)
|
|
15
|
+
|
|
16
|
+
# stub request to standardFields
|
|
17
|
+
stub_api_get('/standardfields','standardfields/standardfields.json')
|
|
18
|
+
|
|
19
|
+
# stub request for City
|
|
20
|
+
stub_api_get('/standardfields/City','standardfields/city.json')
|
|
21
|
+
|
|
22
|
+
# stub request for StateOrProvince
|
|
23
|
+
stub_api_get('/standardfields/StateOrProvince','standardfields/stateorprovince.json')
|
|
24
|
+
|
|
25
|
+
# request
|
|
26
|
+
fields = StandardFields.find_and_expand_all(["City","StateOrProvince"])
|
|
27
|
+
|
|
28
|
+
# keys are present
|
|
29
|
+
fields.should have_key("City")
|
|
30
|
+
fields.should have_key("StateOrProvince")
|
|
31
|
+
fields.should_not have_key("SubdivisionName")
|
|
32
|
+
|
|
33
|
+
# FieldList
|
|
34
|
+
fields["City"]["FieldList"].length.should eq(235)
|
|
35
|
+
fields["StateOrProvince"]["FieldList"].length.should eq(5)
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "/standardfields/nearby/<property_type>", :support do
|
|
40
|
+
on_get_it "should find nearby fields" do
|
|
41
|
+
StandardFields.should respond_to(:find_nearby)
|
|
42
|
+
|
|
43
|
+
# stub request
|
|
44
|
+
stub_api_get('/standardfields/nearby/A','standardfields/nearby.json',
|
|
45
|
+
:Lat => "50",
|
|
46
|
+
:Lon => "-92",
|
|
47
|
+
:_expand => "1")
|
|
48
|
+
|
|
49
|
+
# request
|
|
50
|
+
fields = StandardFields.find_nearby(["A"], {:Lat => 50, :Lon => -92})
|
|
51
|
+
|
|
52
|
+
# validate response
|
|
53
|
+
fields["D"]["Success"].should eq(true)
|
|
54
|
+
fields["D"]["Results"].first.should have_key("City")
|
|
55
|
+
fields["D"]["Results"].first.should have_key("PostalCode")
|
|
56
|
+
fields["D"]["Results"].first.should have_key("StateOrProvince")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe SystemInfo do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@sysinfo = SystemInfo.new({
|
|
6
|
+
"Name"=>"beh apiuser",
|
|
7
|
+
"OfficeId"=>"20071029204441159539000000",
|
|
8
|
+
"Configuration"=>[{
|
|
9
|
+
"IdxDisclaimer"=>""
|
|
10
|
+
}],
|
|
11
|
+
"Id"=>"20101206154326670813000000",
|
|
12
|
+
"MlsId"=>"20000809145531659995000000",
|
|
13
|
+
"Office"=>"",
|
|
14
|
+
"Mls"=>"Fargo-Moorhead MLS"
|
|
15
|
+
})
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should respond to get" do
|
|
19
|
+
SystemInfo.should respond_to(:get)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should have a primary_logo instance method" do
|
|
23
|
+
@sysinfo.should respond_to(:primary_logo)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should respond to attributes" do
|
|
27
|
+
['Name','OfficeId','Id','MlsId','Office','Mls'].each do |k|
|
|
28
|
+
(@sysinfo.send k.to_sym).should be_a(String)
|
|
29
|
+
end
|
|
30
|
+
@sysinfo.Configuration.should be_a(Array)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should have an array of config items" do
|
|
34
|
+
@sysinfo.Configuration.should be_a(Array)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "#primary_logo" do
|
|
38
|
+
before(:each) do
|
|
39
|
+
@sysinfo_with_logos = SystemInfo.new({
|
|
40
|
+
"Name"=>"Brandon Reg1",
|
|
41
|
+
"OfficeId"=>"20080904154102121828000000",
|
|
42
|
+
"Configuration"=>[{
|
|
43
|
+
"MlsLogos"=>[
|
|
44
|
+
{"Uri"=>"http://images.dev.fbsdata.com/eup/20110406184939446866000000.jpg", "Name:"=>"logo and stuff"},
|
|
45
|
+
{"Uri"=>"http://images.dev.fbsdata.com/eup/20110406191929838053000000.jpg", "Name:"=>"tried it"}
|
|
46
|
+
],
|
|
47
|
+
"IdxDisclaimer"=>"",
|
|
48
|
+
"IdxLogoSmall"=>"",
|
|
49
|
+
"IdxLogo"=>"http://images.dev.fbsdata.com/eup/20110406184939446866000000.jpg"
|
|
50
|
+
}],
|
|
51
|
+
"Id"=>"20080904155327755059000000",
|
|
52
|
+
"MlsId"=>"20041217205818829687000000",
|
|
53
|
+
"Office"=>"Brandon Office1",
|
|
54
|
+
"Mls"=>"Eastern Upper Peninsula"
|
|
55
|
+
})
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should return nil when no logo is present" do
|
|
59
|
+
@sysinfo.primary_logo.should == nil
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should return the first logo when several are present" do
|
|
63
|
+
@sysinfo_with_logos.primary_logo.should be_a(Hash)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "/system", :support do
|
|
68
|
+
on_get_it "should return system settings and configuration"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context "/system/languages", :support do
|
|
72
|
+
on_get_it "should return a list of languages"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "/system/accounts", :support do
|
|
76
|
+
on_get_it "should return account metadata"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
after(:each) do
|
|
80
|
+
@sysinfo = nil
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
require 'time'
|
|
4
|
+
|
|
5
|
+
describe TourOfHome do
|
|
6
|
+
subject do
|
|
7
|
+
TourOfHome.new(
|
|
8
|
+
'ResourceUri'=>"/listings/20060725224713296297000000/tourofhomes/20101127153422574618000000",
|
|
9
|
+
'Id'=>"20101127153422574618000000",
|
|
10
|
+
'Date'=>"10/01/2010",
|
|
11
|
+
'StartTime'=>"09:00:00-07:00",
|
|
12
|
+
'EndTime'=>"23:00:00-07:00",
|
|
13
|
+
'Comments'=>"Wonderful home; must see!",
|
|
14
|
+
'AdditionalInfo'=> [{"Hosted By"=>"Joe Smith"}, {"Host Phone"=>"123-456-7890"}, {"Tour Area"=>"North-Central"}]
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should respond to a few methods" do
|
|
19
|
+
subject.class.should respond_to(:find_by_listing_key)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should return tour date and times" do
|
|
23
|
+
start_time = DateTime.new(2010,10,1,9,0,0, "-0700")
|
|
24
|
+
end_time = DateTime.new(2010,10,1,23,0,0, "-0700")
|
|
25
|
+
subject.Date.should eq(Date.new(2010,10,1))
|
|
26
|
+
subject.StartTime.should eq(Time.parse(start_time.to_s))
|
|
27
|
+
subject.EndTime.should eq(Time.parse(end_time.to_s))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "/listings/<listing_id>/tourofhomes", :support do
|
|
31
|
+
on_get_it "should get home tours for a listing" do
|
|
32
|
+
stub_auth_request
|
|
33
|
+
stub_api_get('/listings/20060725224713296297000000/tourofhomes','listings/tour_of_homes.json')
|
|
34
|
+
v = subject.class.find_by_listing_key('20060725224713296297000000')
|
|
35
|
+
v.should be_an(Array)
|
|
36
|
+
v.length.should == 2
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "/listings/<listing_id>/tourofhomes/<tour_id>", :support do
|
|
41
|
+
on_get_it "should get information for a single tour of a home"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Video do
|
|
4
|
+
|
|
5
|
+
it "responds to" do
|
|
6
|
+
Video.should respond_to(:find_by_listing_key)
|
|
7
|
+
Video.new.should respond_to(:branded?)
|
|
8
|
+
Video.new.should respond_to(:unbranded?)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "has a type" do
|
|
12
|
+
Video.new(:Type => "branded").branded?.should == true
|
|
13
|
+
Video.new(:Type => "unbranded").branded?.should == false
|
|
14
|
+
Video.new(:Type => "unbranded").unbranded?.should == true
|
|
15
|
+
Video.new(:Type => "branded").unbranded?.should == false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "/listings/<listing_id>/videos", :support do
|
|
19
|
+
before do
|
|
20
|
+
stub_auth_request
|
|
21
|
+
stub_api_get('/listings/1234/videos','listings/videos_index.json')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
on_get_it "should get an array of videos" do
|
|
25
|
+
p = Video.find_by_listing_key('1234')
|
|
26
|
+
p.should be_an(Array)
|
|
27
|
+
p.length.should == 2
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "/listings/<listing_id>/videos/<video_id>", :support do
|
|
33
|
+
on_get_it "should return information about a single video"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe VirtualTour do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@virtualtour = VirtualTour.new({
|
|
6
|
+
:Uri => "http://www.flexmls.com/",
|
|
7
|
+
:ResourceUri => "/v1/listings/20060712220814669202000000/virtualtours/20110105165843978012000000",
|
|
8
|
+
:Name => "My Branded Tour",
|
|
9
|
+
:Id => "20110105165843978012000000",
|
|
10
|
+
:Type => "branded"
|
|
11
|
+
})
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should respond to a few methods" do
|
|
15
|
+
VirtualTour.should respond_to(:find_by_listing_key)
|
|
16
|
+
@virtualtour.should respond_to(:branded?)
|
|
17
|
+
@virtualtour.should respond_to(:unbranded?)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should know if it's branded" do
|
|
21
|
+
@virtualtour.branded?.should == true
|
|
22
|
+
@virtualtour.unbranded?.should == false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "/listings/<listing_id>/virtualtours", :support do
|
|
26
|
+
on_get_it "should get virtual tours for a listing" do
|
|
27
|
+
stub_auth_request
|
|
28
|
+
stub_api_get('/listings/1234/virtualtours','listings/virtual_tours_index.json')
|
|
29
|
+
|
|
30
|
+
v = VirtualTour.find_by_listing_key('1234')
|
|
31
|
+
v.should be_an(Array)
|
|
32
|
+
v.length.should == 5
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "/listings/<listing_id>/virtualtours/<tour_id>", :support do
|
|
37
|
+
on_get_it "should return information about a specific virtual tour"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
after(:each) do
|
|
41
|
+
@virtualtour = nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require './spec/spec_helper'
|
|
2
|
+
|
|
3
|
+
# Test client implemenations for multi client switching
|
|
4
|
+
module SparkApi
|
|
5
|
+
def self.test_client_a
|
|
6
|
+
Thread.current[:test_client_a] ||= Client.new(:api_key => "a")
|
|
7
|
+
end
|
|
8
|
+
def self.test_client_b
|
|
9
|
+
Client.new(:api_key => "b")
|
|
10
|
+
end
|
|
11
|
+
def self.test_client_c
|
|
12
|
+
Client.new(:api_key => "c")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe SparkApi::MultiClient do
|
|
17
|
+
it "should activate a client implemenation when activate()" do
|
|
18
|
+
SparkApi.activate(:test_client_a)
|
|
19
|
+
SparkApi.client.api_key.should eq('a')
|
|
20
|
+
SparkApi.activate(:test_client_b)
|
|
21
|
+
SparkApi.client.api_key.should eq('b')
|
|
22
|
+
SparkApi.activate(:test_client_c)
|
|
23
|
+
SparkApi.client.api_key.should eq('c')
|
|
24
|
+
SparkApi.activate(:test_client_a)
|
|
25
|
+
SparkApi.client.api_key.should eq('a')
|
|
26
|
+
end
|
|
27
|
+
it "should fail to activate symbols that do not have implementations" do
|
|
28
|
+
expect { SparkApi.activate(:test_client_d) }.to raise_error(ArgumentError)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should temporarily activate a client implemenation when activate() block" do
|
|
32
|
+
SparkApi.activate(:test_client_a)
|
|
33
|
+
SparkApi.client.api_key.should eq('a')
|
|
34
|
+
SparkApi.activate(:test_client_b) do
|
|
35
|
+
SparkApi.client.api_key.should eq('b')
|
|
36
|
+
end
|
|
37
|
+
SparkApi.client.api_key.should eq('a')
|
|
38
|
+
expect do
|
|
39
|
+
SparkApi.activate(:test_client_c) do
|
|
40
|
+
SparkApi.client.api_key.should eq('c')
|
|
41
|
+
raise "OH MY GOODNESS I BLEW UP!!!"
|
|
42
|
+
end
|
|
43
|
+
end.to raise_error
|
|
44
|
+
SparkApi.client.api_key.should eq('a')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "yaml" do
|
|
48
|
+
it "should activate a client implemenation when activate()" do
|
|
49
|
+
SparkApi::Configuration::YamlConfig.stub(:config_path) { "spec/config/spark_api" }
|
|
50
|
+
SparkApi.activate(:test_key)
|
|
51
|
+
SparkApi.client.api_key.should eq('demo_key')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|