diff --git a/README.md b/README.md index b8fe77e..4ab4362 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..eae54b7 100644 --- a/lib/mindbody-api/services/class_service.rb +++ b/lib/mindbody-api/services/class_service.rb @@ -7,6 +7,9 @@ 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 + operation :remove_clients_from_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..4fd13d6 100644 --- a/spec/services/class_service_spec.rb +++ b/spec/services/class_service_spec.rb @@ -7,4 +7,7 @@ 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)} + it { should respond_to(:remove_clients_from_classes)} end diff --git a/wsdl/AppointmentService.wsdl b/wsdl/AppointmentService.wsdl index 09c7973..d82eb88 100644 --- a/wsdl/AppointmentService.wsdl +++ b/wsdl/AppointmentService.wsdl @@ -174,6 +174,8 @@ + + @@ -221,6 +223,7 @@ + @@ -264,7 +267,9 @@ + + @@ -321,6 +326,7 @@ + @@ -411,6 +417,7 @@ + @@ -548,6 +555,7 @@ + @@ -584,6 +592,8 @@ + + @@ -673,6 +683,7 @@ + diff --git a/wsdl/ClassService.wsdl b/wsdl/ClassService.wsdl index 1bc0247..3c724e8 100644 --- a/wsdl/ClassService.wsdl +++ b/wsdl/ClassService.wsdl @@ -174,6 +174,8 @@ + + @@ -219,6 +221,7 @@ + @@ -240,6 +243,7 @@ + @@ -304,7 +308,9 @@ + + @@ -352,18 +358,6 @@ - - - - - - - - - - - - @@ -423,6 +417,18 @@ + + + + + + + + + + + + @@ -457,6 +463,7 @@ + @@ -800,6 +807,8 @@ + + @@ -879,6 +888,7 @@ + @@ -954,6 +964,7 @@ + @@ -1115,6 +1126,7 @@ + @@ -1144,13 +1156,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1231,6 +1317,18 @@ + + + + + + + + + + + + Gets a list of classes. @@ -1297,6 +1395,16 @@ + + Substitutes the teacher for a class. + + + + + Cancels a single class instance. + + + @@ -1417,6 +1525,24 @@ + + + + + + + + + + + + + + + + + + Provides methods and attributes relating to classes and enrollments. diff --git a/wsdl/ClientService.wsdl b/wsdl/ClientService.wsdl index 3a6dc9e..9323249 100644 --- a/wsdl/ClientService.wsdl +++ b/wsdl/ClientService.wsdl @@ -141,6 +141,8 @@ + + @@ -150,6 +152,7 @@ + @@ -188,6 +191,7 @@ + @@ -221,6 +225,7 @@ + @@ -353,7 +358,9 @@ + + @@ -401,18 +408,6 @@ - - - - - - - - - - - - @@ -435,6 +430,7 @@ + @@ -485,6 +481,18 @@ + + + + + + + + + + + + @@ -1255,6 +1263,7 @@ + diff --git a/wsdl/FinderService.wsdl b/wsdl/FinderService.wsdl index f423a35..f916cda 100644 --- a/wsdl/FinderService.wsdl +++ b/wsdl/FinderService.wsdl @@ -156,6 +156,8 @@ + + @@ -257,6 +259,7 @@ + @@ -300,7 +303,9 @@ + + @@ -348,18 +353,6 @@ - - - - - - - - - - - - @@ -382,6 +375,7 @@ + @@ -394,6 +388,18 @@ + + + + + + + + + + + + @@ -428,6 +434,7 @@ + @@ -702,31 +709,31 @@ - + + - + - + - + - @@ -741,72 +748,72 @@ - + + + - + - - - - - - - - - - - - + + - + - - + - + - - + + + + + + + + + + + + - + - + - + - @@ -884,47 +891,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -967,6 +933,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wsdl/SaleService.wsdl b/wsdl/SaleService.wsdl index 7243217..aea9ab1 100644 --- a/wsdl/SaleService.wsdl +++ b/wsdl/SaleService.wsdl @@ -167,6 +167,8 @@ + + @@ -188,6 +190,8 @@ + + @@ -282,7 +286,9 @@ + + @@ -330,18 +336,6 @@ - - - - - - - - - - - - @@ -364,6 +358,7 @@ + @@ -392,6 +387,7 @@ + @@ -445,6 +441,18 @@ + + + + + + + + + + + + @@ -479,6 +487,7 @@ + @@ -754,25 +763,26 @@ - + - + + + + + + - - - - + + + + + - - - - - @@ -790,31 +800,30 @@ - - - - - - + - - - - - - + - - - - - + + + + + + + + + + + + + + @@ -830,31 +839,31 @@ - + + - + - + - + - @@ -869,72 +878,72 @@ - + + + - + - - - - - - - - - - - - + + - + - - + - + - - + + + + + + + + + + + + - + - + - + - diff --git a/wsdl/SiteService.wsdl b/wsdl/SiteService.wsdl index ec0cae5..291b757 100644 --- a/wsdl/SiteService.wsdl +++ b/wsdl/SiteService.wsdl @@ -17,6 +17,7 @@ + @@ -120,6 +121,8 @@ + + @@ -295,6 +298,7 @@ + @@ -343,6 +347,7 @@ + diff --git a/wsdl/StaffService.wsdl b/wsdl/StaffService.wsdl index 9ee9f7b..de54e10 100644 --- a/wsdl/StaffService.wsdl +++ b/wsdl/StaffService.wsdl @@ -151,7 +151,9 @@ + + @@ -188,6 +190,8 @@ + + @@ -235,6 +239,7 @@ + @@ -295,6 +300,7 @@ + @@ -445,6 +451,7 @@ + @@ -497,18 +504,6 @@ - - - - - - - - - - - - @@ -530,6 +525,18 @@ + + + + + + + + + + + +