zuora_connect 3.2.3 → 3.2.4

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: 3442f4b39c0b917e66b7d64fd07e631773f9db276ea60c3c2f0e9382d09c1d23
4
- data.tar.gz: 0e2f0d9d8a90488a1a6fc5d64e7eccbc38403483828c59fed0d7710f970f2d39
3
+ metadata.gz: 616f15048a650618223bf57d362d0284f50a0d66b36228940a684ca364432dfb
4
+ data.tar.gz: 702b6927ff3a14059378ee64be74f7cb8403cb6794d688a76f0d9aea03da32b6
5
5
  SHA512:
6
- metadata.gz: 00e597ca1cf6203a875cf82b9c5c9b439e495d2d69e53977b9a1c9f0bb310f24db9bb379bd9cbd7304d0e3628ae871205c21c9b90966bff462f25e78b69ed8eb
7
- data.tar.gz: 50dd2bbeb894e9b1fed6a33ccefb9bb90e889698f4d2c36079ee05543331112043a430dbc207c97c2ea25584a34eab62d0b27de34dbeda9f74afb4f65239f6aa
6
+ metadata.gz: 8ae3fc967fa600378ff3d40df0515fe781fc1c3e6fab1598581eca49d123903f2e91f944dc6db64294350b3a73674ca42912e45aa78bbe70bd83f326ea815005
7
+ data.tar.gz: 37549efe15ebef568920fa4b8923d0f2106486b5beffbe7a3e04ebbda3dea2ff358e656d7fee5e9771efac4e3ac6c79ef79d73a64e2682d054cddf536f2aa7a5
@@ -20,6 +20,8 @@ module ZuoraConnect
20
20
 
21
21
  @appinstance = ZuoraConnect::AppInstance.find_by(id: app_instance_id)
22
22
  ZuoraConnect::ZuoraUser.current_user_id = 0
23
+ zuora_org_ids = cookies['Zuora-Org-Ids'] || request.headers['Zuora-Org-Ids']
24
+ ZuoraConnect::ZuoraUser.current_org_ids = zuora_org_ids.split('|') if zuora_org_ids
23
25
  if @appinstance.blank?
24
26
  Apartment::Tenant.switch!('public')
25
27
  begin
@@ -3,7 +3,7 @@ module ZuoraConnect
3
3
  self.table_name = "zuora_users"
4
4
  attr_accessor :session
5
5
 
6
- cattr_accessor :current_user_id, :current_org_id, :current_org_child_org_ids
6
+ cattr_accessor :current_user_id, :current_org_ids
7
7
 
8
8
  # zuora_user_id/zuora_entity_id both come from cookie or headers
9
9
  # zuora_current_identity comes from session
@@ -66,62 +66,9 @@ module ZuoraConnect
66
66
  end
67
67
 
68
68
  @zuora_user = ZuoraConnect::ZuoraUser.find_by(zuora_user_id: ZuoraConnect::ZuoraUser.current_user_id)
69
+ zuora_org_ids = request.headers["Zuora-Org-Ids"]
70
+ ZuoraConnect::ZuoraUser.current_org_ids = zuora_org_ids.split('|') if zuora_org_ids
69
71
 
70
- zuora_org_id = request.headers["Zuora-Org-Id"]
71
- zuora_return_nested_orgs_data = request.headers['Zuora-Return-Nested-Orgs-Data'].to_bool
72
- ZuoraConnect::ZuoraUser.current_org_id = zuora_org_id
73
- ZuoraConnect::ZuoraUser.current_org_child_org_ids = []
74
-
75
- if zuora_org_id.present? && zuora_return_nested_orgs_data
76
- cached_org_relationship = Redis.current.get("MultiOrgRelationship:#{@appinstance.id}")
77
-
78
- if cached_org_relationship.present?
79
- cached_org_relationship = JSON.parse(cached_org_relationship)
80
- ZuoraConnect::ZuoraUser.current_org_child_org_ids =
81
- get_child_orgs_from_relation_mapping(cached_org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
82
- else
83
- begin
84
- zuora_client = @appinstance.target_login.client
85
- child_org_list, _ =
86
- zuora_client.rest_call(
87
- url: zuora_client.
88
- rest_endpoint("tenant-registry/listChildOrgsForOrg/#{ZuoraConnect::ZuoraUser.current_org_id}").
89
- gsub('v1/', ''),
90
- session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
91
- zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
92
- )
93
-
94
- root_org_id = (child_org_list || {}).dig(0, 'rootOrgId').to_s
95
- if root_org_id.present?
96
- root_child_org_list, _ =
97
- zuora_client.rest_call(
98
- url: zuora_client.
99
- rest_endpoint("tenant-registry/listChildOrgsForOrg/#{root_org_id}").
100
- gsub('v1/', ''),
101
- session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
102
- zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
103
- )
104
-
105
- org_relationship = org_relation_mapping(root_child_org_list)
106
- Redis.current.setex(
107
- "MultiOrgRelationship:#{@appinstance.id}",
108
- 1.day,
109
- org_relationship.to_json
110
- )
111
-
112
- ZuoraConnect::ZuoraUser.current_org_child_org_ids =
113
- get_child_orgs_from_relation_mapping(org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
114
- else
115
- ZuoraConnect.logger.info("Failed to get root org id for #{@appinstance.id}")
116
- end
117
- rescue ZuoraAPI::Exceptions::ZuoraAPIError => ex
118
- render json: {
119
- status: 401,
120
- message: ex.message
121
- }.to_json, status: :unauthorized
122
- end
123
- end
124
- end
125
72
  end
126
73
  end
127
74
 
@@ -282,40 +229,6 @@ module ZuoraConnect
282
229
  def hallway_integration?
283
230
  return (request.headers['ZuoraCurrentEntity'].present? || cookies['ZuoraCurrentEntity'].present?)
284
231
  end
285
-
286
- def org_relation_mapping(root_org_relation)
287
- relation = {}
288
-
289
- return relation if root_org_relation.blank?
290
-
291
- root_org_id = root_org_relation.dig(0, 'rootOrgId')
292
- relation[root_org_id] = []
293
-
294
- root_org_relation.each do |child_org|
295
- relation[child_org['id']] = []
296
- end
297
-
298
- root_org_relation.each do |child_org|
299
- parent_org_id = child_org['parentOrgId']
300
- relation[parent_org_id].push(child_org['id'])
301
- end
302
-
303
- relation
304
- end
305
-
306
- def get_child_orgs_from_relation_mapping(relation_mapping, org_id)
307
- if relation_mapping.blank? || org_id.blank? || relation_mapping[org_id].blank?
308
- return []
309
- end
310
-
311
- child_orgs = relation_mapping[org_id].dup
312
- relation_mapping[org_id].each do |child_org_id|
313
- child_orgs += get_child_orgs_from_relation_mapping(relation_mapping, child_org_id)
314
- end
315
-
316
- child_orgs
317
- end
318
-
319
232
  def create_new_instance
320
233
  ZuoraConnect::AppInstance.read_master_db do
321
234
  Thread.current[:appinstance] = nil
@@ -646,57 +559,8 @@ module ZuoraConnect
646
559
  session["appInstance"] = @appinstance.id
647
560
  end
648
561
 
649
- zuora_org_id = cookies['Zuora-Org-Id'] || request.headers['Zuora-Org-Id']
650
- zuora_return_nested_orgs_data =
651
- cookies['Zuora-Return-Nested-Orgs-Data'].to_bool ||
652
- request.headers['Zuora-Return-Nested-Orgs-Data'].to_bool
653
- ZuoraConnect::ZuoraUser.current_org_id = zuora_org_id
654
- ZuoraConnect::ZuoraUser.current_org_child_org_ids = []
655
-
656
- if zuora_org_id.present? && zuora_return_nested_orgs_data
657
- cached_org_relationship = Redis.current.get("MultiOrgRelationship:#{@appinstance.id}")
658
-
659
- if cached_org_relationship.present?
660
- cached_org_relationship = JSON.parse(cached_org_relationship)
661
- ZuoraConnect::ZuoraUser.current_org_child_org_ids =
662
- get_child_orgs_from_relation_mapping(cached_org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
663
- else
664
- child_org_list, _ =
665
- zuora_client.rest_call(
666
- url: zuora_client.
667
- rest_endpoint("tenant-registry/listChildOrgsForOrg/#{ZuoraConnect::ZuoraUser.current_org_id}").
668
- gsub('v1/', ''),
669
- session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
670
- headers: auth_headers,
671
- zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
672
- )
673
-
674
- root_org_id = (child_org_list || {}).dig(0, 'rootOrgId').to_s
675
- if root_org_id.present?
676
- root_child_org_list, _ =
677
- zuora_client.rest_call(
678
- url: zuora_client.
679
- rest_endpoint("tenant-registry/listChildOrgsForOrg/#{root_org_id}").
680
- gsub('v1/', ''),
681
- session_type: zuora_client.is_a?(ZuoraAPI::Oauth) ? :bearer : :basic,
682
- headers: auth_headers,
683
- zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id
684
- )
685
-
686
- org_relationship = org_relation_mapping(root_child_org_list)
687
- Redis.current.setex(
688
- "MultiOrgRelationship:#{@appinstance.id}",
689
- 1.day,
690
- org_relationship.to_json
691
- )
692
-
693
- ZuoraConnect::ZuoraUser.current_org_child_org_ids =
694
- get_child_orgs_from_relation_mapping(org_relationship, ZuoraConnect::ZuoraUser.current_org_id)
695
- else
696
- ZuoraConnect.logger.info("Failed to get root org id for #{@appinstance.id}")
697
- end
698
- end
699
- end
562
+ zuora_org_ids = cookies['Zuora-Org-Ids'] || request.headers['Zuora-Org-Ids']
563
+ ZuoraConnect::ZuoraUser.current_org_ids = zuora_org_ids.split('|') if zuora_org_ids
700
564
 
701
565
  rescue ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError => ex
702
566
  output_xml, input_xml, response = zuora_client.soap_call(errors: [], z_session: false, zuora_track_id: ZuoraConnect::RequestIdMiddleware.zuora_request_id) do |xml|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZuoraConnect
4
- VERSION = "3.2.3"
4
+ VERSION = "3.2.4"
5
5
  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: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment