zuora_connect 2.0.60k → 2.0.60p
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/zuora_connect/app_instance_base.rb +65 -3
- 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: 49954ce1a10057c773fa3dbc859cccd19e756297192ee85d276cada97c085446
|
4
|
+
data.tar.gz: bd0ce83a9631479cb2402383c5a53e104742d19fb83b951d24cdf5fe66b48bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1e341cea3b729c967af29ecfaa9bd143ef656a415487654ae59870ef75e3b719d4873975aa12fe6b845b3916d8ef1de2f63faca22c42c89280058d404c8d3b7
|
7
|
+
data.tar.gz: 22804e4a0db2285d91ef7c1da8fab9d67261ff13302b48db31f872c820d3b037425ece070a41aa3a119c1bfc7be039a78a6298ff99066b0a2fb3bbfeb6559a40
|
@@ -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'
|
@@ -260,9 +261,16 @@ module ZuoraConnect
|
|
260
261
|
|
261
262
|
if self.user_timezone.present?
|
262
263
|
# connect instance which has a custom timezone
|
263
|
-
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
|
+
)
|
264
268
|
if self.environment == 'Production'
|
265
|
-
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
|
+
)
|
266
274
|
end
|
267
275
|
self.user_timezone = nil
|
268
276
|
Time.zone = self.timezone
|
@@ -999,13 +1007,67 @@ module ZuoraConnect
|
|
999
1007
|
# object_id: The id or id's of the object/objects to be returned.
|
1000
1008
|
# child_objects: Whether to include child objects of the object in question.
|
1001
1009
|
# cache: Store individual "1" object lookup in redis for caching.
|
1002
|
-
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')
|
1003
1011
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
1004
1012
|
|
1005
1013
|
if object_id.present? && ![Array, String].include?(object_id.class)
|
1006
1014
|
raise "Object Id can only be a string or an array of strings"
|
1007
1015
|
end
|
1008
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
|
+
|
1009
1071
|
if defined?(Redis.current) && object_id.present? && object_id.class == String && object_id.present?
|
1010
1072
|
stub_catalog = cache ? decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}")) : nil
|
1011
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_id = zuora_user_id
|
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_id = 0
|
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
|
+
before_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_id
|
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.60p
|
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-
|
11
|
+
date: 2020-11-12 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
|