zuora_connect 1.4.13 → 1.4.14
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/app/models/zuora_connect/app_instance_base.rb +27 -11
- data/lib/zuora_connect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 077a25dc2d6bcd586fb61024dc7b4afbd59d8f88
|
4
|
+
data.tar.gz: ca164373466c60e40379266f5e5abd2dc1c38a76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd291bd585b089603743ae549c46d63c4d49b39945458ff737312079bb19060905b63dc0b465017614697a871b26774aed0795d91a170606ce3573139c2e069e
|
7
|
+
data.tar.gz: e033ed78d360990bfd58e4aab9463c0098777206f3b1fa75229a1201ee59b29da5aa51ca9e71217d3fcc984b62ddba6475a1eabf29cdfc5ae6e4129412da7795
|
@@ -23,17 +23,21 @@ module ZuoraConnect
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def cache_app_instance
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if defined?(Redis.current)
|
27
|
+
Redis.current.set("AppInstance:#{self.id}", encrypt_data(self.save_data))
|
28
|
+
Redis.current.expire("AppInstance:#{self.id}", 60.minutes.to_i)
|
29
|
+
Redis.current.del("Deleted:#{self.id}")
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def decrypt_data(data)
|
34
|
+
return data if data.blank?
|
32
35
|
return Rails.env == 'development' ? JSON.parse(data) : JSON.parse(encryptor.decrypt_and_verify(CGI::unescape(data)))
|
33
36
|
end
|
34
37
|
|
35
38
|
def encrypt_data(data)
|
36
|
-
return
|
39
|
+
return data if data.blank?
|
40
|
+
return Rails.env == 'development' ? data.to_json : encryptor.encrypt_and_sign(data.to_json)
|
37
41
|
end
|
38
42
|
|
39
43
|
def encryptor
|
@@ -50,14 +54,24 @@ module ZuoraConnect
|
|
50
54
|
|
51
55
|
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, map_lower_objects: true)
|
52
56
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
53
|
-
|
57
|
+
|
58
|
+
if defined?(Redis.current) && !object_id.blank?
|
59
|
+
stub_catalog = decrypt_data(Redis.current.get("Catalog:#{self.id}:#{object_id}"))
|
60
|
+
object_hierarchy = decrypt_data(Redis.current.get("Catalog:#{self.id}:Hierarchy:#{object_id}"))
|
61
|
+
end
|
62
|
+
|
63
|
+
if defined?(object_hierarchy)
|
64
|
+
object_hierarchy ||= (JSON.parse(ActiveRecord::Base.connection.execute('SELECT catalog_mapping #> \'{%s}\' AS item FROM "public"."zuora_connect_app_instances" WHERE "id" = %s LIMIT 1' % [entity_reference, self.id]).first["item"] || "{}") [object_id] || {"productId" => "SAFTEY", "productRatePlanId" => "SAFTEY", "productRatePlanChargeId" => "SAFTEY"})
|
65
|
+
Redis.current.set("Catalog:#{self.id}:Hierarchy:#{object_id}", encrypt_data(object_hierarchy)) if defined?(Redis.current)
|
66
|
+
end
|
54
67
|
|
55
68
|
case object
|
56
69
|
when :product
|
57
70
|
if object_id.blank?
|
58
|
-
stub_catalog
|
71
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT catalog #> \'{%s}\' AS item FROM "public"."zuora_connect_app_instances" WHERE "id" = %s' % [entity_reference, self.id]).first["item"] || "{}")
|
59
72
|
else
|
60
|
-
stub_catalog
|
73
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT catalog #> \'{%s, %s}\' AS item FROM "public"."zuora_connect_app_instances" WHERE "id" = %s' % [entity_reference, object_id, self.id]).first["item"] || "{}")
|
74
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog)) if defined?(Redis.current)
|
61
75
|
end
|
62
76
|
|
63
77
|
if !map_lower_objects
|
@@ -65,9 +79,10 @@ module ZuoraConnect
|
|
65
79
|
end
|
66
80
|
when :rateplan
|
67
81
|
if object_id.blank?
|
68
|
-
stub_catalog
|
82
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT json_object_agg(rateplan_id, rateplan) AS item FROM "public"."zuora_connect_app_instances", jsonb_each(("public"."zuora_connect_app_instances"."catalog" #> \'{%s}\' )) AS e(product_id, product), jsonb_each(product #> \'{productRatePlans}\') AS ee(rateplan_id, rateplan) WHERE "id" = %s' % [entity_reference, self.id]).first["item"] || "{}")
|
69
83
|
else
|
70
|
-
stub_catalog
|
84
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT catalog #> \'{%s, %s, productRatePlans, %s}\' AS item FROM "public"."zuora_connect_app_instances" WHERE "id" = %s' % [entity_reference, object_hierarchy['productId'], object_id, self.id]).first["item"] || "{}")
|
85
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog)) if defined?(Redis.current)
|
71
86
|
end
|
72
87
|
|
73
88
|
if !map_lower_objects
|
@@ -75,9 +90,10 @@ module ZuoraConnect
|
|
75
90
|
end
|
76
91
|
when :charge
|
77
92
|
if object_id.blank?
|
78
|
-
stub_catalog
|
93
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT json_object_agg(charge_id, charge) as item FROM "public"."zuora_connect_app_instances", jsonb_each(("public"."zuora_connect_app_instances"."catalog" #> \'{%s}\' )) AS e(product_id, product), jsonb_each(product #> \'{productRatePlans}\') AS ee(rateplan_id, rateplan), jsonb_each(rateplan #> \'{productRatePlanCharges}\') AS eee(charge_id, charge) WHERE "id" = %s' % [entity_reference, self.id]).first["item"] || "{}")
|
79
94
|
else
|
80
|
-
stub_catalog
|
95
|
+
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute('SELECT catalog #> \'{%s, %s, productRatePlans, %s, productRatePlanCharges, %s}\' AS item FROM "public"."zuora_connect_app_instances" WHERE "id" = %s' % [entity_reference, object_hierarchy['productId'], object_hierarchy['productRatePlanId'], object_id, self.id]).first["item"] || "{}")
|
96
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog)) if defined?(Redis.current)
|
81
97
|
end
|
82
98
|
end
|
83
99
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-session_store
|