zuora_connect 3.0.2.pre.g → 3.0.2.pre.k
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b4a4c2927c6b81722708d1a63d756c904baaa5a8476851bce38da0e45d6215f
|
4
|
+
data.tar.gz: ed4dfa6c6e9c70b6c22af27904b9688f814504ad17caf2ee6fe31ad6417b7135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce54ad080c6a485e5b20bedb43989646a97460891819666409fbedb0192ad36e6efeddf5a8a2259d740222137cdd51ceacc72df77de326334cd451746ceaa75
|
7
|
+
data.tar.gz: 3c5adcb73a7b967dd4335af2ebbb0a91202313632fdc9beebe25e58da7278646aedf48eb6178ee3ce5385549d5269f9a4f95629441cd8e144eb5432062727894
|
@@ -266,7 +266,8 @@ module ZuoraConnect
|
|
266
266
|
|
267
267
|
params = {
|
268
268
|
name: self.task_data.dig('name'),
|
269
|
-
zuora_entity_ids: (self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities') || []).map{|e| e['id']}.uniq,
|
269
|
+
zuora_entity_ids: (self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities') || []).select {|entity| !entity['skip'].to_bool}.map{|e| e['id']}.uniq,
|
270
|
+
zuora_global_tenant_id: task_data.dig(LOGIN_TENANT_DESTINATION, 'entities', 0, 'globalEntityId').to_i, # tenant id of the global/parent entity, 0 if nil
|
270
271
|
zuora_tenant_ids: tenants.map(&:to_s).uniq,
|
271
272
|
organizations: organizations
|
272
273
|
}
|
@@ -277,6 +278,9 @@ module ZuoraConnect
|
|
277
278
|
params.merge!({zuora_domain: client.rest_domain, environment: client.environment })
|
278
279
|
end
|
279
280
|
end
|
281
|
+
|
282
|
+
# makes it safe to add elements to params which don't correspond to existing columns in an app's schema
|
283
|
+
# rejects those elements which do not correspond to model attributes for your app
|
280
284
|
params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) || self[k] == v}
|
281
285
|
self.update_columns(params) if params.present?
|
282
286
|
end
|
@@ -813,7 +817,7 @@ module ZuoraConnect
|
|
813
817
|
def strip_cache_data(object: {}, keys: ['applications', 'tokens','tenant_ids', 'organizations','user_settings'] )
|
814
818
|
keys.each {|key| object.delete(key) }
|
815
819
|
object.select {|k,v| k.include?('login') && v['tenant_type'] == 'Zuora'}.each do |login_key, login_data|
|
816
|
-
object[login_key]['entities'] = login_data.fetch('entities',[]).map {|entity| entity.slice('id', 'tenantId', 'entityId', 'displayName')}
|
820
|
+
object[login_key]['entities'] = login_data.fetch('entities',[]).map {|entity| entity.slice('id', 'tenantId', 'entityId', 'displayName', 'identifier')}
|
817
821
|
end
|
818
822
|
return object
|
819
823
|
end
|
@@ -1,27 +1,29 @@
|
|
1
1
|
module ZuoraConnect
|
2
2
|
class Login
|
3
|
-
|
3
|
+
attr_accessor :clients, :identifier_to_ids, :default_entity
|
4
4
|
def initialize (fields)
|
5
|
-
|
5
|
+
self.clients = {}
|
6
|
+
self.identifier_to_ids = {}
|
6
7
|
if fields["tenant_type"] == "Zuora"
|
7
8
|
login_fields = fields.map{|k,v| [k.to_sym, v]}.to_h
|
8
9
|
login_type = fields.dig("authentication_type").blank? ? 'Basic' : fields.dig("authentication_type").capitalize
|
9
10
|
|
10
11
|
raise ZuoraConnect::Exceptions::InvalidCredentialSet.new("Cannot setup application with ZSession Login.") if login_type == "Session"
|
11
|
-
|
12
|
-
|
12
|
+
self.clients["Default"] = "::ZuoraAPI::#{login_type}".constantize.new(**login_fields)
|
13
|
+
self.default_entity = fields["entities"][0]["id"] if (fields.dig("entities") || []).size == 1
|
13
14
|
if fields["entities"] && fields["entities"].size > 0
|
14
15
|
fields["entities"].each do |entity|
|
15
|
-
params = {:entity_id => entity["id"]}.merge(login_fields)
|
16
|
-
|
16
|
+
params = {:entity_id => entity["id"], :entity_identifier => entity["identifier"]}.merge(login_fields)
|
17
|
+
self.clients[entity["id"]] = "::ZuoraAPI::#{login_type}".constantize.new(**params)
|
18
|
+
self.identifier_to_ids[entity["identifier"]] = entity["id"]
|
17
19
|
end
|
18
20
|
end
|
19
|
-
self.attr_builder("available_entities",
|
21
|
+
self.attr_builder("available_entities", self.clients.keys)
|
20
22
|
end
|
21
23
|
fields.each do |k,v|
|
22
24
|
self.attr_builder(k,v)
|
23
25
|
end
|
24
|
-
|
26
|
+
self.default_entity ||= "Default"
|
25
27
|
end
|
26
28
|
|
27
29
|
def attr_builder(field,val)
|
@@ -29,9 +31,19 @@ module ZuoraConnect
|
|
29
31
|
send("#{field}=", val)
|
30
32
|
end
|
31
33
|
|
32
|
-
def client(id =
|
33
|
-
|
34
|
-
|
34
|
+
def client(id = self.default_entity)
|
35
|
+
use_entity_name = self.identifier_to_ids.keys.include?(id)
|
36
|
+
|
37
|
+
# Translate entity name to entity id
|
38
|
+
id = self.identifier_to_ids[id] if use_entity_name
|
39
|
+
|
40
|
+
client = id.blank? ? self.clients[self.default_entity] : self.clients[id]
|
35
41
|
|
42
|
+
if client
|
43
|
+
client.entity_header_type = use_entity_name ? :entity_name : :entity_id
|
44
|
+
end
|
45
|
+
|
46
|
+
client
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
@@ -8,13 +8,16 @@ module ZuoraConnect
|
|
8
8
|
# zuora_user_id/zuora_entity_id both come from cookie or headers
|
9
9
|
# zuora_current_identity comes from session
|
10
10
|
# app_instance is only needed to try to migrate :/
|
11
|
-
def self.update_id_response(zuora_user_id, zuora_entity_id, zuora_current_identity, app_instance)
|
11
|
+
def self.update_id_response(zuora_user_id, zuora_entity_id, zuora_current_identity, app_instance, permissions)
|
12
12
|
zuora_user = find_or_create_by!(zuora_user_id: zuora_user_id) do |user|
|
13
13
|
user.zuora_identity_response = { zuora_entity_id => zuora_current_identity }
|
14
|
+
user.app_permissions = permissions
|
14
15
|
end
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
zuora_user.zuora_identity_response[zuora_entity_id] = zuora_current_identity
|
18
|
+
zuora_user.app_permissions = permissions
|
19
|
+
|
20
|
+
if zuora_user.changed?
|
18
21
|
zuora_user.save!
|
19
22
|
end
|
20
23
|
|
@@ -28,11 +31,5 @@ module ZuoraConnect
|
|
28
31
|
app_instance.apartment_switch(nil, true)
|
29
32
|
retry
|
30
33
|
end
|
31
|
-
|
32
|
-
# NOTE(hartley): this value was extracted from original usage in helper,
|
33
|
-
# need to investigate when exactly the identity_response should be updated
|
34
|
-
def stale_identity?
|
35
|
-
updated_at < Time.now - 1.day
|
36
|
-
end
|
37
34
|
end
|
38
35
|
end
|
@@ -64,6 +64,8 @@ module ZuoraConnect
|
|
64
64
|
else
|
65
65
|
check_instance
|
66
66
|
end
|
67
|
+
|
68
|
+
@zuora_user = ZuoraConnect::ZuoraUser.find_by(zuora_user_id: ZuoraConnect::ZuoraUser.current_user_id)
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -419,7 +421,8 @@ module ZuoraConnect
|
|
419
421
|
if defined?(@appinstance) && !@appinstance['zuora_logins'].nil?
|
420
422
|
@zuora_user = ZuoraConnect::ZuoraUser.update_id_response(
|
421
423
|
zuora_user_id, zuora_entity_id, session["ZuoraCurrentIdentity"],
|
422
|
-
@appinstance
|
424
|
+
@appinstance,
|
425
|
+
session['ZuoraCurrentUserInfo']['permissions']
|
423
426
|
)
|
424
427
|
@zuora_user.session = session
|
425
428
|
ZuoraConnect::ZuoraUser.current_user_id = zuora_user_id
|
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: 3.0.2.pre.
|
4
|
+
version: 3.0.2.pre.k
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08
|
11
|
+
date: 2021-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|