mindbody 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +48 -0
- data/.rvmrc +2 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/lib/mindbody.rb +10 -0
- data/lib/mindbody/appointment_service.rb +3 -0
- data/lib/mindbody/class_service.rb +3 -0
- data/lib/mindbody/client_service.rb +3 -0
- data/lib/mindbody/credentials.rb +36 -0
- data/lib/mindbody/mb_meta.rb +10 -0
- data/lib/mindbody/mb_service.rb +56 -0
- data/lib/mindbody/sale_service.rb +3 -0
- data/lib/mindbody/site_service.rb +3 -0
- data/lib/mindbody/source_credentials.rb +3 -0
- data/lib/mindbody/staff_service.rb +3 -0
- data/lib/mindbody/version.rb +3 -0
- data/mindbody.gemspec +22 -0
- data/test/helper.rb +18 -0
- data/test/test_mindbody.rb +7 -0
- metadata +79 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source :rubygems
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "savon", "~> 0.9.2"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "shoulda", ">= 0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.6.0"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Tristan Goffman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= mindbody
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to mindbody
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Tristan Goffman. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "mindbody"
|
18
|
+
gem.homepage = "http://github.com/trisrael/mindbody"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{TODO: one-line summary of your gem}
|
21
|
+
gem.description = %Q{TODO: longer description of your gem}
|
22
|
+
gem.email = "tgoffman@gmail.com"
|
23
|
+
gem.authors = ["Tristan Goffman"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "mindbody #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/lib/mindbody.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'mindbody/mb_meta'
|
2
|
+
require 'mindbody/credentials'
|
3
|
+
require 'mindbody/source_credentials'
|
4
|
+
require 'mindbody/mb_service'
|
5
|
+
require 'mindbody/class_service'
|
6
|
+
require 'mindbody/site_service'
|
7
|
+
require 'mindbody/appointment_service'
|
8
|
+
require 'mindbody/sale_service'
|
9
|
+
require 'mindbody/client_service'
|
10
|
+
require 'mindbody/staff_service'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Credentials
|
2
|
+
attr_accessor :name, :password, :ids
|
3
|
+
|
4
|
+
#A map describing how the local private instance variables should show for public services
|
5
|
+
def self.public_var_names (soap_names_map)
|
6
|
+
@@map = soap_names_map
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(name, password, ids)
|
10
|
+
@name = name
|
11
|
+
@password = password
|
12
|
+
|
13
|
+
begin
|
14
|
+
ids.count #Is this an array?
|
15
|
+
rescue
|
16
|
+
ids = [ids]
|
17
|
+
end
|
18
|
+
|
19
|
+
@ids = ids
|
20
|
+
end
|
21
|
+
|
22
|
+
#Return a hash ready for inclusion in a savon SOAP request,
|
23
|
+
#allow instance variables to renamed dependent on a map set up in the class
|
24
|
+
def to_hash
|
25
|
+
mapper = @@map || {}
|
26
|
+
|
27
|
+
{
|
28
|
+
mapper[:name] || "Name" => @name,
|
29
|
+
|
30
|
+
mapper[:password] || "Password" => @password,
|
31
|
+
|
32
|
+
mapper[:ids] || "Ids" => { "int" => @ids}
|
33
|
+
}
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module MBMeta
|
2
|
+
NS = :_5 #Name for soap elements
|
3
|
+
WSDL_PREFIX = "http://clients.mindbodyonline.com/api/0_5/"
|
4
|
+
WSDL_POSTFIX = ".asmx?WSDL"
|
5
|
+
|
6
|
+
#Returns the Mindody API url for the XML WSDL describing the server of @param service_name
|
7
|
+
def wsdl_url(service_name)
|
8
|
+
WSDL_PREFIX + service_name + WSDL_POSTFIX
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'savon'
|
2
|
+
class MBService
|
3
|
+
extend MBMeta
|
4
|
+
#Sets up the service WSDL endpoint given a Mindbody service name
|
5
|
+
def self.service(service_name)
|
6
|
+
@@endpoint = self.wsdl_url(service_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :client, :src_creds, :usr_creds
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@client = nil
|
13
|
+
@src_creds = options[:source_credentials]
|
14
|
+
@usr_creds = options[:user_credentials]
|
15
|
+
|
16
|
+
@client = Savon::Client.new @@endpoint if @@endpoint
|
17
|
+
end
|
18
|
+
|
19
|
+
#Builds the inner XML of the Mindbody SOAP call
|
20
|
+
def build_request(options = {})
|
21
|
+
|
22
|
+
request_body =
|
23
|
+
{
|
24
|
+
"PageSize" => 10,
|
25
|
+
"XMLDetail" => "Bare",
|
26
|
+
"CurrentPageIndex" => 0
|
27
|
+
}
|
28
|
+
|
29
|
+
request_body["SourceCredentials"] = @src_creds.to_hash if @src_creds
|
30
|
+
request_body["UserCredentials"] = @usr_creds.to_hash if @usr_creds
|
31
|
+
|
32
|
+
return request_body.deep_merge!(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
#Build a Mindbody SOAP request for the given service
|
36
|
+
def get_service(service_symbol, options)
|
37
|
+
raise "No SOAP client instantiated" unless @client
|
38
|
+
|
39
|
+
raise "No SourceCredentials supplied" if !@src_creds && !options[:source_credentials]
|
40
|
+
|
41
|
+
response = @client.request MBMeta::NS, service_symbol do
|
42
|
+
soap.body =
|
43
|
+
{
|
44
|
+
"Request" => build_request(options)
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#Allows services to be called directly on the service and rerouted to
|
50
|
+
#the client
|
51
|
+
def method_missing(m_name, *args, &block)
|
52
|
+
options = args[0]
|
53
|
+
get_service m_name.to_sym, options.is_a?(Hash) ? options : {}
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/mindbody.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$:.unshift lib unless $:.include? lib
|
3
|
+
|
4
|
+
require "mindbody/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mindbody"
|
8
|
+
s.version = Mindbody::Version
|
9
|
+
s.authors = "Tristan Goffman"
|
10
|
+
s.email = "tgoffman@gmail.com"
|
11
|
+
s.homepage = "http://github.com/trisrael/mindbody"
|
12
|
+
s.summary = "Ruby interface to Mindbody 0.5 API"
|
13
|
+
s.description = "Ruby's interface to the Mindbody 0.5 API with no bell's and whistles"
|
14
|
+
|
15
|
+
s.rubyforge_project = s.name
|
16
|
+
|
17
|
+
s.add_dependency "savon", "~> 0.9.2"
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.require_path = "lib"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'mindbody'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mindbody
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tristan Goffman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-05-08 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: savon
|
17
|
+
requirement: &72063370 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *72063370
|
26
|
+
description: Ruby's interface to the Mindbody 0.5 API with no bell's and whistles
|
27
|
+
email: tgoffman@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .document
|
33
|
+
- .gitignore
|
34
|
+
- .rvmrc
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE.txt
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- lib/mindbody.rb
|
40
|
+
- lib/mindbody/appointment_service.rb
|
41
|
+
- lib/mindbody/class_service.rb
|
42
|
+
- lib/mindbody/client_service.rb
|
43
|
+
- lib/mindbody/credentials.rb
|
44
|
+
- lib/mindbody/mb_meta.rb
|
45
|
+
- lib/mindbody/mb_service.rb
|
46
|
+
- lib/mindbody/sale_service.rb
|
47
|
+
- lib/mindbody/site_service.rb
|
48
|
+
- lib/mindbody/source_credentials.rb
|
49
|
+
- lib/mindbody/staff_service.rb
|
50
|
+
- lib/mindbody/version.rb
|
51
|
+
- mindbody.gemspec
|
52
|
+
- test/helper.rb
|
53
|
+
- test/test_mindbody.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/trisrael/mindbody
|
56
|
+
licenses: []
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project: mindbody
|
75
|
+
rubygems_version: 1.6.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Ruby interface to Mindbody 0.5 API
|
79
|
+
test_files: []
|