zuora_connect 1.4.26 → 1.4.27
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 +25 -15
- 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: 68db8fc7b5747a7f48f637fa7617c9236fe855e3
|
|
4
|
+
data.tar.gz: 6e0f26cb0c70fa8c644b2feea037006e55790958
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ae942f39bf835b60bbc18f7ebba849786af486196a4a01c76bc91c95b2cbd356911348b92e6839a6c359bb89ea270555b9bf2d89df7ecd544a9a63e9a98292f
|
|
7
|
+
data.tar.gz: d5887de872edffc73cb60b1c43e42bfff6e9d59560010d7b7bb8fdf6194dd8000ea2b6f60e511a1914581a85cb826d5d5dc3c3b1b8dcf6329bf642c3fa3bf0eb
|
|
@@ -56,12 +56,12 @@ module ZuoraConnect
|
|
|
56
56
|
# entity_id: If the using catalog json be field to store multiple entity product catalogs.
|
|
57
57
|
# object: The Object class desired to be returned. Available [:product, :rateplan, :charge]
|
|
58
58
|
# object_id: The id or id's of the object/objects to be returned.
|
|
59
|
-
# child_objects: Whether to include child objects of the object in question.
|
|
59
|
+
# child_objects: Whether to include child objects of the object in question.
|
|
60
60
|
# cache: Store individual "1" object lookup in redis for caching.
|
|
61
61
|
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false)
|
|
62
62
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
|
63
63
|
|
|
64
|
-
if object_id.present? && ![Array, String].include?(object_id.class)
|
|
64
|
+
if object_id.present? && ![Array, String].include?(object_id.class)
|
|
65
65
|
raise "Object Id can only be a string or an array of strings"
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -77,17 +77,17 @@ module ZuoraConnect
|
|
|
77
77
|
case object
|
|
78
78
|
when :product
|
|
79
79
|
if object_id.blank?
|
|
80
|
-
string =
|
|
80
|
+
string =
|
|
81
81
|
"SELECT "\
|
|
82
82
|
"json_object_agg(product_id, product #{child_objects ? '' : '- \'productRatePlans\''}) AS item "\
|
|
83
83
|
"FROM "\
|
|
84
84
|
"\"public\".\"zuora_connect_app_instances\", "\
|
|
85
85
|
"jsonb_each((\"public\".\"zuora_connect_app_instances\".\"catalog\" #> '{%s}' )) AS e(product_id, product) "\
|
|
86
86
|
"WHERE "\
|
|
87
|
-
"\"id\" = %s" % [entity_reference, self.id]
|
|
87
|
+
"\"id\" = %s" % [entity_reference, self.id]
|
|
88
88
|
else
|
|
89
89
|
if object_id.class == String
|
|
90
|
-
string =
|
|
90
|
+
string =
|
|
91
91
|
"SELECT "\
|
|
92
92
|
"(catalog #> '{%s, %s}') #{child_objects ? '' : '- \'productRatePlans\''} AS item "\
|
|
93
93
|
"FROM "\
|
|
@@ -95,7 +95,7 @@ module ZuoraConnect
|
|
|
95
95
|
"WHERE "\
|
|
96
96
|
"\"id\" = %s" % [entity_reference, object_id, self.id]
|
|
97
97
|
elsif object_id.class == Array
|
|
98
|
-
string =
|
|
98
|
+
string =
|
|
99
99
|
"SELECT "\
|
|
100
100
|
"json_object_agg(product_id, product #{child_objects ? '' : '- \'productRatePlans\''}) AS item "\
|
|
101
101
|
"FROM "\
|
|
@@ -120,7 +120,7 @@ module ZuoraConnect
|
|
|
120
120
|
"\"id\" = %s" % [entity_reference, self.id]
|
|
121
121
|
else
|
|
122
122
|
if object_id.class == String
|
|
123
|
-
string =
|
|
123
|
+
string =
|
|
124
124
|
"SELECT "\
|
|
125
125
|
"(catalog #> '{%s, %s, productRatePlans, %s}') #{child_objects ? '' : '- \'productRatePlanCharges\''} AS item "\
|
|
126
126
|
"FROM "\
|
|
@@ -128,7 +128,7 @@ module ZuoraConnect
|
|
|
128
128
|
"WHERE "\
|
|
129
129
|
"\"id\" = %s" % [entity_reference, object_hierarchy['productId'], object_id, self.id]
|
|
130
130
|
elsif object_id.class == Array
|
|
131
|
-
string =
|
|
131
|
+
string =
|
|
132
132
|
"SELECT "\
|
|
133
133
|
"json_object_agg(rateplan_id, rateplan #{child_objects ? '' : '- \'productRatePlanCharges\''}) AS item "\
|
|
134
134
|
"FROM "\
|
|
@@ -155,7 +155,7 @@ module ZuoraConnect
|
|
|
155
155
|
"\"id\" = %s" % [entity_reference, self.id]
|
|
156
156
|
else
|
|
157
157
|
if object_id.class == String
|
|
158
|
-
string =
|
|
158
|
+
string =
|
|
159
159
|
"SELECT "\
|
|
160
160
|
"catalog #> '{%s, %s, productRatePlans, %s, productRatePlanCharges, %s}' AS item "\
|
|
161
161
|
"FROM "\
|
|
@@ -164,7 +164,7 @@ module ZuoraConnect
|
|
|
164
164
|
"\"id\" = %s" % [entity_reference, object_hierarchy['productId'], object_hierarchy['productRatePlanId'], object_id, self.id]
|
|
165
165
|
|
|
166
166
|
elsif object_id.class == Array
|
|
167
|
-
string =
|
|
167
|
+
string =
|
|
168
168
|
"SELECT "\
|
|
169
169
|
"json_object_agg(charge_id, charge) AS item "\
|
|
170
170
|
"FROM "\
|
|
@@ -183,11 +183,11 @@ module ZuoraConnect
|
|
|
183
183
|
|
|
184
184
|
stub_catalog ||= JSON.parse(ActiveRecord::Base.connection.execute(string).first["item"] || "{}")
|
|
185
185
|
|
|
186
|
-
if defined?(Redis.current) && object_id.present? && object_id.class == String
|
|
186
|
+
if defined?(Redis.current) && object_id.present? && object_id.class == String
|
|
187
187
|
Redis.current.set("Catalog:#{self.id}:#{object_id}:Hierarchy", encrypt_data(object_hierarchy))
|
|
188
|
-
Redis.current.set("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}", encrypt_data(stub_catalog)) if cache
|
|
188
|
+
Redis.current.set("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}", encrypt_data(stub_catalog)) if cache
|
|
189
189
|
end
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
return stub_catalog
|
|
192
192
|
end
|
|
193
193
|
|
|
@@ -208,13 +208,13 @@ module ZuoraConnect
|
|
|
208
208
|
Rails.logger.debug("Fetching catalog for default") if entity_id.blank?
|
|
209
209
|
Rails.logger.debug("Fetching catalog for entity #{entity_id}") if !entity_id.blank?
|
|
210
210
|
Rails.logger.debug("Fetch Catalog")
|
|
211
|
-
|
|
211
|
+
|
|
212
212
|
login = zuora_login.client(entity_reference)
|
|
213
213
|
|
|
214
214
|
old_logger = ActiveRecord::Base.logger
|
|
215
215
|
ActiveRecord::Base.logger = nil
|
|
216
216
|
ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{tmp}\', \'{}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp}\', \'{}\') where "id" = %{id}' % {:id => self.id})
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
response = {'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{page_size}")}
|
|
219
219
|
while !response["nextPage"].blank?
|
|
220
220
|
url = login.rest_endpoint(response["nextPage"].split('/v1/').last)
|
|
@@ -410,6 +410,7 @@ module ZuoraConnect
|
|
|
410
410
|
end
|
|
411
411
|
|
|
412
412
|
def refresh_oauth
|
|
413
|
+
count ||= 0
|
|
413
414
|
Rails.logger.debug("[#{self.id}] REFRESHING - OAuth")
|
|
414
415
|
params = {
|
|
415
416
|
:grant_type => "refresh_token",
|
|
@@ -426,6 +427,15 @@ module ZuoraConnect
|
|
|
426
427
|
else
|
|
427
428
|
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Refreshing Access Token", response.body, response.code)
|
|
428
429
|
end
|
|
430
|
+
rescue
|
|
431
|
+
if count < 3
|
|
432
|
+
Rails.logger.debug("REFRESHING - OAuth Failed - Retrying(#{count})")
|
|
433
|
+
count += 1
|
|
434
|
+
retry
|
|
435
|
+
else
|
|
436
|
+
Rails.logger.fatal("REFRESHING - OAuth Failed")
|
|
437
|
+
raise
|
|
438
|
+
end
|
|
429
439
|
end
|
|
430
440
|
|
|
431
441
|
def oauth_expired?
|
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.27
|
|
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-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord-session_store
|