spark_api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,70 @@
|
|
1
|
+
module SparkApi
|
2
|
+
# API Response interface
|
3
|
+
module Response
|
4
|
+
ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details]
|
5
|
+
attr_accessor *ATTRIBUTES
|
6
|
+
def success?
|
7
|
+
@success
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# All known response codes listed in the API
|
12
|
+
module ResponseCodes
|
13
|
+
NOT_FOUND = 404
|
14
|
+
METHOD_NOT_ALLOWED = 405
|
15
|
+
INVALID_KEY = 1000
|
16
|
+
DISABLED_KEY = 1010
|
17
|
+
API_USER_REQUIRED = 1015
|
18
|
+
SESSION_TOKEN_EXPIRED = 1020
|
19
|
+
SSL_REQUIRED = 1030
|
20
|
+
INVALID_JSON = 1035
|
21
|
+
INVALID_FIELD = 1040
|
22
|
+
MISSING_PARAMETER = 1050
|
23
|
+
INVALID_PARAMETER = 1053
|
24
|
+
CONFLICTING_DATA = 1055
|
25
|
+
NOT_AVAILABLE= 1500
|
26
|
+
RATE_LIMIT_EXCEEDED = 1550
|
27
|
+
end
|
28
|
+
|
29
|
+
# Errors built from API responses
|
30
|
+
class InvalidResponse < StandardError; end
|
31
|
+
class ClientError < StandardError
|
32
|
+
attr_reader :code, :status, :details
|
33
|
+
def initialize (options = {})
|
34
|
+
# Support the standard initializer for errors
|
35
|
+
opts = options.is_a?(Hash) ? options : {:message => options.to_s}
|
36
|
+
@code = opts[:code]
|
37
|
+
@status = opts[:status]
|
38
|
+
@details = opts[:details]
|
39
|
+
super(opts[:message])
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
class NotFound < ClientError; end
|
44
|
+
class PermissionDenied < ClientError; end
|
45
|
+
class NotAllowed < ClientError; end
|
46
|
+
class BadResourceRequest < ClientError; end
|
47
|
+
|
48
|
+
# Nice and handy class wrapper for the api response hash
|
49
|
+
class ApiResponse < ::Array
|
50
|
+
include SparkApi::Response
|
51
|
+
def initialize(d)
|
52
|
+
begin
|
53
|
+
hash = d["D"]
|
54
|
+
if hash.nil? || hash.empty?
|
55
|
+
raise InvalidResponse, "The server response could not be understood"
|
56
|
+
end
|
57
|
+
self.message = hash["Message"]
|
58
|
+
self.code = hash["Code"]
|
59
|
+
self.results = Array(hash["Results"])
|
60
|
+
self.success = hash["Success"]
|
61
|
+
self.pagination = hash["Pagination"]
|
62
|
+
self.details = hash["Details"] || []
|
63
|
+
super(results)
|
64
|
+
rescue Exception => e
|
65
|
+
SparkApi.logger.error "Unable to understand the response! #{d}"
|
66
|
+
raise
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module FlexmlsApi
|
2
|
+
# API Response interface
|
3
|
+
module Response
|
4
|
+
ATTRIBUTES = [:code, :message, :results, :success, :pagination, :details]
|
5
|
+
attr_accessor *ATTRIBUTES
|
6
|
+
def success?
|
7
|
+
@success
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# All known response codes listed in the API
|
12
|
+
module ResponseCodes
|
13
|
+
NOT_FOUND = 404
|
14
|
+
METHOD_NOT_ALLOWED = 405
|
15
|
+
INVALID_KEY = 1000
|
16
|
+
DISABLED_KEY = 1010
|
17
|
+
API_USER_REQUIRED = 1015
|
18
|
+
SESSION_TOKEN_EXPIRED = 1020
|
19
|
+
SSL_REQUIRED = 1030
|
20
|
+
INVALID_JSON = 1035
|
21
|
+
INVALID_FIELD = 1040
|
22
|
+
MISSING_PARAMETER = 1050
|
23
|
+
INVALID_PARAMETER = 1053
|
24
|
+
CONFLICTING_DATA = 1055
|
25
|
+
NOT_AVAILABLE= 1500
|
26
|
+
RATE_LIMIT_EXCEEDED = 1550
|
27
|
+
end
|
28
|
+
|
29
|
+
# Errors built from API responses
|
30
|
+
class InvalidResponse < StandardError; end
|
31
|
+
class ClientError < StandardError
|
32
|
+
attr_reader :code, :status, :details
|
33
|
+
def initialize (options = {})
|
34
|
+
# Support the standard initializer for errors
|
35
|
+
opts = options.is_a?(Hash) ? options : {:message => options.to_s}
|
36
|
+
@code = opts[:code]
|
37
|
+
@status = opts[:status]
|
38
|
+
@details = opts[:details]
|
39
|
+
super(opts[:message])
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
class NotFound < ClientError; end
|
44
|
+
class PermissionDenied < ClientError; end
|
45
|
+
class NotAllowed < ClientError; end
|
46
|
+
class BadResourceRequest < ClientError; end
|
47
|
+
|
48
|
+
# Nice and handy class wrapper for the api response hash
|
49
|
+
class ApiResponse < ::Array
|
50
|
+
include FlexmlsApi::Response
|
51
|
+
def initialize(d)
|
52
|
+
begin
|
53
|
+
hash = d["D"]
|
54
|
+
if hash.nil? || hash.empty?
|
55
|
+
raise InvalidResponse, "The server response could not be understood"
|
56
|
+
end
|
57
|
+
self.message = hash["Message"]
|
58
|
+
self.code = hash["Code"]
|
59
|
+
self.results = Array(hash["Results"])
|
60
|
+
self.success = hash["Success"]
|
61
|
+
self.pagination = hash["Pagination"]
|
62
|
+
self.details = hash["Details"] || []
|
63
|
+
super(results)
|
64
|
+
rescue Exception => e
|
65
|
+
FlexmlsApi.logger.error "Unable to understand the response! #{d}"
|
66
|
+
raise
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/script/console
ADDED
data/script/console~
ADDED
data/script/example.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
Bundler.require(:default, "development") if defined?(Bundler)
|
5
|
+
|
6
|
+
path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
7
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
8
|
+
require path + '/spark_api'
|
9
|
+
|
10
|
+
SparkApi.logger.info("Hello!")
|
11
|
+
|
12
|
+
SparkApi.configure do |config|
|
13
|
+
config.api_key = "agent_key"
|
14
|
+
config.api_secret = "agent_secret"
|
15
|
+
config.version = "v1"
|
16
|
+
config.endpoint = "https://api.sparkapi.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
client = SparkApi.client
|
20
|
+
|
21
|
+
list = client.get '/contacts'
|
22
|
+
puts "client: #{list.inspect}"
|
23
|
+
list = SparkApi::Models::Contact.get
|
24
|
+
puts "model: #{list.inspect}"
|
25
|
+
|
26
|
+
|
27
|
+
|
data/script/example.rb~
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
Bundler.require(:default, "development") if defined?(Bundler)
|
5
|
+
|
6
|
+
path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
7
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
8
|
+
require path + '/flexmls_api'
|
9
|
+
|
10
|
+
FlexmlsApi.logger.info("Hello!")
|
11
|
+
|
12
|
+
FlexmlsApi.configure do |config|
|
13
|
+
config.api_key = "agent_key"
|
14
|
+
config.api_secret = "agent_secret"
|
15
|
+
config.version = "v1"
|
16
|
+
config.endpoint = "https://api.flexmls.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
client = FlexmlsApi.client
|
20
|
+
|
21
|
+
list = client.get '/contacts'
|
22
|
+
puts "client: #{list.inspect}"
|
23
|
+
list = FlexmlsApi::Models::Contact.get
|
24
|
+
puts "model: #{list.inspect}"
|
25
|
+
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,160 @@
|
|
1
|
+
{
|
2
|
+
"D": {
|
3
|
+
"Success": true,
|
4
|
+
"Results": [
|
5
|
+
{
|
6
|
+
"Name" : "Sample User",
|
7
|
+
"Id" : "20000426173054342350000000",
|
8
|
+
"Office" : "Sample Office Inc",
|
9
|
+
"OfficeId" : "20030426173014239760000000",
|
10
|
+
"Mls" : "Your Local MLS",
|
11
|
+
"MlsId": "20000426143505724628000000",
|
12
|
+
"Emails": [
|
13
|
+
{
|
14
|
+
"Type": "Work",
|
15
|
+
"Name": "My Work E-mail",
|
16
|
+
"Address": "work@test.com",
|
17
|
+
"Primary": true
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"Type": "Mobile",
|
21
|
+
"Name": "My Mobile E-mail",
|
22
|
+
"Address": "mobile@test.com"
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"Phones": [
|
26
|
+
{
|
27
|
+
"Type": "Work",
|
28
|
+
"Name": "My Work Phone",
|
29
|
+
"Number": "701-555-1212",
|
30
|
+
"Primary": true
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"Type": "Mobile",
|
34
|
+
"Name": "My Mobile Phone",
|
35
|
+
"Number": "702-555-1313"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"Websites": [
|
39
|
+
{
|
40
|
+
"Type": "Work",
|
41
|
+
"Name": "My Work Website",
|
42
|
+
"Uri": "http://iamthebestagent.com",
|
43
|
+
"Primary": true
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"Type": "Mobile",
|
47
|
+
"Name": "My Mobile Website",
|
48
|
+
"Uri": "http://m.iamthebestagent.com"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"Addresses": [
|
52
|
+
{
|
53
|
+
"Type": "Work",
|
54
|
+
"Name": "My Work Address",
|
55
|
+
"Address": "101 Main Ave, Phoenix, AZ 12345",
|
56
|
+
"Primary": true
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"Images": [
|
60
|
+
{
|
61
|
+
"Type": "Photo",
|
62
|
+
"Name": "My Photo",
|
63
|
+
"Uri": "http://photos.flexmls.com/az/...."
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"Type": "Logo",
|
67
|
+
"Name": "My Logo",
|
68
|
+
"Uri": "http://photos.flexmls.com/az/...."
|
69
|
+
}
|
70
|
+
]
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"Name" : "Other User",
|
74
|
+
"Id" : "20000426173054382350000000",
|
75
|
+
"Office" : "Sample Office Inc",
|
76
|
+
"OfficeId" : "20030426173014239760000000",
|
77
|
+
"Mls" : "Your Local MLS",
|
78
|
+
"MlsId": "20000426143505724628000000",
|
79
|
+
"Emails": [
|
80
|
+
{
|
81
|
+
"Type": "Work",
|
82
|
+
"Name": "My Work E-mail",
|
83
|
+
"Address": "otherwork@test.com",
|
84
|
+
"Primary": true
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"Type": "Mobile",
|
88
|
+
"Name": "My Mobile E-mail",
|
89
|
+
"Address": "othermobile@test.com"
|
90
|
+
}
|
91
|
+
],
|
92
|
+
"Phones": [
|
93
|
+
{
|
94
|
+
"Type": "Work",
|
95
|
+
"Name": "My Work Phone",
|
96
|
+
"Number": "701-555-1414",
|
97
|
+
"Primary": true
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"Type": "Mobile",
|
101
|
+
"Name": "My Mobile Phone",
|
102
|
+
"Number": "702-555-1515"
|
103
|
+
}
|
104
|
+
],
|
105
|
+
"Websites": [
|
106
|
+
{
|
107
|
+
"Type": "Work",
|
108
|
+
"Name": "My Work Website",
|
109
|
+
"Uri": "http://iamtheotheragent.com",
|
110
|
+
"Primary": true
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"Type": "Mobile",
|
114
|
+
"Name": "My Mobile Website",
|
115
|
+
"Uri": "http://m.iamtheotheragent.com"
|
116
|
+
}
|
117
|
+
],
|
118
|
+
"Addresses": [
|
119
|
+
{
|
120
|
+
"Type": "Work",
|
121
|
+
"Name": "My Work Address",
|
122
|
+
"Address": "101 Main Ave, Phoenix, AZ 12345",
|
123
|
+
"Primary": true
|
124
|
+
}
|
125
|
+
],
|
126
|
+
"Images": [
|
127
|
+
{
|
128
|
+
"Type": "Photo",
|
129
|
+
"Name": "My Photo",
|
130
|
+
"Uri": "http://photos.flexmls.com/az/1234.jpg"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"Type": "Logo",
|
134
|
+
"Name": "My Logo",
|
135
|
+
"Uri": "http://photos.flexmls.com/az/logo.jpg"
|
136
|
+
}
|
137
|
+
]
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"Name" : "Empty User",
|
141
|
+
"Id" : "20110126173054382350000000",
|
142
|
+
"Office" : "New Office Inc",
|
143
|
+
"OfficeId" : "20110426173014239760000000",
|
144
|
+
"Mls" : "New MLS",
|
145
|
+
"MlsId": "20110426143505724628000000",
|
146
|
+
"Emails": [
|
147
|
+
],
|
148
|
+
"Phones": [
|
149
|
+
],
|
150
|
+
"Websites": [
|
151
|
+
],
|
152
|
+
"Addresses": [
|
153
|
+
],
|
154
|
+
"Images": [
|
155
|
+
]
|
156
|
+
}
|
157
|
+
|
158
|
+
]
|
159
|
+
}
|
160
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"D": {
|
3
|
+
"Success": true,
|
4
|
+
"Results": [
|
5
|
+
{
|
6
|
+
"Name" : "Sample User",
|
7
|
+
"Id" : "20000426173054342350000000",
|
8
|
+
"Office" : "Sample Office Inc",
|
9
|
+
"OfficeId" : "20030426173014239760000000",
|
10
|
+
"Mls" : "Your Local MLS",
|
11
|
+
"MlsId": "20000426143505724628000000",
|
12
|
+
"Emails": [
|
13
|
+
{
|
14
|
+
"Type": "Work",
|
15
|
+
"Name": "My Work E-mail",
|
16
|
+
"Address": "work@test.com",
|
17
|
+
"Primary": true
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"Type": "Mobile",
|
21
|
+
"Name": "My Mobile E-mail",
|
22
|
+
"Address": "mobile@test.com"
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"Phones": [
|
26
|
+
{
|
27
|
+
"Type": "Work",
|
28
|
+
"Name": "My Work Phone",
|
29
|
+
"Number": "701-555-1212",
|
30
|
+
"Primary": true
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"Type": "Mobile",
|
34
|
+
"Name": "My Mobile Phone",
|
35
|
+
"Number": "702-555-1313"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"Websites": [
|
39
|
+
{
|
40
|
+
"Type": "Work",
|
41
|
+
"Name": "My Work Website",
|
42
|
+
"Uri": "http://iamthebestagent.com",
|
43
|
+
"Primary": true
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"Type": "Mobile",
|
47
|
+
"Name": "My Mobile Website",
|
48
|
+
"Uri": "http://m.iamthebestagent.com"
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"Addresses": [
|
52
|
+
{
|
53
|
+
"Type": "Work",
|
54
|
+
"Name": "My Work Address",
|
55
|
+
"Address": "101 Main Ave, Phoenix, AZ 12345",
|
56
|
+
"Primary": true
|
57
|
+
}
|
58
|
+
],
|
59
|
+
"Images": [
|
60
|
+
{
|
61
|
+
"Type": "Photo",
|
62
|
+
"Name": "My Photo",
|
63
|
+
"Uri": "http://photos.flexmls.com/az/...."
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"Type": "Logo",
|
67
|
+
"Name": "My Logo",
|
68
|
+
"Uri": "http://photos.flexmls.com/az/...."
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
}
|