zuora_connect 2.0.5f → 2.0.5h

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ecdb5a9d063569ac82005b0356326e9c9b063e34865ad91afea19417115f7b2
4
- data.tar.gz: 41cab7d528348714fb1d892d61f2bfbafa5af4acf1c47b2f9e1af9a0a433bb6b
3
+ metadata.gz: f3ac4dedb3c0a45e3e06bdb5f896945c9133f73cc840ea1ee6e69f328a1d5b3d
4
+ data.tar.gz: adf9a515f860cf94c56b048cc9bde389640e1f6c4a46a9a4a4d599e3be18017f
5
5
  SHA512:
6
- metadata.gz: 6fccb7ce6ecf1348cd134b0fce2c23c0074b39456dea474271e80dc842494eb88f3cdf2956198771065aaeb921a68d3adec33d22bd7bae97deff3b2c1be32c40
7
- data.tar.gz: adf55d461e781b502abe944fab3e88ed5f2629aff2b102c643e5c316362529938172a640c09e396b7942a4eb9a8519fe8546e6a4e1691082af16f800944ba914
6
+ metadata.gz: 7487348f4ed6b1d59c7ce62ea033fcc6192cac73e6cce67973ddd79340331061b580ef78dad182cebb92af66dd3fbba0ddac35a552c1ca0f58f57c6c04a52d4d
7
+ data.tar.gz: d41ba2be63158fdc5f12e2f06c3c2b09e44a40779cf9a989c477e75b9e450eb2f4e9e5eeef6ef7e62facf263e599a886e77cc71dee66c356753159c3956b6d98
@@ -162,18 +162,18 @@ module ZuoraConnect
162
162
  @appinstance = ZuoraConnect::AppInstance.find(appinstances.to_h.keys.first)
163
163
 
164
164
  #Add user/update
165
- @user = ZuoraConnect::ZuoraUser.where(:zuora_user_id => zuora_user_id).first
166
- if @user.present?
165
+ @zuora_user = ZuoraConnect::ZuoraUser.where(:zuora_user_id => zuora_user_id).first
166
+ if @zuora_user.present?
167
167
  ZuoraConnect.logger.debug("Current zuora user #{zuora_user_id}")
168
- if @user.updated_at < Time.now - 1.day
169
- @user.zuora_identity_response[zuora_entity_id] = session["ZuoraCurrentIdentity"]
170
- @user.save!
168
+ if @zuora_user.updated_at < Time.now - 1.day
169
+ @zuora_user.zuora_identity_response[zuora_entity_id] = session["ZuoraCurrentIdentity"]
170
+ @zuora_user.save!
171
171
  end
172
172
  else
173
173
  ZuoraConnect.logger.debug("New zuora user object for #{zuora_user_id}")
174
- @user = ZuoraConnect::ZuoraUser.create!(:zuora_user_id => zuora_user_id, :zuora_identity_response => {zuora_entity_id => session["ZuoraCurrentIdentity"]})
174
+ @zuora_user = ZuoraConnect::ZuoraUser.create!(:zuora_user_id => zuora_user_id, :zuora_identity_response => {zuora_entity_id => session["ZuoraCurrentIdentity"]})
175
175
  end
176
- @user.session = session
176
+ @zuora_user.session = session
177
177
  session["appInstance"] = @appinstance.id
178
178
 
179
179
  #We have multiple, user must pick
@@ -193,14 +193,16 @@ module ZuoraConnect
193
193
  }
194
194
  return
195
195
  end
196
+
197
+ user = (ENV['DEIS_APP'] || "Application").split('-').map(&:capitalize).join(' ')
196
198
 
197
199
  body = {
198
200
  'userId' => zuora_user_id,
199
201
  'entityIds' => [zuora_entity_id.unpack("a8a4a4a4a12").join('-')],
200
202
  'customAuthorities' => [],
201
203
  'additionalInformation' => {
202
- 'description' => 'This user is for workflow application.',
203
- 'name' => 'Workflow API User'
204
+ 'description' => "This user is for #{user} application.",
205
+ 'name' => "#{user} API User"
204
206
  }
205
207
  }
206
208
 
@@ -220,7 +222,7 @@ module ZuoraConnect
220
222
  rescue Apartment::TenantExists => ex
221
223
  ZuoraConnect.logger.debug("Tenant Already Exists")
222
224
  end
223
-
225
+ available_entities = client_describe["accessibleEntities"].select {|entity| entity['id'] == client_describe['defaultEntityId']}
224
226
  task_data = {
225
227
  "id": next_id,
226
228
  "name": client_describe["tenantName"],
@@ -234,9 +236,9 @@ module ZuoraConnect
234
236
  "oauth_client_id": oauth_response['clientId'],
235
237
  "oauth_secret": oauth_response['clientSecret'],
236
238
  "authentication_type": "OAUTH",
237
- "entities": client_describe["accessibleEntities"].map {|e| e.merge({'displayName' => client_describe["tenantName"]})} #needs work
239
+ "entities": available_entities.map {|e| e.merge({'displayName' => client_describe["tenantName"]})}
238
240
  },
239
- "tenant_ids": client_describe["accessibleEntities"].map{|e| e['entityId'] }.push(client_describe["tenantId"]).uniq,
241
+ "tenant_ids": cavailable_entities.map{|e| e['entityId'] }.push(client_describe["tenantId"]).uniq,
240
242
  }
241
243
 
242
244
  @appinstance = ZuoraConnect::AppInstance.new(:id => next_id, :zuora_logins => task_data, :oauth_expires_at => Time.now + 1000.years)
@@ -312,6 +314,10 @@ module ZuoraConnect
312
314
  return session["#{@appinstance.id}::admin"]
313
315
  end
314
316
 
317
+ def zuora_user
318
+ return @zuora_user
319
+ end
320
+
315
321
  private
316
322
  def setup_instance_via_data
317
323
  session.clear
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "2.0.5f"
2
+ VERSION = "2.0.5h"
3
3
  end
@@ -4,6 +4,10 @@ module ZuoraConnect
4
4
  def is_app_admin?
5
5
  return @appinstance.blank? ? false : session["#{@appinstance.id}::admin"]
6
6
  end
7
+
8
+ def zuora_user
9
+ return @zuora_user
10
+ end
7
11
  end
8
12
  end
9
13
  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.5f
4
+ version: 2.0.5h
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment