zuora_connect 2.0.60j → 2.0.60o
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 +81 -5
- data/app/models/zuora_connect/zuora_user.rb +1 -1
- data/lib/zuora_connect.rb +3 -0
- data/lib/zuora_connect/controllers/helpers.rb +5 -0
- data/lib/zuora_connect/version.rb +1 -1
- data/lib/zuora_connect/zuora_audit.rb +31 -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: 7d82918ec805d77782d6697f71fa0e28c85c75d243632207a2930046aeacdc60
|
4
|
+
data.tar.gz: 9f2341b491fbb516259cd0ace04482da657f688000609ba6cca99a9d85437fc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059e06f6514b2580a013cedf8e37843936465f44c1b55020d0fc790862b3f983b6ecac6696c2b899db8eba94bfccf6fe431b8ae7422c1ef241b1c833652b87a1'
|
7
|
+
data.tar.gz: 0174a924a7291780e970718d2c98a6bf43819eae85f4b71afd43f5f4214b357587967cd3072d7f9996d21fe97897903f5e4da9d0bcce7b4915421982dcef3d72
|
@@ -21,6 +21,7 @@ module ZuoraConnect
|
|
21
21
|
HOLDING_PATTERN_SLEEP = 5.seconds
|
22
22
|
CONNECT_APPLICATION_ID = 0
|
23
23
|
CONNECT_COMMUNICATION_SLEEP = Rails.env.test? ? 0.seconds : 5.seconds
|
24
|
+
CATALOG_LOOKUP_PAGE_SIZE = 10_000
|
24
25
|
IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh', 'de']
|
25
26
|
INTERNAL_HOSTS = []
|
26
27
|
LOGIN_TENANT_DESTINATION = 'target_login'
|
@@ -241,14 +242,35 @@ module ZuoraConnect
|
|
241
242
|
ZuoraConnect.logger.error(ex) if !IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
242
243
|
end
|
243
244
|
|
244
|
-
|
245
|
-
|
245
|
+
begin
|
246
|
+
sql = <<-eos
|
247
|
+
SELECT zuora_users.zuora_identity_response
|
248
|
+
FROM "#{self.id}".zuora_users
|
249
|
+
ORDER BY zuora_users.updated_at DESC
|
250
|
+
LIMIT 1;
|
251
|
+
eos
|
252
|
+
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
253
|
+
|
254
|
+
if user.present?
|
255
|
+
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
256
|
+
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
257
|
+
end
|
258
|
+
rescue => ex
|
259
|
+
Rails.logger.error('Failed to get users while setting app instance timezone', ex)
|
260
|
+
end
|
246
261
|
|
247
262
|
if self.user_timezone.present?
|
248
263
|
# connect instance which has a custom timezone
|
249
|
-
if !self.auto_deployed? &&
|
264
|
+
if !self.auto_deployed? && (
|
265
|
+
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
266
|
+
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
267
|
+
)
|
250
268
|
if self.environment == 'Production'
|
251
|
-
ZuoraConnect.logger.error(
|
269
|
+
ZuoraConnect.logger.error(
|
270
|
+
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
271
|
+
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
272
|
+
app_instance_id: self.id
|
273
|
+
)
|
252
274
|
end
|
253
275
|
self.user_timezone = nil
|
254
276
|
Time.zone = self.timezone
|
@@ -985,13 +1007,67 @@ module ZuoraConnect
|
|
985
1007
|
# object_id: The id or id's of the object/objects to be returned.
|
986
1008
|
# child_objects: Whether to include child objects of the object in question.
|
987
1009
|
# cache: Store individual "1" object lookup in redis for caching.
|
988
|
-
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false)
|
1010
|
+
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false, source: 'DB')
|
989
1011
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
990
1012
|
|
991
1013
|
if object_id.present? && ![Array, String].include?(object_id.class)
|
992
1014
|
raise "Object Id can only be a string or an array of strings"
|
993
1015
|
end
|
994
1016
|
|
1017
|
+
if source == 'API'
|
1018
|
+
zuora_login = self.login_lookup(type: 'Zuora').first
|
1019
|
+
login = zuora_login.client(entity_reference)
|
1020
|
+
|
1021
|
+
catalog_container = {}
|
1022
|
+
response = {
|
1023
|
+
'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{CATALOG_LOOKUP_PAGE_SIZE}")
|
1024
|
+
}
|
1025
|
+
while response['nextPage'].present?
|
1026
|
+
url = login.rest_endpoint(response['nextPage'].split('/v1/').last)
|
1027
|
+
output_json, response = login.rest_call(debug: false, url: url, timeout_retry: true)
|
1028
|
+
|
1029
|
+
case object
|
1030
|
+
when :product
|
1031
|
+
output_json.fetch('products', []).each do |product|
|
1032
|
+
if object_id.nil?
|
1033
|
+
catalog_container[product['id']] = product.except('productRatePlans')
|
1034
|
+
elsif object_id.is_a?(String)
|
1035
|
+
next unless product['id'] == object_id
|
1036
|
+
|
1037
|
+
rate_plans = {}
|
1038
|
+
product['productRatePlans'].each do |rate_plan|
|
1039
|
+
charges = {}
|
1040
|
+
rate_plan['productRatePlanCharges'].each do |charge|
|
1041
|
+
charges[charge['id']] = charge.merge(
|
1042
|
+
{
|
1043
|
+
'productId' => product['id'],
|
1044
|
+
'productName' => product['name'],
|
1045
|
+
'productRatePlanId' => rate_plan['id'],
|
1046
|
+
'productRatePlanName' => rate_plan['name'],
|
1047
|
+
}
|
1048
|
+
)
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
rate_plan['productRatePlanCharges'] = charges
|
1052
|
+
rate_plans[rate_plan['id']] = rate_plan.merge(
|
1053
|
+
{
|
1054
|
+
'productId' => product['id'],
|
1055
|
+
'productName' => product['name']
|
1056
|
+
}
|
1057
|
+
)
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
product['productRatePlans'] = rate_plans
|
1061
|
+
catalog_container = product
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
else
|
1065
|
+
raise "Available objects include [:product]"
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
return catalog_container
|
1069
|
+
end
|
1070
|
+
|
995
1071
|
if defined?(Redis.current) && object_id.present? && object_id.class == String && object_id.present?
|
996
1072
|
stub_catalog = cache ? decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}")) : nil
|
997
1073
|
object_hierarchy = decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Hierarchy"))
|
data/lib/zuora_connect.rb
CHANGED
@@ -13,6 +13,9 @@ require 'logging/connect_formatter'
|
|
13
13
|
require 'metrics/influx/point_value'
|
14
14
|
require 'metrics/net'
|
15
15
|
require 'mono_logger'
|
16
|
+
require 'zuora_connect/zuora_audit'
|
17
|
+
require 'active_record'
|
18
|
+
::ActiveRecord::Base.send :include, ZuoraConnect::ZuoraAudit
|
16
19
|
|
17
20
|
module ZuoraConnect
|
18
21
|
class << self
|
@@ -132,6 +132,9 @@ module ZuoraConnect
|
|
132
132
|
if locale.include?("-")
|
133
133
|
locale = locale.split("-").first
|
134
134
|
retry
|
135
|
+
elsif locale != session["#{@appinstance.id}::user::language"]
|
136
|
+
locale = session["#{@appinstance.id}::user::language"]
|
137
|
+
retry
|
135
138
|
end
|
136
139
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
137
140
|
end
|
@@ -439,6 +442,7 @@ module ZuoraConnect
|
|
439
442
|
@zuora_user = ZuoraConnect::ZuoraUser.create!(:zuora_user_id => zuora_user_id, :zuora_identity_response => {zuora_entity_id => session["ZuoraCurrentIdentity"]})
|
440
443
|
end
|
441
444
|
@zuora_user.session = session
|
445
|
+
ZuoraConnect::ZuoraUser.current_user = @zuora_user
|
442
446
|
session["#{@appinstance.id}::user::localUserId"] = @zuora_user.id
|
443
447
|
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
444
448
|
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
@@ -681,6 +685,7 @@ module ZuoraConnect
|
|
681
685
|
key = ZuoraConnect.configuration.dev_mode_pass
|
682
686
|
values = {:user => user , :key => key, :appinstance => session["appInstance"]}
|
683
687
|
@appinstance = ZuoraConnect::AppInstance.find_by(:id => values[:appinstance].to_i)
|
688
|
+
ZuoraConnect::ZuoraUser.current_user = user
|
684
689
|
if @appinstance.blank?
|
685
690
|
Apartment::Tenant.switch!("public")
|
686
691
|
begin
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Added by @Vina
|
2
|
+
# Description: This automatically stamp user created/updated the record for DataQuery Audit
|
3
|
+
# Usage: add 'zuora_audit' to your model.rb that you would like to track
|
4
|
+
|
5
|
+
module ZuoraConnect
|
6
|
+
module ZuoraAudit
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def zuora_audit
|
11
|
+
include ZuoraConnect::ZuoraAudit::ZuoraAuditInstanceMethods
|
12
|
+
after_create :set_created_by_id
|
13
|
+
before_update :set_updated_by_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ZuoraAuditInstanceMethods
|
18
|
+
def set_created_by_id
|
19
|
+
self.created_by_id = current_user_id if defined?(self.created_by_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_updated_by_id
|
23
|
+
self.updated_by_id = current_user_id if defined?(self.updated_by_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def current_user_id
|
27
|
+
return ZuoraConnect::ZuoraUser.current_user
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
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: 2.0.
|
4
|
+
version: 2.0.60o
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -374,6 +374,7 @@ files:
|
|
374
374
|
- lib/zuora_connect/exceptions.rb
|
375
375
|
- lib/zuora_connect/railtie.rb
|
376
376
|
- lib/zuora_connect/version.rb
|
377
|
+
- lib/zuora_connect/zuora_audit.rb
|
377
378
|
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
378
379
|
- test/dummy/README.rdoc
|
379
380
|
- test/dummy/Rakefile
|