Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More apis #28

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

25 changes: 13 additions & 12 deletions lib/mindbody-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 7 additions & 4 deletions lib/mindbody-api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)}}
Expand Down
3 changes: 3 additions & 0 deletions lib/mindbody-api/services/class_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 2 additions & 0 deletions spec/mindbody_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/services/class_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions wsdl/AppointmentService.wsdl
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
<s:element minOccurs="0" maxOccurs="1" name="AcceptsAmericanExpress" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="ContactEmail" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ESA" nillable="true" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="TotalWOD" nillable="true" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="TaxInclusivePrices" nillable="true" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:complexType name="Resource">
Expand Down Expand Up @@ -221,6 +223,7 @@
<s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ScheduleType" nillable="true" type="tns:ScheduleType" />
<s:element minOccurs="1" maxOccurs="1" name="CancelOffset" nillable="true" type="s:int" />
</s:sequence>
</s:extension>
</s:complexContent>
Expand Down Expand Up @@ -264,7 +267,9 @@
<s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PostalCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ForeignZip" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SortOrder" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="LoginLocations" type="tns:ArrayOfLocation" />
<s:element minOccurs="0" maxOccurs="1" name="MultiLocation" nillable="true" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="Action" type="tns:ActionCode" />
<s:element minOccurs="0" maxOccurs="1" name="ID" nillable="true" type="s:long" />
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
Expand Down Expand Up @@ -321,6 +326,7 @@
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DefaultTimeLength" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="ProgramID" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="NumDeducted" nillable="true" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Action" type="tns:ActionCode" />
<s:element minOccurs="0" maxOccurs="1" name="ID" nillable="true" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
Expand Down Expand Up @@ -411,6 +417,7 @@
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactInfoRelationship" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactInfoPhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactInfoEmail" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PromotionalEmailOptIn" nillable="true" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="Action" type="tns:ActionCode" />
<s:element minOccurs="0" maxOccurs="1" name="ID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string" />
Expand Down Expand Up @@ -548,6 +555,7 @@
<s:element minOccurs="1" maxOccurs="1" name="SendEmail" nillable="true" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="ApplyPayment" nillable="true" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="Appointments" type="tns:ArrayOfAppointment" />
<s:element minOccurs="1" maxOccurs="1" name="IgnoreDefaultSessionLength" nillable="true" type="s:boolean" />
</s:sequence>
</s:extension>
</s:complexContent>
Expand Down Expand Up @@ -584,6 +592,8 @@
<s:element minOccurs="0" maxOccurs="1" name="StaffIDs" type="tns:ArrayOfLong" />
<s:element minOccurs="1" maxOccurs="1" name="StartDate" nillable="true" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="EndDate" nillable="true" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="AppointmentID" nillable="true" type="s:long" />
<s:element minOccurs="1" maxOccurs="1" name="IgnoreDefaultSessionLength" nillable="true" type="s:boolean" />
</s:sequence>
</s:extension>
</s:complexContent>
Expand Down Expand Up @@ -673,6 +683,7 @@
<s:element minOccurs="0" maxOccurs="1" name="UnavailableDescription" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="IsUnavailable" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="PublicDisplay" nillable="true" type="tns:AvailabilityDisplay" />
<s:element minOccurs="0" maxOccurs="1" name="Execute" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
Expand Down
Loading