zuora_connect 1.5.30 → 1.5.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/zuora_connect/app_instance_base.rb +579 -482
- data/config/initializers/object_method_hooks.rb +27 -0
- data/config/initializers/redis.rb +2 -2
- data/db/migrate/20180301052853_add_catalog_attempted_at.rb +5 -0
- data/lib/zuora_connect/configuration.rb +0 -1
- data/lib/zuora_connect/controllers/helpers.rb +10 -6
- data/lib/zuora_connect/exceptions.rb +2 -0
- data/lib/zuora_connect/version.rb +1 -2
- metadata +48 -32
@@ -0,0 +1,27 @@
|
|
1
|
+
class Object
|
2
|
+
def self.method_hook(*args)
|
3
|
+
options = args.extract_options!
|
4
|
+
return unless (options[:before].present? or options[:after].present?)
|
5
|
+
args.each do |method_name|
|
6
|
+
old_method = instance_method(method_name) rescue next
|
7
|
+
|
8
|
+
define_method(method_name) do |*args|
|
9
|
+
# invoke before callback
|
10
|
+
if options[:before].present?
|
11
|
+
options[:before].is_a?(Proc) ? options[:before].call(method_name, self):
|
12
|
+
send(options[:before], method_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
# you can modify the code to call after callback
|
16
|
+
# only when the old method returns true etc..
|
17
|
+
old_method.bind(self).call(*args)
|
18
|
+
|
19
|
+
# invoke after callback
|
20
|
+
if options[:after].present?
|
21
|
+
options[:after].is_a?(Proc) ? options[:after].call(method_name, self):
|
22
|
+
send(options[:after], method_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
redis_url = ENV["REDIS_URL"].present? ? ENV["REDIS_URL"] : 'redis://localhost:6379/1'
|
1
|
+
redis_url = ENV["REDIS_URL"].present? ? ENV["REDIS_URL"] : defined?(Rails.application.secrets.redis) ? Rails.application.secrets.redis : 'redis://localhost:6379/1'
|
2
2
|
if defined?(Redis.current)
|
3
|
-
Redis.current = Redis.new(:url => redis_url, :timeout => 10)
|
3
|
+
Redis.current = Redis.new(:url => redis_url, :timeout => 10, :reconnect_attempts => 2)
|
4
4
|
if defined?(Resque.redis)
|
5
5
|
Resque.redis = Redis.current
|
6
6
|
end
|
@@ -3,7 +3,6 @@ module ZuoraConnect
|
|
3
3
|
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri,:use_s3, :default_locale,:dev_mode_appinstance ,:dev_mode_admin, :dev_mode_user, :dev_mode_pass, :default_time_zone,:delayed_job,:url, :private_key, :dev_mode_logins,:dev_mode_mode, :dev_mode_options, :mode, :timeout,:dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :additional_apartment_models
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@timeout = 30.minutes
|
7
6
|
@default_locale = :en
|
8
7
|
@default_time_zone = Time.zone
|
9
8
|
@url = "https://connect.zuora.com"
|
@@ -8,7 +8,7 @@ module ZuoraConnect
|
|
8
8
|
#Skip session for api requests
|
9
9
|
request.session_options[:skip] = true
|
10
10
|
start_time = Time.now
|
11
|
-
if
|
11
|
+
if request.headers["API-Token"].present?
|
12
12
|
@appinstance = ZuoraConnect::AppInstance.where(:api_token => request.headers["API-Token"]).first
|
13
13
|
Rails.logger.debug("[#{@appinstance.id}] API REQUEST - API token") if @appinstance.present?
|
14
14
|
check_instance
|
@@ -38,7 +38,9 @@ module ZuoraConnect
|
|
38
38
|
#Call .data_lookup with the current session to retrieve session. In some cases session may be stored/cache in redis
|
39
39
|
#so data lookup provides a model method that can be overriden per app.
|
40
40
|
if params[:controller] != 'zuora_connect/api/v1/app_instance' && params[:action] != 'drop'
|
41
|
-
|
41
|
+
if @appinstance.new_session_for_ui_requests(:params => params)
|
42
|
+
@appinstance.new_session(:session => @appinstance.data_lookup(:session => session))
|
43
|
+
end
|
42
44
|
end
|
43
45
|
PaperTrail.whodunnit = session["#{@appinstance.id}::user::email"] if defined?(PaperTrail) && session["#{@appinstance.id}::user::email"].present?
|
44
46
|
begin
|
@@ -52,7 +54,7 @@ module ZuoraConnect
|
|
52
54
|
|
53
55
|
def persist_connect_app_session
|
54
56
|
if @appinstance.present?
|
55
|
-
if defined?(Redis.current)
|
57
|
+
if defined?(Redis.current)
|
56
58
|
@appinstance.cache_app_instance
|
57
59
|
else
|
58
60
|
session.merge!(@appinstance.save_data)
|
@@ -138,8 +140,8 @@ module ZuoraConnect
|
|
138
140
|
@appinstance = ZuoraConnect::AppInstance.new(:id => values[:appinstance].to_i, :access_token => values[:user], :refresh_token => values[:key], :token => "#{values[:key]}#{values[:key]}", :api_token => "#{values[:key]}#{values[:key]}")
|
139
141
|
@appinstance.save(:validate => false)
|
140
142
|
end
|
141
|
-
if @appinstance.access_token.blank? || @appinstance.refresh_token.blank?
|
142
|
-
@appinstance.update_attributes(:access_token => values["user"], :refresh_token => values["key"], :token => "#{values[:key]}#{values[:key]}", :api_token => "#{values[:key]}#{values[:key]}")
|
143
|
+
if @appinstance.access_token.blank? || @appinstance.refresh_token.blank? || @appinstance.token.blank? || @appinstance.api_token.blank?
|
144
|
+
@appinstance.update_attributes!(:access_token => values["user"], :refresh_token => values["key"], :token => "#{values[:key]}#{values[:key]}", :api_token => "#{values[:key]}#{values[:key]}")
|
143
145
|
end
|
144
146
|
session["#{@appinstance.id}::admin"] = ZuoraConnect.configuration.dev_mode_admin
|
145
147
|
end
|
@@ -147,7 +149,9 @@ module ZuoraConnect
|
|
147
149
|
#API ONLY
|
148
150
|
def check_instance
|
149
151
|
if @appinstance.present?
|
150
|
-
|
152
|
+
if @appinstance.new_session_for_api_requests(:params => params)
|
153
|
+
@appinstance.new_session(:session => @appinstance.data_lookup(:session => session))
|
154
|
+
end
|
151
155
|
Thread.current[:appinstance] = @appinstance
|
152
156
|
PaperTrail.whodunnit = "API User" if defined?(PaperTrail)
|
153
157
|
return true
|
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: 1.5.
|
4
|
+
version: 1.5.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: derailed
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: pg
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,6 +225,7 @@ files:
|
|
211
225
|
- app/views/zuora_connect/static/invalid_app_instance_error.html.erb
|
212
226
|
- app/views/zuora_connect/static/session_error.html.erb
|
213
227
|
- config/initializers/apartment.rb
|
228
|
+
- config/initializers/object_method_hooks.rb
|
214
229
|
- config/initializers/redis.rb
|
215
230
|
- config/initializers/resque.rb
|
216
231
|
- config/initializers/to_bool.rb
|
@@ -224,6 +239,7 @@ files:
|
|
224
239
|
- db/migrate/20110503003602_add_catalog_data_to_app_instance.rb
|
225
240
|
- db/migrate/20110503003603_add_catalog_mappings_to_app_instance.rb
|
226
241
|
- db/migrate/20110503003604_catalog_default.rb
|
242
|
+
- db/migrate/20180301052853_add_catalog_attempted_at.rb
|
227
243
|
- lib/resque/additions.rb
|
228
244
|
- lib/resque/dynamic_queues.rb
|
229
245
|
- lib/resque/self_lookup.rb
|
@@ -301,44 +317,44 @@ signing_key:
|
|
301
317
|
specification_version: 4
|
302
318
|
summary: Summary of Connect.
|
303
319
|
test_files:
|
304
|
-
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|
305
320
|
- test/models/zuora_connect/app_instance_test.rb
|
306
321
|
- test/test_helper.rb
|
307
|
-
- test/fixtures/zuora_connect/app_instances.yml
|
308
322
|
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
309
|
-
- test/
|
310
|
-
- test/zuora_connect_test.rb
|
311
|
-
- test/dummy/Rakefile
|
312
|
-
- test/dummy/bin/rails
|
313
|
-
- test/dummy/bin/bundle
|
314
|
-
- test/dummy/bin/setup
|
315
|
-
- test/dummy/bin/rake
|
316
|
-
- test/dummy/README.rdoc
|
317
|
-
- test/dummy/config/locales/en.yml
|
318
|
-
- test/dummy/config/environment.rb
|
319
|
-
- test/dummy/config/secrets.yml
|
320
|
-
- test/dummy/config/database.yml
|
321
|
-
- test/dummy/config/application.rb
|
322
|
-
- test/dummy/config/boot.rb
|
323
|
-
- test/dummy/config/environments/production.rb
|
324
|
-
- test/dummy/config/environments/development.rb
|
325
|
-
- test/dummy/config/environments/test.rb
|
326
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
327
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
328
|
-
- test/dummy/config/initializers/session_store.rb
|
329
|
-
- test/dummy/config/initializers/mime_types.rb
|
330
|
-
- test/dummy/config/initializers/inflections.rb
|
331
|
-
- test/dummy/config/initializers/assets.rb
|
332
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
333
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
334
|
-
- test/dummy/config/routes.rb
|
323
|
+
- test/dummy/public/404.html
|
335
324
|
- test/dummy/public/422.html
|
336
325
|
- test/dummy/public/500.html
|
337
326
|
- test/dummy/public/favicon.ico
|
338
|
-
- test/dummy/
|
327
|
+
- test/dummy/Rakefile
|
328
|
+
- test/dummy/README.rdoc
|
329
|
+
- test/dummy/app/controllers/application_controller.rb
|
339
330
|
- test/dummy/app/helpers/application_helper.rb
|
340
331
|
- test/dummy/app/views/layouts/application.html.erb
|
341
|
-
- test/dummy/app/controllers/application_controller.rb
|
342
332
|
- test/dummy/app/assets/stylesheets/application.css
|
343
333
|
- test/dummy/app/assets/javascripts/application.js
|
334
|
+
- test/dummy/config/routes.rb
|
335
|
+
- test/dummy/config/boot.rb
|
336
|
+
- test/dummy/config/initializers/assets.rb
|
337
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
338
|
+
- test/dummy/config/initializers/session_store.rb
|
339
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
340
|
+
- test/dummy/config/initializers/inflections.rb
|
341
|
+
- test/dummy/config/initializers/mime_types.rb
|
342
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
343
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
344
|
+
- test/dummy/config/environment.rb
|
345
|
+
- test/dummy/config/application.rb
|
346
|
+
- test/dummy/config/database.yml
|
347
|
+
- test/dummy/config/secrets.yml
|
348
|
+
- test/dummy/config/environments/production.rb
|
349
|
+
- test/dummy/config/environments/test.rb
|
350
|
+
- test/dummy/config/environments/development.rb
|
351
|
+
- test/dummy/config/locales/en.yml
|
352
|
+
- test/dummy/bin/rails
|
353
|
+
- test/dummy/bin/rake
|
354
|
+
- test/dummy/bin/setup
|
355
|
+
- test/dummy/bin/bundle
|
344
356
|
- test/dummy/config.ru
|
357
|
+
- test/integration/navigation_test.rb
|
358
|
+
- test/zuora_connect_test.rb
|
359
|
+
- test/fixtures/zuora_connect/app_instances.yml
|
360
|
+
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|