zuora_connect 1.4.12 → 1.4.13a
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 +22 -11
- data/lib/zuora_connect/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e57dbd41b6b3061db0b57e211bf1b53deee71d6
|
4
|
+
data.tar.gz: 2a18c93ae7ab502bd165fa6dda57a21ff70b4db5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b739b5d69418ddc0dcac8d70e454a932a9c829090685eae8d75d011ad3bdc12894f238b57ea5cb37dfd7e459bf10b2792413a7bf1e0d4bfc78074ff496f3c76
|
7
|
+
data.tar.gz: d57d581cd02e8c52b24d204e31edfac7af8ae7a96563cbde43255d19b39f95da6bad91b012b287ff6a3337eb24f7a9093fdf1ac5c06784cdb0879087f2243fa5
|
@@ -23,16 +23,20 @@ module ZuoraConnect
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def cache_app_instance
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if defined?(Redis)
|
27
|
+
Redis.current.set("AppInstance:#{self.id}", encrypt_data(self.save_data.to_json))
|
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)
|
39
|
+
return data if data.blank?
|
36
40
|
return Rails.env == 'development' ? data : encryptor.encrypt_and_sign(data)
|
37
41
|
end
|
38
42
|
|
@@ -51,13 +55,18 @@ module ZuoraConnect
|
|
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
|
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"})
|
58
|
+
|
59
|
+
if defined?(Redis) && !object_id.blank?
|
60
|
+
stub_catalog = decrypt_data(Redis.current.get("Catalog:#{self.id}:#{object_id}"))
|
61
|
+
end
|
54
62
|
|
55
63
|
case object
|
56
64
|
when :product
|
57
65
|
if object_id.blank?
|
58
|
-
stub_catalog
|
66
|
+
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"] || "{}")
|
67
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog))
|
59
68
|
else
|
60
|
-
stub_catalog
|
69
|
+
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"] || "{}")
|
61
70
|
end
|
62
71
|
|
63
72
|
if !map_lower_objects
|
@@ -65,9 +74,10 @@ module ZuoraConnect
|
|
65
74
|
end
|
66
75
|
when :rateplan
|
67
76
|
if object_id.blank?
|
68
|
-
stub_catalog
|
77
|
+
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"] || "{}")
|
78
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog))
|
69
79
|
else
|
70
|
-
stub_catalog
|
80
|
+
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"] || "{}")
|
71
81
|
end
|
72
82
|
|
73
83
|
if !map_lower_objects
|
@@ -75,9 +85,10 @@ module ZuoraConnect
|
|
75
85
|
end
|
76
86
|
when :charge
|
77
87
|
if object_id.blank?
|
78
|
-
stub_catalog
|
88
|
+
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"] || "{}")
|
89
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}", encrypt_data(stub_catalog))
|
79
90
|
else
|
80
|
-
stub_catalog
|
91
|
+
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"] || "{}")
|
81
92
|
end
|
82
93
|
end
|
83
94
|
|
@@ -96,7 +107,7 @@ module ZuoraConnect
|
|
96
107
|
return results
|
97
108
|
end
|
98
109
|
|
99
|
-
def get_catalog(zuora_login: self.login_lookup(type: "Zuora").first, entity_id: nil)
|
110
|
+
def get_catalog(page_size: 5, zuora_login: self.login_lookup(type: "Zuora").first, entity_id: nil)
|
100
111
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
101
112
|
Rails.logger.debug("Fetching catalog for default") if entity_id.blank?
|
102
113
|
Rails.logger.debug("Fetching catalog for entity #{entity_id}") if !entity_id.blank?
|
@@ -109,7 +120,7 @@ module ZuoraConnect
|
|
109
120
|
ActiveRecord::Base.logger = nil
|
110
121
|
ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{%{entity}}\', \'{}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{%{entity}}\', \'{}\') where "id" = %{id}' % {:entity => entity_reference, :id => self.id})
|
111
122
|
|
112
|
-
response = {'nextPage' => login.rest_endpoint(
|
123
|
+
response = {'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{page_size}")}
|
113
124
|
while !response["nextPage"].blank?
|
114
125
|
url = login.rest_endpoint(response["nextPage"].split('/v1/').last)
|
115
126
|
Rails.logger.debug("Fetch Catalog URL #{url}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.13a
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
@@ -297,9 +297,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
297
297
|
version: '0'
|
298
298
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
299
|
requirements:
|
300
|
-
- - "
|
300
|
+
- - ">"
|
301
301
|
- !ruby/object:Gem::Version
|
302
|
-
version:
|
302
|
+
version: 1.3.1
|
303
303
|
requirements: []
|
304
304
|
rubyforge_project:
|
305
305
|
rubygems_version: 2.6.8
|