diff --git a/README.md b/README.md index b8fe77e..feb3294 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,16 @@ Alternatively, you may set them in an initializer: config.site_ids = -99 config.source_key = 'abcd1234' config.source_name = 'SuperFoo' - config.log_level = :info # Savon logging level. Default is :debug, options are [:debug, :info, :warn, :error, :fatal] + config.log_level = :info # Savon logging level. Default is :debug, options are [:debug, :info, :warn, :error, :fatal] + config.filters = ['Password'] + # Enable as you see fit + # See http://savonrb.com/version2/globals.html for more information settings. + #config.read_timeout = 0 + #config.open_timeout = 0 + #config.pretty_print_xml = true + #config.log = true end -See http://savonrb.com/version2/globals.html for more information on the logging -setting. ## Usage @@ -75,5 +80,5 @@ See the various [issues](https://github.com/wingrunr21/mindbody-api/issues?state This gem is written by [Stafford Brunk](https://github.com/wingrunr21) -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/wingrunr21/mindbody-api/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/wingrunr21/mindbody-api/trend.png)](https://bitdeli.com/free "Bitdeli Badge") [![Build Status](https://travis-ci.org/wingrunr21/mindbody-api.png)](https://travis-ci.org/wingrunr21/mindbody-api) diff --git a/lib/mindbody-api.rb b/lib/mindbody-api.rb index ef100cb..f7ef3a5 100644 --- a/lib/mindbody-api.rb +++ b/lib/mindbody-api.rb @@ -17,19 +17,20 @@ def configuration end end - class Config - attr_accessor :log_level, :open_timeout, :read_timeout, :source_name, :source_key, :site_ids + class Config < OpenStruct - def initialize - @log_level = :debug - @source_name = ENV['MINDBODY_SOURCE_NAME'] || '' - @source_key = ENV['MINDBODY_SOURCE_KEY'] || '' - @site_ids = (ENV['MINDBODY_SITE_IDS'] || '').scan(/-?\d+/).map(&:to_i) - end - - # Make sure site_ids is always an Array - def site_ids=(ids) - @site_ids = [*ids] + def initialize() + defaults = + { + log_level: :debug, + source_name: ENV['MINDBODY_SOURCE_NAME'] || '', + source_key: ENV['MINDBODY_SOURCE_KEY'] || '', + site_ids: (ENV['MINDBODY_SITE_IDS'] || '').scan(/-?\d+/).map(&:to_i), + filters: ['Password'] + } + super(defaults) + # Override site_id to make sure its always an array + define_singleton_method("site_ids=") { |x| modifiable[:site_ids] = [*x] } end end end diff --git a/lib/mindbody-api/client.rb b/lib/mindbody-api/client.rb index 6d17444..85cf657 100644 --- a/lib/mindbody-api/client.rb +++ b/lib/mindbody-api/client.rb @@ -6,10 +6,13 @@ class Client < Savon::Client def call(operation_name, locals = {}, &block) # Inject the auth params into the request and setup the - # correct request structure - @globals.open_timeout(MindBody.configuration.open_timeout) - @globals.read_timeout(MindBody.configuration.read_timeout) - @globals.log_level(MindBody.configuration.log_level) + #Allow you to override Savon global properties + MindBody.configuration.to_h.each do |key, value| + if @globals.respond_to?(key) + @globals.send(key, value) + end + end + locals = locals.has_key?(:message) ? locals[:message] : locals locals = fixup_locals(locals) params = {:message => {'Request' => auth_params.merge(locals)}} diff --git a/lib/mindbody-api/services/class_service.rb b/lib/mindbody-api/services/class_service.rb index 63ffbaf..2abacb4 100644 --- a/lib/mindbody-api/services/class_service.rb +++ b/lib/mindbody-api/services/class_service.rb @@ -7,6 +7,8 @@ class ClassService < Service operation :get_class_visits, required:[:class_id] operation :get_class_descriptions operation :get_class_schedules + operation :add_clients_to_enrollments + operation :add_clients_to_classes end end end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index e6e22de..f6e8c00 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -3,10 +3,11 @@ describe MindBody::Services::Client do before do creds = double('credentials') - creds.stub(:log_level).and_return(:debug) creds.stub(:source_name).and_return('test') creds.stub(:source_key).and_return('test_key') creds.stub(:site_ids).and_return([-99]) + #Savon options + creds.stub(:to_h).and_return({open_timeout: 0, read_timeout: 0}) MindBody.stub(:configuration).and_return(creds) @client = MindBody::Services::Client.new(:wsdl => 'spec/fixtures/wsdl/geotrust.wsdl') diff --git a/spec/mindbody_spec.rb b/spec/mindbody_spec.rb index 57c2770..7b24387 100644 --- a/spec/mindbody_spec.rb +++ b/spec/mindbody_spec.rb @@ -30,6 +30,8 @@ it { should respond_to(:source_name) } it { should respond_to(:source_key) } it { should respond_to(:site_ids) } + # Savon global options + it { should respond_to(:filters) } end describe '#new' do diff --git a/spec/services/class_service_spec.rb b/spec/services/class_service_spec.rb index 08a94e8..f47db16 100644 --- a/spec/services/class_service_spec.rb +++ b/spec/services/class_service_spec.rb @@ -7,4 +7,6 @@ it { should respond_to(:get_class_visits) } it { should respond_to(:get_class_descriptions) } it { should respond_to(:get_class_schedules) } + it { should respond_to(:add_clients_to_enrollments) } + it { should respond_to(:add_clients_to_classes)} end