realogy 0.3.1 → 0.3.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/lib/realogy/app/models/data_sync.rb +29 -1
- data/lib/realogy/app/models/realogy/entity.rb +2 -1
- data/lib/realogy/version.rb +1 -1
- data/realogy-0.3.1.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c57f98326c067508c84f5073c33bd538a44f94608c472a1d01c9fc79ffbca2ba
|
4
|
+
data.tar.gz: 55981de8712110d8eb7fe6f4656ba7896543e67fe48c3d32ba428d145c35e754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60fe61f7b9013cf023bc22619cc94fbdf381ef1e06d26d0f8ab07255f6f7ba31ce762dd377bbcdce81f59197563e0f83bae7e80f3b36de324128e78f64b67408
|
7
|
+
data.tar.gz: 73dce272f6726bfadd8eda74043ecdc09df97dbe72aee6b678deef54ea7cc3704277f05de4653cee5677074c5d2a8cdf15e383513523b436caf65e720ef36516
|
@@ -3,6 +3,7 @@ module Realogy
|
|
3
3
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'oauth2'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
@@instance = Realogy::DataSync.new
|
8
9
|
|
@@ -104,7 +105,7 @@ module Realogy
|
|
104
105
|
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
105
106
|
http.request(request)
|
106
107
|
end
|
107
|
-
return JSON(response.body)
|
108
|
+
return JSON(response.body) rescue nil
|
108
109
|
end
|
109
110
|
|
110
111
|
def auth_token
|
@@ -126,14 +127,41 @@ module Realogy
|
|
126
127
|
end
|
127
128
|
|
128
129
|
def oauth2_client_credentials_token(client_id, client_secret, token_url, scope)
|
130
|
+
@token = OAuth2::AccessToken.read_token_from_file(".oauth-access-token.json")
|
129
131
|
expiry = @token.try(:expires_at).present? ? DateTime.strptime(@token.expires_at.to_s, '%s') : 1.day.ago
|
130
132
|
if expiry > DateTime.now.utc
|
131
133
|
return @token.token
|
132
134
|
else
|
133
135
|
@token = oauth2_client_credentials_token_object(client_id, client_secret, token_url, scope)
|
136
|
+
@token.save_token_to_file(".oauth-access-token.json")
|
134
137
|
return @token.token
|
135
138
|
end
|
136
139
|
end
|
137
140
|
|
138
141
|
end
|
139
142
|
end
|
143
|
+
|
144
|
+
OAuth2::AccessToken.class_eval do
|
145
|
+
def self.read_token_from_file path
|
146
|
+
data = nil
|
147
|
+
token = nil
|
148
|
+
client = OAuth2::Client.new(
|
149
|
+
ENV["REALOGY_CLIENT_ID"],
|
150
|
+
ENV["REALOGY_CLIENT_SECRET"],
|
151
|
+
token_url: ENV["REALOGY_TOKEN_URL"]
|
152
|
+
)
|
153
|
+
if File.exists?(path)
|
154
|
+
File.open(path) do |f|
|
155
|
+
token = OAuth2::AccessToken.from_hash(client, JSON.parse(f.read))
|
156
|
+
end
|
157
|
+
end
|
158
|
+
return token
|
159
|
+
end
|
160
|
+
|
161
|
+
def save_token_to_file path
|
162
|
+
File.open(path, "w+") do |f|
|
163
|
+
f << self.to_hash.to_json
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -17,7 +17,8 @@ class Realogy::Entity < ApplicationRecord
|
|
17
17
|
|
18
18
|
def populate
|
19
19
|
call = ["get_", self.class.to_s.downcase.split("::").last, "_by_id"].join.to_sym
|
20
|
-
|
20
|
+
result = Realogy::DataSync.client.__send__(call, self.entity_id)
|
21
|
+
self.data = result unless result.blank?
|
21
22
|
self.save if self.changed?
|
22
23
|
end
|
23
24
|
|
data/lib/realogy/version.rb
CHANGED
data/realogy-0.3.1.gem
ADDED
Binary file
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Edlund
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- realogy-0.1.0.gem
|
132
132
|
- realogy-0.2.0.gem
|
133
133
|
- realogy-0.3.0.gem
|
134
|
+
- realogy-0.3.1.gem
|
134
135
|
- realogy.gemspec
|
135
136
|
homepage: https://github.com/arcticleo/realogy
|
136
137
|
licenses:
|