zuora_connect 3.1.0.pre.a → 3.1.0.pre.d

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: 1bfbbb07eb966a69d84820c47abc61d68930e326962a7254fbaff709fc5e734f
4
- data.tar.gz: 8f964b17242b8db5ec83bf8bd70d5ec113bd4f6dabbfefac8005548a079b0272
3
+ metadata.gz: 8a5ca7980f0c3e5418bbd8b34d277421c00bbe709870ca1f17088c16e65a7454
4
+ data.tar.gz: 5465170884c82258888725799568a8d43e70ddceb968652c284335397023875f
5
5
  SHA512:
6
- metadata.gz: 9240e5e7e344b0886407c9eb90abcc0a464c1d0a86daba0043871844003f954a3b9748086b21169f01d4e696428188181bb5d35feb38ebb75f804f9e862ff2df
7
- data.tar.gz: 365883658d6fe47b2996f35bd2382380788983d9564378930864031361b42ce58efd6a46a65b7341313e7d9c0b9f6afcc180ad28f4b2540862155003ced1ca03
6
+ metadata.gz: 623b63683caba7ac18d08da2fba2b9d5db96eb24b9d0e0b833b85d4d707a2f2c34f1dc687248b9e034271cae4a4f402e0a78ce227cecfbbf9e467de07189771f
7
+ data.tar.gz: 2f27d2fe72ad6abe199a49b8872c6ed1e581257d62a62576452331e215f46f48ec17a88c13d75491573c27a71d151d3c1b0bb2f9258d3e1cd458213ed3f5b1b4
@@ -43,7 +43,12 @@ module ZuoraConnect
43
43
 
44
44
  def cache_bust
45
45
  if defined?(Redis.current)
46
+ @appinstance.fetch_connect_data #Fetch data and set in database if kms key is used
47
+ @appinstance.cache_app_instance(force_cache: true) #Update cache in redis
46
48
  Redis.current.del("AppInstance:#{@appinstance.id}")
49
+ @appinstance.cache_app_instance(force_cache: true) #Update cache in redis
50
+ #TODO: Could be a chance another thread cache back to old value, but will eventually cache will get consitent, move to nolonger needing redis cache
51
+
47
52
  respond_to do |format|
48
53
  format.json {render json: {}, status: :ok}
49
54
  end
@@ -351,28 +351,33 @@ module ZuoraConnect
351
351
  self.id >= 25000000
352
352
  end
353
353
 
354
+ def fetch_connect_data
355
+ self.check_oauth_state
356
+ response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
357
+
358
+ if response.code == 200
359
+ begin
360
+ parsed_json = JSON.parse(response.body)
361
+ rescue JSON::ParserError => ex
362
+ raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("JSON parse error", response.body, response.code)
363
+ end
364
+
365
+ self.build_task(task_data: parsed_json, session: session)
366
+ self.set_backup_creds
367
+ self.save(validate: false) if self.changed?
368
+ else
369
+ raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Communicating with Connect", response.body, response.code)
370
+ end
371
+ end
372
+
373
+
354
374
  def refresh(session: {})
355
375
  refresh_count ||= 0
356
376
  skip_connect ||= ZuoraConnect.configuration.skip_connect
357
377
  begin
358
378
  #Check how app was deployed
359
- if !self.auto_deployed? && !skip_connect
360
- self.check_oauth_state
361
- response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
362
-
363
- if response.code == 200
364
- begin
365
- parsed_json = JSON.parse(response.body)
366
- rescue JSON::ParserError => ex
367
- raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("JSON parse error", response.body, response.code)
368
- end
369
-
370
- self.build_task(task_data: parsed_json, session: session)
371
- self.set_backup_creds
372
- self.save(validate: false) if self.changed?
373
- else
374
- raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Communicating with Connect", response.body, response.code)
375
- end
379
+ if !self.auto_deployed? && (!skip_connect || self['zuora_logins'].blank?)
380
+ self.fetch_connect_data
376
381
  else
377
382
  self.build_task(task_data: self.zuora_logins, session: session)
378
383
  end
@@ -775,10 +780,10 @@ module ZuoraConnect
775
780
  Redis.current.del("AppInstance:#{self.id}")
776
781
  end
777
782
 
778
- def cache_app_instance
783
+ def cache_app_instance(force_cache: false)
779
784
  if defined?(Redis.current)
780
785
  #Task data must be present and the last refresh cannot be old. We dont want to overwite new cache data with old
781
- if self.task_data.present? && (self.last_refresh.to_i > INSTANCE_REFRESH_WINDOW.ago.to_i)
786
+ if self.task_data.present? && ((self.last_refresh.to_i > INSTANCE_REFRESH_WINDOW.ago.to_i ) || force_cache)
782
787
  ZuoraConnect.logger.debug("Caching AppInstance", self.default_ougai_items)
783
788
  Redis.current.setex("AppInstance:#{self.id}", INSTANCE_REDIS_CACHE_PERIOD.to_i, self.encrypt_data(data: self.save_data))
784
789
  end
@@ -11,7 +11,7 @@ module ActiveRecord
11
11
  additional_types = []
12
12
  load_types_queries(initializer, oids) do |query|
13
13
  execute_and_clear(query, "SCHEMA", []) do |records|
14
- additional_types.push(records)
14
+ additional_types.push(records.to_a)
15
15
  initializer.run(records)
16
16
  end
17
17
  end
@@ -98,7 +98,19 @@ module ActiveRecord
98
98
  begin
99
99
  if Redis.current.exists(SCHEMA_ADDITIONAL_TYPES)
100
100
  additional_types = JSON.parse(Redis.current.get(SCHEMA_ADDITIONAL_TYPES))
101
- if additional_types.is_a?(Array)
101
+
102
+ rails_version = Rails.version.split('.').map { |x| x.to_i }
103
+ if (rails_version <=> [7, 0, 0]) >= 1
104
+ if additional_types.is_a?(Array) && !additional_types.first.is_a?(Array)
105
+ raise 'incompatible cache version'
106
+ end
107
+ elsif (rails_version <=> [5, 2, 0]) >= 1
108
+ if additional_types.is_a?(Array) && additional_types.first.is_a?(Array)
109
+ raise 'incompatible cache version'
110
+ end
111
+ end
112
+
113
+ if additional_types.is_a?(Array) && additional_types.first.is_a?(Array)
102
114
  additional_types.each { |additional_type| initializer.run(additional_type) }
103
115
  else
104
116
  initializer.run(additional_types)
@@ -106,6 +118,7 @@ module ActiveRecord
106
118
  return true
107
119
  end
108
120
  rescue => ex
121
+ Redis.current.del(SCHEMA_ADDITIONAL_TYPES)
109
122
  Rails.logger.warn('Exception occurred while loading additional types', ex)
110
123
  end
111
124
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZuoraConnect
4
- VERSION = "3.1.0-a"
4
+ VERSION = "3.1.0-d"
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.1.0.pre.a
4
+ version: 3.1.0.pre.d
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment