realogy 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/realogy/app/models/data_sync.rb +12 -12
- data/lib/realogy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12d8e93945c23e56e01fbe630bec8fdbe5ce249bd3b005a86d4a6912d9784db4
|
4
|
+
data.tar.gz: 4d10e4f50b4966dc5c9ba7f3b520db7d521f9406799822bd80cf9f422c4589a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd20fd303e29928de9b4f087dca56ccaf4c42934bb17d1e71439bf343b02add61d9c449a0fa94b9bfe6fc959273006bb987cdcd7381dc7542134b844fef18a6b
|
7
|
+
data.tar.gz: ba898e4b69cd3db029e63db391117a337f10d66a2770a7ba932eb85885f44d8708c6c5dc2474688fef4cfed5123f388fa676675ed6ad67098ed5d6020074b94f
|
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
|
@@ -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
|
@@ -81,13 +81,13 @@ module Realogy
|
|
81
81
|
# Utility
|
82
82
|
|
83
83
|
def uri_for_endpoint endpoint
|
84
|
-
return URI([
|
84
|
+
return URI([Rails.application.credentials.dig(:realogy, :api_base_url), endpoint].join("/"))
|
85
85
|
end
|
86
86
|
|
87
87
|
def perform_simple_call(url)
|
88
88
|
uri = URI(url)
|
89
89
|
request = Net::HTTP::Get.new(uri)
|
90
|
-
request['Ocp-Apim-Subscription-Key'] =
|
90
|
+
request['Ocp-Apim-Subscription-Key'] = Rails.application.credentials.dig(:realogy, :subscription_key)
|
91
91
|
request['Authorization'] = "Bearer #{auth_token}"
|
92
92
|
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
93
93
|
http.max_retries = 10
|
@@ -101,7 +101,7 @@ module Realogy
|
|
101
101
|
uri = uri_for_endpoint(endpoint)
|
102
102
|
uri.query && uri.query.length > 0 ? uri.query += '&' + query : uri.query = query
|
103
103
|
request = Net::HTTP::Get.new(uri.request_uri)
|
104
|
-
request['Ocp-Apim-Subscription-Key'] =
|
104
|
+
request['Ocp-Apim-Subscription-Key'] = Rails.application.credentials.dig(:realogy, :subscription_key)
|
105
105
|
request['Authorization'] = "Bearer #{auth_token}"
|
106
106
|
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
107
107
|
http.max_retries = 10
|
@@ -112,10 +112,10 @@ module Realogy
|
|
112
112
|
|
113
113
|
def auth_token
|
114
114
|
oauth2_client_credentials_token(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
Rails.application.credentials.dig(:realogy, :client_id),
|
116
|
+
Rails.application.credentials.dig(:realogy, :client_secret),
|
117
|
+
Rails.application.credentials.dig(:realogy, :token_url),
|
118
|
+
Rails.application.credentials.dig(:realogy, :scope)
|
119
119
|
)
|
120
120
|
end
|
121
121
|
|
@@ -148,9 +148,9 @@ OAuth2::AccessToken.class_eval do
|
|
148
148
|
data = nil
|
149
149
|
token = nil
|
150
150
|
client = OAuth2::Client.new(
|
151
|
-
|
152
|
-
|
153
|
-
token_url:
|
151
|
+
Rails.application.credentials.dig(:realogy, :client_id),
|
152
|
+
Rails.application.credentials.dig(:realogy, :client_secret),
|
153
|
+
token_url: Rails.application.credentials.dig(:realogy, :token_url)
|
154
154
|
)
|
155
155
|
if File.exists?(path)
|
156
156
|
File.open(path) do |f|
|
data/lib/realogy/version.rb
CHANGED