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,35 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
class SharedListing < Base
|
|
4
|
+
extend Finders
|
|
5
|
+
self.element_name="sharedlistings"
|
|
6
|
+
|
|
7
|
+
def ListingIds=(listing_ids)
|
|
8
|
+
attributes["ListingIds"] = Array(listing_ids)
|
|
9
|
+
end
|
|
10
|
+
def ViewId=(id)
|
|
11
|
+
attributes["ViewId"] = id
|
|
12
|
+
end
|
|
13
|
+
def ReportId=(id)
|
|
14
|
+
attributes["ReportId"] = id
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def save(arguments={})
|
|
18
|
+
begin
|
|
19
|
+
return save!(arguments)
|
|
20
|
+
rescue BadResourceRequest => e
|
|
21
|
+
rescue NotFound => e
|
|
22
|
+
# log and leave
|
|
23
|
+
FlexmlsApi.logger.error("Failed to save SharedListing #{self}: #{e.message}")
|
|
24
|
+
end
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
def save!(arguments={})
|
|
28
|
+
results = connection.post self.class.path, attributes, arguments
|
|
29
|
+
result = results.first
|
|
30
|
+
attributes['ResourceUri'] = result['ResourceUri']
|
|
31
|
+
true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module SparkApi
|
|
2
|
+
module Models
|
|
3
|
+
class StandardFields < Base
|
|
4
|
+
extend Finders
|
|
5
|
+
self.element_name="standardfields"
|
|
6
|
+
|
|
7
|
+
# expand all fields passed in
|
|
8
|
+
def self.find_and_expand_all(fields, arguments={}, max_list_size=1000)
|
|
9
|
+
returns = {}
|
|
10
|
+
|
|
11
|
+
# find all standard fields, but expand only the location fields
|
|
12
|
+
# TODO: when _expand support is added to StandardFields API, use the following
|
|
13
|
+
# standard_fields = find(:all, {:ApiUser => owner, :_expand => fields.join(",")})
|
|
14
|
+
standard_fields = find(:all, arguments)
|
|
15
|
+
|
|
16
|
+
# filter through the list and return only the location fields found
|
|
17
|
+
fields.each do |field|
|
|
18
|
+
# search for field in the payload
|
|
19
|
+
if standard_fields.first.attributes.has_key?(field)
|
|
20
|
+
returns[field] = standard_fields.first.attributes[field]
|
|
21
|
+
|
|
22
|
+
# lookup fully _expand field, if the field has a list
|
|
23
|
+
if returns[field]['HasList'] && returns[field]['MaxListSize'].to_i <= max_list_size
|
|
24
|
+
returns[field] = connection.get("/standardfields/#{field}", arguments).first[field]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
returns
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# find_nearby: find fields nearby via lat/lon
|
|
35
|
+
def self.find_nearby(prop_types = ["A"], arguments={})
|
|
36
|
+
return_json = {"D" => {"Success" => true, "Results" => []} }
|
|
37
|
+
|
|
38
|
+
# add _expand=1 so the fields are returned
|
|
39
|
+
arguments.merge!({:_expand => 1})
|
|
40
|
+
|
|
41
|
+
# find and return
|
|
42
|
+
return_json["D"]["Results"] = connection.get("/standardfields/nearby/#{prop_types.join(',')}", arguments)
|
|
43
|
+
|
|
44
|
+
# return
|
|
45
|
+
return_json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
class StandardFields < Base
|
|
4
|
+
extend Finders
|
|
5
|
+
self.element_name="standardfields"
|
|
6
|
+
|
|
7
|
+
# expand all fields passed in
|
|
8
|
+
def self.find_and_expand_all(fields, arguments={}, max_list_size=1000)
|
|
9
|
+
returns = {}
|
|
10
|
+
|
|
11
|
+
# find all standard fields, but expand only the location fields
|
|
12
|
+
# TODO: when _expand support is added to StandardFields API, use the following
|
|
13
|
+
# standard_fields = find(:all, {:ApiUser => owner, :_expand => fields.join(",")})
|
|
14
|
+
standard_fields = find(:all, arguments)
|
|
15
|
+
|
|
16
|
+
# filter through the list and return only the location fields found
|
|
17
|
+
fields.each do |field|
|
|
18
|
+
# search for field in the payload
|
|
19
|
+
if standard_fields.first.attributes.has_key?(field)
|
|
20
|
+
returns[field] = standard_fields.first.attributes[field]
|
|
21
|
+
|
|
22
|
+
# lookup fully _expand field, if the field has a list
|
|
23
|
+
if returns[field]['HasList'] && returns[field]['MaxListSize'].to_i <= max_list_size
|
|
24
|
+
returns[field] = connection.get("/standardfields/#{field}", arguments).first[field]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
returns
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# find_nearby: find fields nearby via lat/lon
|
|
35
|
+
def self.find_nearby(prop_types = ["A"], arguments={})
|
|
36
|
+
return_json = {"D" => {"Success" => true, "Results" => []} }
|
|
37
|
+
|
|
38
|
+
# add _expand=1 so the fields are returned
|
|
39
|
+
arguments.merge!({:_expand => 1})
|
|
40
|
+
|
|
41
|
+
# find and return
|
|
42
|
+
return_json["D"]["Results"] = connection.get("/standardfields/nearby/#{prop_types.join(',')}", arguments)
|
|
43
|
+
|
|
44
|
+
# return
|
|
45
|
+
return_json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module SparkApi
|
|
2
|
+
module Models
|
|
3
|
+
module Subresource
|
|
4
|
+
|
|
5
|
+
def build_subclass
|
|
6
|
+
Class.new(self)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def find_by_listing_key(key, arguments={})
|
|
10
|
+
collect(connection.get("/listings/#{key}#{self.path}", arguments))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def find_by_id(id, parent_id, arguments={})
|
|
14
|
+
collect(connection.get("/listings/#{parent_id}#{self.path}/#{id}", arguments)).first
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
module Subresource
|
|
4
|
+
|
|
5
|
+
def build_subclass
|
|
6
|
+
Class.new(self)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def find_by_listing_key(key, arguments={})
|
|
10
|
+
collect(connection.get("/listings/#{key}#{self.path}", arguments))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def find_by_id(id, parent_id, arguments={})
|
|
14
|
+
collect(connection.get("/listings/#{parent_id}#{self.path}/#{id}", arguments)).first
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module SparkApi
|
|
2
|
+
module Models
|
|
3
|
+
class SystemInfo < Base
|
|
4
|
+
self.element_name="system"
|
|
5
|
+
|
|
6
|
+
def primary_logo
|
|
7
|
+
logo = nil
|
|
8
|
+
mls_logos = attributes['Configuration'].first['MlsLogos']
|
|
9
|
+
logo = mls_logos.first if !mls_logos.nil? and !mls_logos.empty?
|
|
10
|
+
logo
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
class SystemInfo < Base
|
|
4
|
+
self.element_name="system"
|
|
5
|
+
|
|
6
|
+
def primary_logo
|
|
7
|
+
logo = nil
|
|
8
|
+
mls_logos = attributes['Configuration'].first['MlsLogos']
|
|
9
|
+
logo = mls_logos.first if !mls_logos.nil? and !mls_logos.empty?
|
|
10
|
+
logo
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
require 'time'
|
|
3
|
+
|
|
4
|
+
module SparkApi
|
|
5
|
+
module Models
|
|
6
|
+
class TourOfHome < Base
|
|
7
|
+
extend Subresource
|
|
8
|
+
|
|
9
|
+
self.element_name = "tourofhomes"
|
|
10
|
+
|
|
11
|
+
def initialize(attributes={})
|
|
12
|
+
# Transform the date strings
|
|
13
|
+
unless attributes['Date'].nil?
|
|
14
|
+
date = Date.parse(attributes['Date'])
|
|
15
|
+
attributes['Date'] = date
|
|
16
|
+
attributes['StartTime'] = Time.parse("#{date}T#{attributes['StartTime']}") unless attributes['StartTime'].nil?
|
|
17
|
+
attributes['EndTime'] = Time.parse("#{date}T#{attributes['EndTime']}") unless attributes['EndTime'].nil?
|
|
18
|
+
end
|
|
19
|
+
super(attributes)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
require 'time'
|
|
3
|
+
|
|
4
|
+
module FlexmlsApi
|
|
5
|
+
module Models
|
|
6
|
+
class TourOfHome < Base
|
|
7
|
+
extend Subresource
|
|
8
|
+
|
|
9
|
+
self.element_name = "tourofhomes"
|
|
10
|
+
|
|
11
|
+
def initialize(attributes={})
|
|
12
|
+
# Transform the date strings
|
|
13
|
+
unless attributes['Date'].nil?
|
|
14
|
+
date = Date.parse(attributes['Date'])
|
|
15
|
+
attributes['Date'] = date
|
|
16
|
+
attributes['StartTime'] = Time.parse("#{date}T#{attributes['StartTime']}") unless attributes['StartTime'].nil?
|
|
17
|
+
attributes['EndTime'] = Time.parse("#{date}T#{attributes['EndTime']}") unless attributes['EndTime'].nil?
|
|
18
|
+
end
|
|
19
|
+
super(attributes)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
class Video < Base
|
|
4
|
+
extend Subresource
|
|
5
|
+
self.element_name = 'videos'
|
|
6
|
+
|
|
7
|
+
def branded?
|
|
8
|
+
attributes['Type'] == 'branded'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def unbranded?
|
|
12
|
+
attributes['Type'] == 'unbranded'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module SparkApi
|
|
2
|
+
module Models
|
|
3
|
+
class VirtualTour < Base
|
|
4
|
+
extend Subresource
|
|
5
|
+
self.element_name="virtualtours"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def branded?
|
|
9
|
+
attributes["Type"] == "branded"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def unbranded?
|
|
13
|
+
attributes["Type"] == "unbranded"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
module Models
|
|
3
|
+
class VirtualTour < Base
|
|
4
|
+
extend Subresource
|
|
5
|
+
self.element_name="virtualtours"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def branded?
|
|
9
|
+
attributes["Type"] == "branded"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def unbranded?
|
|
13
|
+
attributes["Type"] == "unbranded"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module SparkApi
|
|
2
|
+
#===Active support for multiple clients
|
|
3
|
+
module MultiClient
|
|
4
|
+
include SparkApi::Configuration
|
|
5
|
+
|
|
6
|
+
# Activate a specific instance of the client (with appropriate config settings). Each client
|
|
7
|
+
# is lazily instanciated by calling the matching SparkApi.symbol_name method on the
|
|
8
|
+
# SparkApi module. It's the developers responsibility to extend the module and provide this
|
|
9
|
+
# method.
|
|
10
|
+
# Parameters
|
|
11
|
+
# @sym - the unique symbol identifier for a client configuration.
|
|
12
|
+
# &block - a block of code to run with the specified client enabled, after which the original
|
|
13
|
+
# client setting will be reenabled
|
|
14
|
+
def activate(sym)
|
|
15
|
+
if block_given?
|
|
16
|
+
original_client = Thread.current[:spark_api_client]
|
|
17
|
+
begin
|
|
18
|
+
activate_client(sym)
|
|
19
|
+
yield
|
|
20
|
+
ensure
|
|
21
|
+
Thread.current[:spark_api_client] = original_client
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
activate_client(sym)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# set the active client for the symbol
|
|
31
|
+
def activate_client(symbol)
|
|
32
|
+
if !Thread.current[symbol].nil?
|
|
33
|
+
active_client = Thread.current[symbol]
|
|
34
|
+
elsif SparkApi.respond_to? symbol
|
|
35
|
+
active_client = SparkApi.send(symbol)
|
|
36
|
+
elsif YamlConfig.exists? symbol.to_s
|
|
37
|
+
active_client = activate_client_from_config(symbol)
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, "The symbol #{symbol} is not setup correctly as a multi client key."
|
|
40
|
+
end
|
|
41
|
+
Thread.current[symbol] = active_client
|
|
42
|
+
Thread.current[:spark_api_client] = active_client
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def activate_client_from_config(symbol)
|
|
46
|
+
SparkApi.logger.debug("Loading multiclient [#{symbol.to_s}] from config")
|
|
47
|
+
yaml = YamlConfig.build(symbol.to_s)
|
|
48
|
+
if(yaml.oauth2?)
|
|
49
|
+
Client.new(yaml.client_keys.merge({
|
|
50
|
+
:oauth2_provider => Authentication::OAuth2Impl.load_provider(yaml.oauth2_provider, yaml.oauth2_keys),
|
|
51
|
+
:authentication_mode => SparkApi::Authentication::OAuth2,
|
|
52
|
+
}))
|
|
53
|
+
else
|
|
54
|
+
Client.new(yaml.client_keys)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module FlexmlsApi
|
|
2
|
+
#===Active support for multiple clients
|
|
3
|
+
module MultiClient
|
|
4
|
+
include FlexmlsApi::Configuration
|
|
5
|
+
|
|
6
|
+
# Activate a specific instance of the client (with appropriate config settings). Each client
|
|
7
|
+
# is lazily instanciated by calling the matching FlexmlsApi.symbol_name method on the
|
|
8
|
+
# FlexmlsApi module. It's the developers responsibility to extend the module and provide this
|
|
9
|
+
# method.
|
|
10
|
+
# Parameters
|
|
11
|
+
# @sym - the unique symbol identifier for a client configuration.
|
|
12
|
+
# &block - a block of code to run with the specified client enabled, after which the original
|
|
13
|
+
# client setting will be reenabled
|
|
14
|
+
def activate(sym)
|
|
15
|
+
if block_given?
|
|
16
|
+
original_client = Thread.current[:flexmls_api_client]
|
|
17
|
+
begin
|
|
18
|
+
activate_client(sym)
|
|
19
|
+
yield
|
|
20
|
+
ensure
|
|
21
|
+
Thread.current[:flexmls_api_client] = original_client
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
activate_client(sym)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# set the active client for the symbol
|
|
31
|
+
def activate_client(symbol)
|
|
32
|
+
if !Thread.current[symbol].nil?
|
|
33
|
+
active_client = Thread.current[symbol]
|
|
34
|
+
elsif FlexmlsApi.respond_to? symbol
|
|
35
|
+
active_client = FlexmlsApi.send(symbol)
|
|
36
|
+
elsif YamlConfig.exists? symbol.to_s
|
|
37
|
+
active_client = activate_client_from_config(symbol)
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, "The symbol #{symbol} is not setup correctly as a multi client key."
|
|
40
|
+
end
|
|
41
|
+
Thread.current[symbol] = active_client
|
|
42
|
+
Thread.current[:flexmls_api_client] = active_client
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def activate_client_from_config(symbol)
|
|
46
|
+
FlexmlsApi.logger.debug("Loading multiclient [#{symbol.to_s}] from config")
|
|
47
|
+
yaml = YamlConfig.build(symbol.to_s)
|
|
48
|
+
if(yaml.oauth2?)
|
|
49
|
+
Client.new(yaml.client_keys.merge({
|
|
50
|
+
:oauth2_provider => Authentication::OAuth2Impl.load_provider(yaml.oauth2_provider, yaml.oauth2_keys),
|
|
51
|
+
:authentication_mode => FlexmlsApi::Authentication::OAuth2,
|
|
52
|
+
}))
|
|
53
|
+
else
|
|
54
|
+
Client.new(yaml.client_keys)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|