realogy 0.5.9 → 0.6.2
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/.gitignore +0 -1
- data/Gemfile.lock +70 -0
- data/README.md +56 -14
- data/lib/realogy/app/models/data_sync.rb +36 -13
- data/lib/realogy/app/models/date_time.rb +11 -0
- data/lib/realogy/version.rb +1 -1
- data/lib/realogy.rb +1 -1
- data/realogy.gemspec +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f02721407645903a2d9ac60db41b1d8cbf634ca114dda8a59d30adc2f965de8c
|
4
|
+
data.tar.gz: 71e9bdeccb476d4410210361cc296a3185c683f63601da6d01f9560b1e9e8c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f761f642d02074648b93393a673e8174f1152b3f5b4227a073bcfbabbd9fef33edd806c65742becbd1f27a7dcd4a7a4e2e1847a2071afe51774b68a7b07de179
|
7
|
+
data.tar.gz: 5c0327820519b16c455ef8b6b4f7b8da293c4a4ac2b9558dbaca5f1feaf4217c9a60b104bca774d6434d45db67abdd47fceb8ef4372fc7cd25a165ce6ffac7ed
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
realogy (0.5.9)
|
5
|
+
activerecord (>= 5.0)
|
6
|
+
oauth2
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (7.0.2.3)
|
12
|
+
activesupport (= 7.0.2.3)
|
13
|
+
activerecord (7.0.2.3)
|
14
|
+
activemodel (= 7.0.2.3)
|
15
|
+
activesupport (= 7.0.2.3)
|
16
|
+
activesupport (7.0.2.3)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
concurrent-ruby (1.1.9)
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
faraday (2.2.0)
|
24
|
+
faraday-net_http (~> 2.0)
|
25
|
+
ruby2_keywords (>= 0.0.4)
|
26
|
+
faraday-net_http (2.0.1)
|
27
|
+
i18n (1.10.0)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
jwt (2.3.0)
|
30
|
+
minitest (5.15.0)
|
31
|
+
multi_json (1.15.0)
|
32
|
+
multi_xml (0.6.0)
|
33
|
+
oauth2 (1.4.9)
|
34
|
+
faraday (>= 0.17.3, < 3.0)
|
35
|
+
jwt (>= 1.0, < 3.0)
|
36
|
+
multi_json (~> 1.3)
|
37
|
+
multi_xml (~> 0.5)
|
38
|
+
rack (>= 1.2, < 3)
|
39
|
+
rack (2.2.3)
|
40
|
+
rake (13.0.6)
|
41
|
+
rspec (3.11.0)
|
42
|
+
rspec-core (~> 3.11.0)
|
43
|
+
rspec-expectations (~> 3.11.0)
|
44
|
+
rspec-mocks (~> 3.11.0)
|
45
|
+
rspec-core (3.11.0)
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-expectations (3.11.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.11.0)
|
50
|
+
rspec-mocks (3.11.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.11.0)
|
53
|
+
rspec-support (3.11.0)
|
54
|
+
ruby2_keywords (0.0.5)
|
55
|
+
sqlite3 (1.4.2)
|
56
|
+
tzinfo (2.0.4)
|
57
|
+
concurrent-ruby (~> 1.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
arm64-darwin-21
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
bundler (~> 2.3)
|
64
|
+
rake (>= 12.3.3)
|
65
|
+
realogy!
|
66
|
+
rspec (~> 3.0)
|
67
|
+
sqlite3
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
2.3.7
|
data/README.md
CHANGED
@@ -31,15 +31,16 @@ Set up for usage by creating Realogy's migration and running it.
|
|
31
31
|
rails g realogy:install
|
32
32
|
rails db:migrate
|
33
33
|
|
34
|
-
Realogy is expecting these
|
34
|
+
Realogy is expecting these encrypted credentials to be present to be able to function:
|
35
35
|
|
36
36
|
```
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
realogy:
|
38
|
+
client_id:
|
39
|
+
client_secret:
|
40
|
+
token_url:
|
41
|
+
scope:
|
42
|
+
subscription_key:
|
43
|
+
api_base_url:
|
43
44
|
```
|
44
45
|
|
45
46
|
### Available Rake Tasks
|
@@ -127,9 +128,10 @@ config.active_job.queue_adapter = :delayed_job
|
|
127
128
|
```ruby
|
128
129
|
realogy = Realogy::DataSync.client
|
129
130
|
```
|
130
|
-
#### Retrieve array of objects
|
131
131
|
|
132
|
-
|
132
|
+
#### Get active objects
|
133
|
+
|
134
|
+
The calls to retrieve active entities are:
|
133
135
|
|
134
136
|
```ruby
|
135
137
|
realogy.get_active_agents
|
@@ -139,20 +141,31 @@ realogy.get_active_offices
|
|
139
141
|
realogy.get_active_teams
|
140
142
|
```
|
141
143
|
|
142
|
-
When no argument is submitted, all entities are returned.
|
144
|
+
When no argument is submitted, all active entities are returned.
|
145
|
+
|
146
|
+
Filters can be applied for `brandCode` and `countryCode`. For example:
|
143
147
|
|
144
148
|
```ruby
|
145
149
|
# Fetch all active agents, for all brands, in all countries:
|
146
|
-
realogy.get_active_agents
|
150
|
+
realogy.get_active_agents
|
147
151
|
|
148
152
|
# Fetch all active agents, for all brands, in Sweden:
|
149
|
-
realogy.
|
153
|
+
realogy.get_active_companies(countryCode: "SE")
|
150
154
|
|
155
|
+
# Allowed brandCode values: C21, CB, ERA, SIR, BHG, CBC, ZIP, CLB, & COR
|
151
156
|
# Fetch all active Sotheby's agents in all countries:
|
152
|
-
realogy.
|
157
|
+
realogy.get_active_offices(brandCode: "SIR")
|
153
158
|
|
154
159
|
# Fetch all active Sotheby's agents in Sweden:
|
155
|
-
realogy.
|
160
|
+
realogy.get_active_teams(brandCode: "SIR", countryCode: "SE")
|
161
|
+
```
|
162
|
+
|
163
|
+
When fetching listings, the type of listing can also be specified:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
# Allowed type values: ForSale, ForRent, ForSaleCommercial, & ForLeaseCommercial
|
167
|
+
# Fetch all active agents, for all brands, in all countries:
|
168
|
+
realogy.get_active_listings(type: "ForSale")
|
156
169
|
```
|
157
170
|
|
158
171
|
#### Retrieve delta of objects
|
@@ -179,6 +192,35 @@ realogy.get_offices_delta({since: 5.minutes.ago})
|
|
179
192
|
realogy.get_teams_delta({since: 1.day.ago})
|
180
193
|
```
|
181
194
|
|
195
|
+
#### Get all listings
|
196
|
+
|
197
|
+
To retrieve all listings, `fromDate` and `brandCode` are mandatory parameters. A minimum call to retrieve all listing entities could look like this:
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string)
|
201
|
+
```
|
202
|
+
|
203
|
+
These are additional filters that can be applied:
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
# fromDate and toDate must be converted to supported text format. This is done with to_query_string:
|
207
|
+
realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string, toDate: DateTime.now.to_query_string)
|
208
|
+
|
209
|
+
# Allowed type values: ForSale, ForRent, ForSaleCommercial, & ForLeaseCommercial
|
210
|
+
realogy.get_all_listings(brandCode: "C21", fromDate: 1.week.ago.to_query_string, type: "ForSale")
|
211
|
+
|
212
|
+
# Allowed status values: Active, Available, Pending, & Closed
|
213
|
+
realogy.get_all_listings(brandCode: "CB", fromDate: 1.week.ago.to_query_string, status: "Active")
|
214
|
+
|
215
|
+
# Limit results to a particular country
|
216
|
+
realogy.get_all_listings(brandCode: "SIR", fromDate: 1.week.ago.to_query_string, countryCode: "IT")
|
217
|
+
|
218
|
+
# Limit number of listings per result batch. Allowed span: 10–1000.
|
219
|
+
realogy.get_all_listings(brandCode: "BHG", fromDate: 1.week.ago.to_query_string, limit: 10)
|
220
|
+
|
221
|
+
```
|
222
|
+
|
223
|
+
|
182
224
|
#### Retrieve JSON object
|
183
225
|
|
184
226
|
```ruby
|
@@ -4,13 +4,13 @@ module Realogy
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'oauth2'
|
6
6
|
require 'json'
|
7
|
-
|
7
|
+
|
8
8
|
@@instance = Realogy::DataSync.new
|
9
9
|
|
10
10
|
def self.client
|
11
11
|
return @@instance
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
private_class_method :new
|
15
15
|
|
16
16
|
# API endpoints by type
|
@@ -23,6 +23,10 @@ module Realogy
|
|
23
23
|
get_active_teams: "teams/active"
|
24
24
|
}
|
25
25
|
|
26
|
+
ALL_API_ENDPOINTS = {
|
27
|
+
get_all_listings: "listings/all"
|
28
|
+
}
|
29
|
+
|
26
30
|
DELTA_API_ENDPOINTS = {
|
27
31
|
get_agents_delta: "agents/delta",
|
28
32
|
get_companies_delta: "companies/delta",
|
@@ -47,7 +51,26 @@ module Realogy
|
|
47
51
|
endpoint = ACTIVE_API_ENDPOINTS[method_name]
|
48
52
|
params = {
|
49
53
|
'brandCode': hash[:brandCode],
|
50
|
-
'countryCode': hash[:countryCode]
|
54
|
+
'countryCode': hash[:countryCode],
|
55
|
+
'type': hash[:type]
|
56
|
+
}.compact
|
57
|
+
return perform_api_call(endpoint, params)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
ALL_API_ENDPOINTS.keys.each do |method_name|
|
62
|
+
define_method method_name do |*args|
|
63
|
+
hash = args.first.is_a?(::Hash) ? args.first : {}
|
64
|
+
endpoint = ALL_API_ENDPOINTS[method_name]
|
65
|
+
params = {
|
66
|
+
'brandCode': hash[:brandCode],
|
67
|
+
'countryCode': hash[:countryCode],
|
68
|
+
'cursor': hash[:cursor],
|
69
|
+
'fromDate': hash[:fromDate],
|
70
|
+
'limit': hash[:limit],
|
71
|
+
'status': hash[:status],
|
72
|
+
'toDate': hash[:toDate],
|
73
|
+
'type': hash[:type]
|
51
74
|
}.compact
|
52
75
|
return perform_api_call(endpoint, params)
|
53
76
|
end
|
@@ -81,13 +104,13 @@ module Realogy
|
|
81
104
|
# Utility
|
82
105
|
|
83
106
|
def uri_for_endpoint endpoint
|
84
|
-
return URI([
|
107
|
+
return URI([Rails.application.credentials.dig(:realogy, :api_base_url), endpoint].join("/"))
|
85
108
|
end
|
86
109
|
|
87
110
|
def perform_simple_call(url)
|
88
111
|
uri = URI(url)
|
89
112
|
request = Net::HTTP::Get.new(uri)
|
90
|
-
request['Ocp-Apim-Subscription-Key'] =
|
113
|
+
request['Ocp-Apim-Subscription-Key'] = Rails.application.credentials.dig(:realogy, :subscription_key)
|
91
114
|
request['Authorization'] = "Bearer #{auth_token}"
|
92
115
|
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
93
116
|
http.max_retries = 10
|
@@ -101,7 +124,7 @@ module Realogy
|
|
101
124
|
uri = uri_for_endpoint(endpoint)
|
102
125
|
uri.query && uri.query.length > 0 ? uri.query += '&' + query : uri.query = query
|
103
126
|
request = Net::HTTP::Get.new(uri.request_uri)
|
104
|
-
request['Ocp-Apim-Subscription-Key'] =
|
127
|
+
request['Ocp-Apim-Subscription-Key'] = Rails.application.credentials.dig(:realogy, :subscription_key)
|
105
128
|
request['Authorization'] = "Bearer #{auth_token}"
|
106
129
|
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
107
130
|
http.max_retries = 10
|
@@ -112,10 +135,10 @@ module Realogy
|
|
112
135
|
|
113
136
|
def auth_token
|
114
137
|
oauth2_client_credentials_token(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
138
|
+
Rails.application.credentials.dig(:realogy, :client_id),
|
139
|
+
Rails.application.credentials.dig(:realogy, :client_secret),
|
140
|
+
Rails.application.credentials.dig(:realogy, :token_url),
|
141
|
+
Rails.application.credentials.dig(:realogy, :scope)
|
119
142
|
)
|
120
143
|
end
|
121
144
|
|
@@ -148,9 +171,9 @@ OAuth2::AccessToken.class_eval do
|
|
148
171
|
data = nil
|
149
172
|
token = nil
|
150
173
|
client = OAuth2::Client.new(
|
151
|
-
|
152
|
-
|
153
|
-
token_url:
|
174
|
+
Rails.application.credentials.dig(:realogy, :client_id),
|
175
|
+
Rails.application.credentials.dig(:realogy, :client_secret),
|
176
|
+
token_url: Rails.application.credentials.dig(:realogy, :token_url)
|
154
177
|
)
|
155
178
|
if File.exists?(path)
|
156
179
|
File.open(path) do |f|
|
data/lib/realogy/version.rb
CHANGED
data/lib/realogy.rb
CHANGED
@@ -2,7 +2,7 @@ require "realogy/version"
|
|
2
2
|
require "realogy/railtie" if defined?(Rails)
|
3
3
|
require "realogy/app/models/application_record.rb"
|
4
4
|
require "realogy/app/models/data_sync.rb"
|
5
|
-
require "realogy/app/models/
|
5
|
+
require "realogy/app/models/date_time.rb"
|
6
6
|
require "realogy/app/models/hash.rb"
|
7
7
|
require "realogy/app/models/realogy/entity.rb"
|
8
8
|
require "realogy/app/models/realogy/agent.rb"
|
data/realogy.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "~>
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.3"
|
26
26
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
28
28
|
spec.add_development_dependency 'sqlite3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realogy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Edlund
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- ".travis.yml"
|
108
108
|
- CODE_OF_CONDUCT.md
|
109
109
|
- Gemfile
|
110
|
+
- Gemfile.lock
|
110
111
|
- LICENSE.txt
|
111
112
|
- README.md
|
112
113
|
- Rakefile
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- lib/realogy/app/jobs/populate_realogy_entity_job.rb
|
120
121
|
- lib/realogy/app/models/application_record.rb
|
121
122
|
- lib/realogy/app/models/data_sync.rb
|
123
|
+
- lib/realogy/app/models/date_time.rb
|
122
124
|
- lib/realogy/app/models/hash.rb
|
123
125
|
- lib/realogy/app/models/realogy/agent.rb
|
124
126
|
- lib/realogy/app/models/realogy/company.rb
|
@@ -134,7 +136,7 @@ homepage: https://github.com/arcticleo/realogy
|
|
134
136
|
licenses:
|
135
137
|
- MIT
|
136
138
|
metadata: {}
|
137
|
-
post_install_message:
|
139
|
+
post_install_message:
|
138
140
|
rdoc_options: []
|
139
141
|
require_paths:
|
140
142
|
- lib
|
@@ -149,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
- !ruby/object:Gem::Version
|
150
152
|
version: '0'
|
151
153
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
154
|
+
rubygems_version: 3.3.7
|
155
|
+
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: Encapsulation of Realogy's DataSync API.
|
156
158
|
test_files: []
|