simplyrets 0.1 → 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +46 -13
- data/README.org +6 -6
- data/example.rb +9 -9
- data/lib/simplyrets.rb +33 -56
- data/lib/simplyrets/#listing.rb# +199 -0
- data/lib/simplyrets/api/default_api.rb +154 -0
- data/lib/simplyrets/listing.rb~ +199 -0
- data/lib/simplyrets/models/agent.rb +61 -0
- data/lib/simplyrets/models/base_object.rb +87 -0
- data/lib/simplyrets/models/broker.rb +37 -0
- data/lib/simplyrets/models/contact_information.rb +53 -0
- data/lib/simplyrets/models/error.rb +45 -0
- data/lib/simplyrets/models/geographic_data.rb +69 -0
- data/lib/simplyrets/models/listing.rb +199 -0
- data/lib/simplyrets/models/listing.rb~ +199 -0
- data/lib/simplyrets/models/mls_information.rb +69 -0
- data/lib/simplyrets/models/office.rb +61 -0
- data/lib/simplyrets/models/open_house.rb +37 -0
- data/lib/simplyrets/models/parking.rb +53 -0
- data/lib/simplyrets/models/property.rb +277 -0
- data/lib/simplyrets/models/sales.rb +69 -0
- data/lib/simplyrets/models/school.rb +61 -0
- data/lib/simplyrets/models/street_address.rb +85 -0
- data/lib/simplyrets/models/tax.rb +53 -0
- data/lib/simplyrets/simplyrets.rb +76 -0
- data/lib/simplyrets/simplyrets/api_error.rb +26 -0
- data/lib/simplyrets/simplyrets/configuration.rb +101 -0
- data/lib/simplyrets/simplyrets/request.rb +213 -0
- data/lib/simplyrets/simplyrets/response.rb +156 -0
- data/lib/simplyrets/simplyrets/version.rb +5 -0
- data/simplyrets.gemspec +16 -9
- metadata +153 -36
- data/#example.rb# +0 -29
- data/lib/monkey.rb +0 -90
- data/lib/properties_api.rb +0 -75
- data/lib/simplyrets.rb~ +0 -85
- data/lib/simplyrets/configuration.rb +0 -25
- data/lib/simplyrets/request.rb +0 -205
- data/lib/simplyrets/response.rb +0 -70
- data/lib/simplyrets/version.rb +0 -4
- data/models/agent.rb +0 -39
- data/models/contactinformation.rb +0 -36
- data/models/geographicdata.rb +0 -43
- data/models/listing.rb +0 -95
- data/models/mlsinformation.rb +0 -35
- data/models/office.rb +0 -39
- data/models/property.rb +0 -84
- data/models/school.rb +0 -27
- data/models/streetaddress.rb +0 -47
- data/models/tax.rb +0 -28
- data/pkg/simplyrets-0.1.gem +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
#
|
3
|
+
class Sales < BaseObject
|
4
|
+
attr_accessor :agent, :close_date, :close_price, :contract_date, :office
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# RETS Sales data agent id
|
10
|
+
:'agent' => :'agent',
|
11
|
+
|
12
|
+
# RETS Sales data close date
|
13
|
+
:'close_date' => :'closeDate',
|
14
|
+
|
15
|
+
# RETS Sales data sold price
|
16
|
+
:'close_price' => :'closePrice',
|
17
|
+
|
18
|
+
# RETS Sales data contract date
|
19
|
+
:'contract_date' => :'contractDate',
|
20
|
+
|
21
|
+
# RETS Sales data selling office/brokerage id
|
22
|
+
:'office' => :'office'
|
23
|
+
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# attribute type
|
28
|
+
def self.simplyrets_types
|
29
|
+
{
|
30
|
+
:'agent' => :'String',
|
31
|
+
:'close_date' => :'DateTime',
|
32
|
+
:'close_price' => :'Integer',
|
33
|
+
:'contract_date' => :'DateTime',
|
34
|
+
:'office' => :'String'
|
35
|
+
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
44
|
+
|
45
|
+
|
46
|
+
if attributes[:'agent']
|
47
|
+
self.agent = attributes[:'agent']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes[:'closeDate']
|
51
|
+
self.close_date = attributes[:'closeDate']
|
52
|
+
end
|
53
|
+
|
54
|
+
if attributes[:'closePrice']
|
55
|
+
self.close_price = attributes[:'closePrice']
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes[:'contractDate']
|
59
|
+
self.contract_date = attributes[:'contractDate']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes[:'office']
|
63
|
+
self.office = attributes[:'office']
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
#
|
3
|
+
class School < BaseObject
|
4
|
+
attr_accessor :district, :elementary_school, :middle_school, :high_school
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# School district name.
|
10
|
+
:'district' => :'district',
|
11
|
+
|
12
|
+
# Elementary school name.
|
13
|
+
:'elementary_school' => :'elementarySchool',
|
14
|
+
|
15
|
+
# Middle or junior school name
|
16
|
+
:'middle_school' => :'middleSchool',
|
17
|
+
|
18
|
+
# High school name
|
19
|
+
:'high_school' => :'highSchool'
|
20
|
+
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# attribute type
|
25
|
+
def self.simplyrets_types
|
26
|
+
{
|
27
|
+
:'district' => :'String',
|
28
|
+
:'elementary_school' => :'String',
|
29
|
+
:'middle_school' => :'String',
|
30
|
+
:'high_school' => :'String'
|
31
|
+
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
40
|
+
|
41
|
+
|
42
|
+
if attributes[:'district']
|
43
|
+
self.district = attributes[:'district']
|
44
|
+
end
|
45
|
+
|
46
|
+
if attributes[:'elementarySchool']
|
47
|
+
self.elementary_school = attributes[:'elementarySchool']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes[:'middleSchool']
|
51
|
+
self.middle_school = attributes[:'middleSchool']
|
52
|
+
end
|
53
|
+
|
54
|
+
if attributes[:'highSchool']
|
55
|
+
self.high_school = attributes[:'highSchool']
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
#
|
3
|
+
class StreetAddress < BaseObject
|
4
|
+
attr_accessor :country, :postal_code, :street_name, :city, :street_number, :full, :cross_street
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# Street address country (United States or Canada)
|
10
|
+
:'country' => :'country',
|
11
|
+
|
12
|
+
# Street Address postal code
|
13
|
+
:'postal_code' => :'postalCode',
|
14
|
+
|
15
|
+
# Name of the street
|
16
|
+
:'street_name' => :'streetName',
|
17
|
+
|
18
|
+
# City name
|
19
|
+
:'city' => :'city',
|
20
|
+
|
21
|
+
# Street number
|
22
|
+
:'street_number' => :'streetNumber',
|
23
|
+
|
24
|
+
# Full pretty-printed address with suffix (if available)
|
25
|
+
:'full' => :'full',
|
26
|
+
|
27
|
+
# Known cross street
|
28
|
+
:'cross_street' => :'crossStreet'
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# attribute type
|
34
|
+
def self.simplyrets_types
|
35
|
+
{
|
36
|
+
:'country' => :'String',
|
37
|
+
:'postal_code' => :'String',
|
38
|
+
:'street_name' => :'String',
|
39
|
+
:'city' => :'String',
|
40
|
+
:'street_number' => :'Integer',
|
41
|
+
:'full' => :'String',
|
42
|
+
:'cross_street' => :'String'
|
43
|
+
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
52
|
+
|
53
|
+
|
54
|
+
if attributes[:'country']
|
55
|
+
self.country = attributes[:'country']
|
56
|
+
end
|
57
|
+
|
58
|
+
if attributes[:'postalCode']
|
59
|
+
self.postal_code = attributes[:'postalCode']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes[:'streetName']
|
63
|
+
self.street_name = attributes[:'streetName']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes[:'city']
|
67
|
+
self.city = attributes[:'city']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes[:'streetNumber']
|
71
|
+
self.street_number = attributes[:'streetNumber']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes[:'full']
|
75
|
+
self.full = attributes[:'full']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes[:'crossStreet']
|
79
|
+
self.cross_street = attributes[:'crossStreet']
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
#
|
3
|
+
class Tax < BaseObject
|
4
|
+
attr_accessor :id, :annual_amount, :year
|
5
|
+
# attribute mapping from ruby-style variable name to JSON key
|
6
|
+
def self.attribute_map
|
7
|
+
{
|
8
|
+
|
9
|
+
# Tax Parcel ID for the listing
|
10
|
+
:'id' => :'id',
|
11
|
+
|
12
|
+
# Annual tax amount in USD
|
13
|
+
:'annual_amount' => :'annualAmount',
|
14
|
+
|
15
|
+
# Tax Year
|
16
|
+
:'year' => :'year'
|
17
|
+
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# attribute type
|
22
|
+
def self.simplyrets_types
|
23
|
+
{
|
24
|
+
:'id' => :'String',
|
25
|
+
:'annual_amount' => :'String',
|
26
|
+
:'year' => :'Integer'
|
27
|
+
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(attributes = {})
|
32
|
+
return if !attributes.is_a?(Hash) || attributes.empty?
|
33
|
+
|
34
|
+
# convert string to symbol for hash key
|
35
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
36
|
+
|
37
|
+
|
38
|
+
if attributes[:'id']
|
39
|
+
self.id = attributes[:'id']
|
40
|
+
end
|
41
|
+
|
42
|
+
if attributes[:'annualAmount']
|
43
|
+
self.annual_amount = attributes[:'annualAmount']
|
44
|
+
end
|
45
|
+
|
46
|
+
if attributes[:'year']
|
47
|
+
self.year = attributes[:'year']
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
module SimplyRets
|
3
|
+
class << self
|
4
|
+
attr_accessor :logger
|
5
|
+
|
6
|
+
# A SimplyRets configuration object. Must act like a hash and return sensible
|
7
|
+
# values for all SimplyRets configuration options. See SimplyRets::Configuration.
|
8
|
+
attr_accessor :configuration
|
9
|
+
|
10
|
+
attr_accessor :resources
|
11
|
+
|
12
|
+
# Call this method to modify defaults in your initializers.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# SimplyRets.configure do |config|
|
16
|
+
# config.api_key['api_key'] = '1234567890abcdef' # api key authentication
|
17
|
+
# config.username = 'wordlover' # http basic authentication
|
18
|
+
# config.password = 'i<3words' # http basic authentication
|
19
|
+
# config.format = 'json' # optional, defaults to 'json'
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
def configure
|
23
|
+
yield(configuration) if block_given?
|
24
|
+
|
25
|
+
self.logger = configuration.logger
|
26
|
+
|
27
|
+
# remove :// from scheme
|
28
|
+
configuration.scheme.sub!(/:\/\//, '')
|
29
|
+
|
30
|
+
# remove http(s):// and anything after a slash
|
31
|
+
configuration.host.sub!(/https?:\/\//, '')
|
32
|
+
configuration.host = configuration.host.split('/').first
|
33
|
+
|
34
|
+
# Add leading and trailing slashes to base_path
|
35
|
+
configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
|
36
|
+
configuration.base_path = "" if configuration.base_path == "/"
|
37
|
+
end
|
38
|
+
|
39
|
+
def authenticated?
|
40
|
+
!SimplyRets.configuration.auth_token.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def de_authenticate
|
44
|
+
SimplyRets.configuration.auth_token = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def authenticate
|
48
|
+
return if SimplyRets.authenticated?
|
49
|
+
|
50
|
+
if SimplyRets.configuration.username.nil? || SimplyRets.configuration.password.nil?
|
51
|
+
raise ApiError, "Username and password are required to authenticate."
|
52
|
+
end
|
53
|
+
|
54
|
+
request = SimplyRets::Request.new(
|
55
|
+
:get,
|
56
|
+
"account/authenticate/{username}",
|
57
|
+
:params => {
|
58
|
+
:username => SimplyRets.configuration.username,
|
59
|
+
:password => SimplyRets.configuration.password
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
response_body = request.response.body
|
64
|
+
SimplyRets.configuration.auth_token = response_body['token']
|
65
|
+
end
|
66
|
+
|
67
|
+
def last_response
|
68
|
+
Thread.current[:simplyrets_last_response]
|
69
|
+
end
|
70
|
+
|
71
|
+
def last_response=(response)
|
72
|
+
Thread.current[:simplyrets_last_response] = response
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SimplyRetsClient
|
2
|
+
module SimplyRets
|
3
|
+
class ApiError < StandardError
|
4
|
+
attr_reader :code, :response_headers, :response_body
|
5
|
+
|
6
|
+
# Usage examples:
|
7
|
+
# ApiError.new
|
8
|
+
# ApiError.new("message")
|
9
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
10
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
11
|
+
def initialize(arg = nil)
|
12
|
+
if arg.is_a? Hash
|
13
|
+
arg.each do |k, v|
|
14
|
+
if k.to_s == 'message'
|
15
|
+
super v
|
16
|
+
else
|
17
|
+
instance_variable_set "@#{k}", v
|
18
|
+
end
|
19
|
+
end
|
20
|
+
else
|
21
|
+
super arg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module SimplyRetsClient
|
4
|
+
module SimplyRets
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :scheme, :host, :base_path, :user_agent, :format, :auth_token, :inject_format, :force_ending_format
|
7
|
+
|
8
|
+
# Defines the username used with HTTP basic authentication.
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :username
|
12
|
+
|
13
|
+
# Defines the password used with HTTP basic authentication.
|
14
|
+
#
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :password
|
17
|
+
|
18
|
+
# Defines API keys used with API Key authentications.
|
19
|
+
#
|
20
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
21
|
+
#
|
22
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
23
|
+
# config.api_key['api_key'] = 'xxx'
|
24
|
+
attr_accessor :api_key
|
25
|
+
|
26
|
+
# Defines API key prefixes used with API Key authentications.
|
27
|
+
#
|
28
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
29
|
+
#
|
30
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
31
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
32
|
+
attr_accessor :api_key_prefix
|
33
|
+
|
34
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
35
|
+
# Default to true.
|
36
|
+
#
|
37
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
38
|
+
#
|
39
|
+
# @return [true, false]
|
40
|
+
attr_accessor :verify_ssl
|
41
|
+
|
42
|
+
# Set this to customize the certificate file to verify the peer.
|
43
|
+
#
|
44
|
+
# @return [String] the path to the certificate file
|
45
|
+
#
|
46
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
47
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
48
|
+
attr_accessor :ssl_ca_cert
|
49
|
+
|
50
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
51
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
52
|
+
# Default to false.
|
53
|
+
#
|
54
|
+
# @return [true, false]
|
55
|
+
attr_accessor :debug
|
56
|
+
|
57
|
+
# Defines the logger used for debugging.
|
58
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
59
|
+
#
|
60
|
+
# @return [#debug]
|
61
|
+
attr_accessor :logger
|
62
|
+
|
63
|
+
# Defines the temporary folder to store downloaded files
|
64
|
+
# (for API endpoints that have file response).
|
65
|
+
# Default to use `Tempfile`.
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
attr_accessor :temp_folder_path
|
69
|
+
|
70
|
+
# Defines the headers to be used in HTTP requests of all API calls by default.
|
71
|
+
#
|
72
|
+
# @return [Hash]
|
73
|
+
attr_accessor :default_headers
|
74
|
+
|
75
|
+
# Defaults go in here..
|
76
|
+
def initialize
|
77
|
+
@format = 'json'
|
78
|
+
@scheme = 'https'
|
79
|
+
@host = 'api.simplyrets.com'
|
80
|
+
@base_path = '/'
|
81
|
+
@user_agent = "ruby-simplyrets-#{SimplyRets::VERSION}"
|
82
|
+
@inject_format = false
|
83
|
+
@force_ending_format = false
|
84
|
+
|
85
|
+
@default_headers = {
|
86
|
+
'Content-Type' => "application/#{@format.downcase}",
|
87
|
+
'User-Agent' => @user_agent
|
88
|
+
}
|
89
|
+
|
90
|
+
# keys for API key authentication (param-name => api-key)
|
91
|
+
@api_key = {}
|
92
|
+
@api_key_prefix = {}
|
93
|
+
|
94
|
+
@verify_ssl = true
|
95
|
+
|
96
|
+
@debug = false
|
97
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|