realogy 0.6.8 → 0.6.10
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 +1 -1
- data/lib/realogy/app/models/realogy/entity.rb +34 -13
- data/lib/realogy/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e5c36fc0a5bd0540a03d4a2b15a27f0308843e3ee9f8c444d7b62ab9ab449f
|
4
|
+
data.tar.gz: 6d7765533f529ceff5d733cb2d524ca2dd82ff02620f8216ff6c253b09d6f2c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ca7f3041d3b123890046ca83bd0558b8a713030253186a9fc2882a5fc4297f09d4b89b04a119062a0c9ba8d7c32fdcbe01d2942bd696b1b87bd499fc45b0e0d
|
7
|
+
data.tar.gz: 9866700d33eda367d057882ab5b127eb8bc106f369315db4a7d16f75863baab767f91dcbeb27dd0db0e91a6fd30c3567da7a14845f1e00e17fc28fa0035f6d89
|
@@ -204,7 +204,7 @@ OAuth2::AccessToken.class_eval do
|
|
204
204
|
Rails.application.credentials.dig(:realogy, :client_secret),
|
205
205
|
token_url: Rails.application.credentials.dig(:realogy, :token_url)
|
206
206
|
)
|
207
|
-
if File.
|
207
|
+
if File.exist?(path)
|
208
208
|
File.open(path) do |f|
|
209
209
|
token = OAuth2::AccessToken.from_hash(client, JSON.parse(f.read))
|
210
210
|
end
|
@@ -6,58 +6,79 @@ class Realogy::Entity < ApplicationRecord
|
|
6
6
|
validates :last_update_on, presence: true
|
7
7
|
|
8
8
|
def needs_updating?
|
9
|
-
|
9
|
+
new_record? || last_update_on_changed? || data.blank?
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.triage
|
13
|
-
|
12
|
+
def self.triage(hash)
|
13
|
+
entity_id = [hash["entityId"], hash["id"]].compact.first
|
14
|
+
@object = find_or_initialize_by(entity_id: entity_id)
|
14
15
|
@object.last_update_on = hash["lastUpdateOn"].to_s.to_datetime
|
15
|
-
|
16
|
+
|
17
|
+
if data_provided_in_hash?(hash)
|
18
|
+
@object.data = extract_entity_data(hash)
|
19
|
+
@object.save if @object.changed?
|
20
|
+
elsif @object.needs_updating?
|
21
|
+
@object.populate
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def get_data
|
19
26
|
call = ["get_", self.class.to_s.downcase.split("::").last, "_by_id"].join.to_sym
|
20
|
-
Realogy::DataSync.client.__send__(call,
|
27
|
+
Realogy::DataSync.client.__send__(call, entity_id)
|
21
28
|
end
|
22
29
|
|
23
30
|
def populate
|
24
31
|
result = get_data
|
25
32
|
self.data = result unless result.blank?
|
26
|
-
|
33
|
+
save if changed?
|
27
34
|
end
|
28
35
|
|
29
36
|
def dig_for_array(*path)
|
30
|
-
return nil unless (json =
|
37
|
+
return nil unless (json = data).is_a?(Hash)
|
31
38
|
(v = json.dig(*path)).is_a?(Array) ? v : nil
|
32
39
|
end
|
33
40
|
|
34
41
|
def dig_for_boolean(*path)
|
35
|
-
return nil unless (json =
|
42
|
+
return nil unless (json = data).is_a?(Hash)
|
36
43
|
(v = json.dig(*path)).to_s.upcase.eql?("TRUE") ? true : nil
|
37
44
|
end
|
38
45
|
|
39
46
|
def dig_for_datetime(*path)
|
40
|
-
|
47
|
+
data.dig(*path).to_datetime rescue nil
|
41
48
|
end
|
42
49
|
|
43
50
|
def dig_for_decimal(*path)
|
44
|
-
return nil unless (json =
|
51
|
+
return nil unless (json = data).is_a?(Hash)
|
45
52
|
(v = json.dig(*path).to_f) != 0.0 ? v : nil
|
46
53
|
end
|
47
54
|
|
48
55
|
def dig_for_hash(*path)
|
49
|
-
return nil unless (json =
|
56
|
+
return nil unless (json = data).is_a?(Hash)
|
50
57
|
(v = json.dig(*path)).is_a?(Hash) ? v : nil
|
51
58
|
end
|
52
59
|
|
53
60
|
def dig_for_integer(*path)
|
54
|
-
return nil unless (json =
|
61
|
+
return nil unless (json = data).is_a?(Hash)
|
55
62
|
(v = json.dig(*path).to_i) != 0 ? v : nil
|
56
63
|
end
|
57
64
|
|
58
65
|
def dig_for_string(*path)
|
59
|
-
return nil unless (json =
|
66
|
+
return nil unless (json = data).is_a?(Hash)
|
60
67
|
(v = json.dig(*path)).to_s.present? ? (v.eql?("0") ? nil : v) : nil
|
61
68
|
end
|
62
69
|
|
70
|
+
class << self
|
71
|
+
private
|
72
|
+
|
73
|
+
def data_provided_in_hash?(hash)
|
74
|
+
# Check if hash contains entity data beyond just metadata fields
|
75
|
+
metadata_keys = %w[entityId id lastUpdateOn class action]
|
76
|
+
(hash.keys - metadata_keys).any?
|
77
|
+
end
|
78
|
+
|
79
|
+
def extract_entity_data(hash)
|
80
|
+
# Remove metadata fields and return just the entity data
|
81
|
+
hash.except("class", "action")
|
82
|
+
end
|
83
|
+
end
|
63
84
|
end
|
data/lib/realogy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realogy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Edlund
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -136,7 +135,6 @@ homepage: https://github.com/arcticleo/realogy
|
|
136
135
|
licenses:
|
137
136
|
- MIT
|
138
137
|
metadata: {}
|
139
|
-
post_install_message:
|
140
138
|
rdoc_options: []
|
141
139
|
require_paths:
|
142
140
|
- lib
|
@@ -151,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
149
|
- !ruby/object:Gem::Version
|
152
150
|
version: '0'
|
153
151
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
152
|
+
rubygems_version: 3.7.2
|
156
153
|
specification_version: 4
|
157
154
|
summary: Encapsulation of Realogy's DataSync API.
|
158
155
|
test_files: []
|