zuora_connect 2.0.60m → 2.0.60r
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 +73 -1
- data/app/models/zuora_connect/zuora_user.rb +1 -1
- data/config/initializers/prometheus.rb +1 -1
- data/lib/zuora_connect/controllers/helpers.rb +2 -2
- data/lib/zuora_connect/version.rb +1 -1
- data/lib/zuora_connect/zuora_audit.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6b7949598476b39650e1fb8b5f4c0940715a4fd7ceea1945b5049f93a468d41
|
4
|
+
data.tar.gz: 8505c3ee1339e3ce136424898b8202466c3264391e5920c0107f706927edae15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c89370d8c846ace233b99f76ef6ee53aa0ec54deb4a7005457b154ae2597c2f6f8e9120816eb47a99083acf1429d770d6b01406af3f58b0f1e29904bfca54988
|
7
|
+
data.tar.gz: 20214d6197712b2aaf380535fbb2e635b0296cd8271c85f1bac28e3bacbb1587eea40542b4ac9a93c1f55ab71788c9b9c0a3eb424eee1d9d53f79042f3811c65
|
@@ -21,6 +21,10 @@ 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
|
25
|
+
CATALOG_LOOKUP_CACHE_TIME_KEY = 'CatalogCachedAt'
|
26
|
+
CATALOG_LOOKUP_TTL = 60.seconds
|
27
|
+
CATALOG_LOOKUP_CACHE_RESULT_KEY = 'CatalogCache'
|
24
28
|
IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh', 'de']
|
25
29
|
INTERNAL_HOSTS = []
|
26
30
|
LOGIN_TENANT_DESTINATION = 'target_login'
|
@@ -1006,13 +1010,81 @@ module ZuoraConnect
|
|
1006
1010
|
# object_id: The id or id's of the object/objects to be returned.
|
1007
1011
|
# child_objects: Whether to include child objects of the object in question.
|
1008
1012
|
# cache: Store individual "1" object lookup in redis for caching.
|
1009
|
-
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false)
|
1013
|
+
def catalog_lookup(entity_id: nil, object: :product, object_id: nil, child_objects: false, cache: false, source: 'DB')
|
1010
1014
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
1011
1015
|
|
1012
1016
|
if object_id.present? && ![Array, String].include?(object_id.class)
|
1013
1017
|
raise "Object Id can only be a string or an array of strings"
|
1014
1018
|
end
|
1015
1019
|
|
1020
|
+
if source == 'API'
|
1021
|
+
catalog_container = {}
|
1022
|
+
|
1023
|
+
if (Redis.current.hget(CATALOG_LOOKUP_CACHE_TIME_KEY, self.id).to_i + CATALOG_LOOKUP_TTL.to_i) > Time.now.to_i
|
1024
|
+
begin
|
1025
|
+
catalog_container = JSON.parse(Redis.current.hget(CATALOG_LOOKUP_CACHE_RESULT_KEY, self.id))
|
1026
|
+
rescue JSON::ParserError => ex
|
1027
|
+
Rails.logger.warn('Failed to parse catalog cache', ex)
|
1028
|
+
end
|
1029
|
+
else
|
1030
|
+
zuora_login = self.login_lookup(type: 'Zuora').first
|
1031
|
+
login = zuora_login.client(entity_reference)
|
1032
|
+
|
1033
|
+
response = {
|
1034
|
+
'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{CATALOG_LOOKUP_PAGE_SIZE}")
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
while response['nextPage'].present?
|
1038
|
+
url = login.rest_endpoint(response['nextPage'].split('/v1/').last)
|
1039
|
+
output_json, response = login.rest_call(debug: false, url: url, timeout_retry: true)
|
1040
|
+
|
1041
|
+
case object
|
1042
|
+
when :product
|
1043
|
+
output_json.fetch('products', []).each do |product|
|
1044
|
+
rate_plans = {}
|
1045
|
+
product['productRatePlans'].each do |rate_plan|
|
1046
|
+
charges = {}
|
1047
|
+
rate_plan['productRatePlanCharges'].each do |charge|
|
1048
|
+
charges[charge['id']] = charge.merge(
|
1049
|
+
{
|
1050
|
+
'productId' => product['id'],
|
1051
|
+
'productName' => product['name'],
|
1052
|
+
'productRatePlanId' => rate_plan['id'],
|
1053
|
+
'productRatePlanName' => rate_plan['name'],
|
1054
|
+
}
|
1055
|
+
)
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
rate_plan['productRatePlanCharges'] = charges
|
1059
|
+
rate_plans[rate_plan['id']] = rate_plan.merge(
|
1060
|
+
{
|
1061
|
+
'productId' => product['id'],
|
1062
|
+
'productName' => product['name']
|
1063
|
+
}
|
1064
|
+
)
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
product['productRatePlans'] = rate_plans
|
1068
|
+
catalog_container[product['id']] = product
|
1069
|
+
end
|
1070
|
+
else
|
1071
|
+
raise "Available objects include [:product]"
|
1072
|
+
end
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
Redis.current.hset(CATALOG_LOOKUP_CACHE_RESULT_KEY, self.id, catalog_container.to_json)
|
1076
|
+
Redis.current.hset(CATALOG_LOOKUP_CACHE_TIME_KEY, self.id, Time.now.to_i)
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
if object_id.nil?
|
1080
|
+
catalog_container.transform_values! { |v| v.except('productRatePlans') }
|
1081
|
+
elsif object_id.is_a?(String)
|
1082
|
+
catalog_container = catalog_container[object_id]
|
1083
|
+
end
|
1084
|
+
|
1085
|
+
return catalog_container
|
1086
|
+
end
|
1087
|
+
|
1016
1088
|
if defined?(Redis.current) && object_id.present? && object_id.class == String && object_id.present?
|
1017
1089
|
stub_catalog = cache ? decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Children:#{child_objects}")) : nil
|
1018
1090
|
object_hierarchy = decrypt_data(data: Redis.current.get("Catalog:#{self.id}:#{object_id}:Hierarchy"))
|
@@ -27,7 +27,7 @@ if defined? Prometheus
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def export
|
30
|
-
filename = File.join(@path,
|
30
|
+
filename = File.join(@path, "resque_export_#{Process.pid}.prom")
|
31
31
|
@lock.synchronize do
|
32
32
|
File.open(filename, 'w+') do |file|
|
33
33
|
file.write(Prometheus::Client::Formats::Text.marshal(@registry))
|
@@ -442,7 +442,7 @@ module ZuoraConnect
|
|
442
442
|
@zuora_user = ZuoraConnect::ZuoraUser.create!(:zuora_user_id => zuora_user_id, :zuora_identity_response => {zuora_entity_id => session["ZuoraCurrentIdentity"]})
|
443
443
|
end
|
444
444
|
@zuora_user.session = session
|
445
|
-
ZuoraConnect::ZuoraUser.
|
445
|
+
ZuoraConnect::ZuoraUser.current_user_id = zuora_user_id
|
446
446
|
session["#{@appinstance.id}::user::localUserId"] = @zuora_user.id
|
447
447
|
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
448
448
|
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
@@ -685,7 +685,7 @@ module ZuoraConnect
|
|
685
685
|
key = ZuoraConnect.configuration.dev_mode_pass
|
686
686
|
values = {:user => user , :key => key, :appinstance => session["appInstance"]}
|
687
687
|
@appinstance = ZuoraConnect::AppInstance.find_by(:id => values[:appinstance].to_i)
|
688
|
-
ZuoraConnect::ZuoraUser.
|
688
|
+
ZuoraConnect::ZuoraUser.current_user_id = 0
|
689
689
|
if @appinstance.blank?
|
690
690
|
Apartment::Tenant.switch!("public")
|
691
691
|
begin
|
@@ -9,7 +9,7 @@ module ZuoraConnect
|
|
9
9
|
module ClassMethods
|
10
10
|
def zuora_audit
|
11
11
|
include ZuoraConnect::ZuoraAudit::ZuoraAuditInstanceMethods
|
12
|
-
|
12
|
+
before_create :set_created_by_id
|
13
13
|
before_update :set_updated_by_id
|
14
14
|
end
|
15
15
|
end
|
@@ -24,7 +24,7 @@ module ZuoraConnect
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def current_user_id
|
27
|
-
return ZuoraConnect::ZuoraUser.
|
27
|
+
return ZuoraConnect::ZuoraUser.current_user_id
|
28
28
|
end
|
29
29
|
end
|
30
30
|
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.60r
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|