tex_mindbody-api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/tex_mindbody/api.rb +76 -0
- data/lib/tex_mindbody/api/configuration.rb +10 -0
- data/lib/tex_mindbody/api/endpoint.rb +2 -0
- data/lib/tex_mindbody/api/endpoint/client.rb +13 -0
- data/lib/tex_mindbody/api/endpoint/usertoken.rb +23 -0
- data/lib/tex_mindbody/api/model.rb +10 -0
- data/lib/tex_mindbody/api/model/client.rb +8 -0
- data/lib/tex_mindbody/api/version.rb +5 -0
- data/tex_mindbody-api.gemspec +41 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 404dad7c3891f0251c9c76e9425d2c2e563e2ca5
|
4
|
+
data.tar.gz: 6bbf03aeaa7d63c17f99dcbf6ae18365497dd391
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7e7b4a9746bfe3ad6a71d8221dde8e4a2de108533326a9d14a9e15e210c596e27d38e878678c33e8ac5e20cb90c3aba7e80ed0994c6ef53b2e90c2ff0df1a09
|
7
|
+
data.tar.gz: 615ba83b27e81947bb3d638e33479f3fa7b3a88016655044b47804a70329a7e7a904a263efd05a8a517ac79f9052699d415274b28a0d4d6f46da1d9ef73b0779
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# TexMindbody::Api
|
2
|
+
|
3
|
+
Thei gem is a wrapper for the v6 API from Mindbody. Currently it supports a very limited subset of calls
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'tex_mindbody-api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tex_mindbody-api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
TexMindbody::Api.configure do |config|
|
25
|
+
config.username = "Siteowner"
|
26
|
+
config.password = "apitest1234"
|
27
|
+
config.api_key = "YOUR API KEY"
|
28
|
+
config.site_id = "-99"
|
29
|
+
end
|
30
|
+
|
31
|
+
TexMindbody::Api.issue
|
32
|
+
clients = TexMindbody::Api.clients SearchText: "Smith"
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/meka-nich/tex_mindbody-api.
|
44
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tex_mindbody/api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'logger'
|
3
|
+
require 'to_bool'
|
4
|
+
require 'set'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'active_support/core_ext/string'
|
7
|
+
require 'tex_mindbody/api/version'
|
8
|
+
require 'tex_mindbody/api/configuration'
|
9
|
+
require 'tex_mindbody/api/model'
|
10
|
+
require 'tex_mindbody/api/endpoint'
|
11
|
+
|
12
|
+
module TexMindbody
|
13
|
+
module Api
|
14
|
+
class << self
|
15
|
+
attr_reader :headers
|
16
|
+
attr_accessor :logger
|
17
|
+
|
18
|
+
def configure
|
19
|
+
yield config
|
20
|
+
init
|
21
|
+
end
|
22
|
+
|
23
|
+
def config
|
24
|
+
@config ||= TexMindbody::Api::Configuration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def init
|
28
|
+
logger ||= Logger.new STDOUT
|
29
|
+
logger.level = Logger::WARN
|
30
|
+
|
31
|
+
if TexMindbody::Api.config.rest_api.nil? || TexMindbody::Api.config.rest_api.empty?
|
32
|
+
TexMindbody::Api.config.rest_api = "https://api.mindbodyonline.com/public/v6"
|
33
|
+
end
|
34
|
+
|
35
|
+
if TexMindbody::Api.config.username.nil? || TexMindbody::Api.config.password.nil?
|
36
|
+
Raise ArgumentError, "config.username & config.password must be set"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get the auth_token
|
40
|
+
if TexMindbody::Api.config.auth_token.nil?
|
41
|
+
TexMindbody::Api.issue
|
42
|
+
end
|
43
|
+
update_headers
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_headers
|
47
|
+
@headers = {
|
48
|
+
"Api-Key": TexMindbody::Api.config.api_key,
|
49
|
+
"SiteId": TexMindbody::Api.config.site_id,
|
50
|
+
"Authorization": TexMindbody::Api.config.auth_token
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def validate_query q, query_opts
|
55
|
+
raise ArgumentError.new "Invalid query parameters used #{q.keys.to_s}" unless q.keys.to_set.subset?(query_opts.to_set)
|
56
|
+
end
|
57
|
+
|
58
|
+
def paginated_get path, response_item, q = {}
|
59
|
+
results = []
|
60
|
+
offset = 0
|
61
|
+
query_params = q.map { |k,v| "#{k}=#{v}"}.join('&')
|
62
|
+
query_params += '&' unless query_params.empty?
|
63
|
+
loop do
|
64
|
+
path_paginated = "#{path}?#{query_params}offset=#{offset}&limit=200"
|
65
|
+
response = HTTParty.get path_paginated, headers: @headers
|
66
|
+
raise IOError.new response if response.server_error?
|
67
|
+
raise ArgumentError.new response unless response.success?
|
68
|
+
results += response[response_item]
|
69
|
+
break if ( (response['PaginationResponse']['PageSize'] + response['PaginationResponse']['RequestedOffset'] ) == response['PaginationResponse']['TotalResults'] )
|
70
|
+
offset += 200
|
71
|
+
end
|
72
|
+
results
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module TexMindbody
|
2
|
+
module Api
|
3
|
+
class << self
|
4
|
+
def clients q = {}
|
5
|
+
query_opts = %i{ClientIds SearchText IsProspect LastModifiedDate}
|
6
|
+
validate_query q, query_opts
|
7
|
+
path = "#{TexMindbody::Api.config.rest_api}/client/clients"
|
8
|
+
clients = paginated_get path, 'Clients', q
|
9
|
+
clients.map {|c| TexMindbody::Api::Model::Client.new c}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TexMindbody
|
2
|
+
module Api
|
3
|
+
class << self
|
4
|
+
def issue
|
5
|
+
path = "#{TexMindbody::Api.config.rest_api}/usertoken/issue"
|
6
|
+
headers = {
|
7
|
+
"Content-Type": 'application/json',
|
8
|
+
"Api-Key": TexMindbody::Api.config.api_key,
|
9
|
+
"SiteId": TexMindbody::Api.config.site_id
|
10
|
+
}
|
11
|
+
body = {
|
12
|
+
"Username": TexMindbody::Api.config.username,
|
13
|
+
"Password": TexMindbody::Api.config.password
|
14
|
+
}
|
15
|
+
response = HTTParty.post path, :headers => headers, :query => {}, :body => body.to_json
|
16
|
+
raise IOError.new response if response.server_error?
|
17
|
+
raise ArgumentError.new response unless response.success?
|
18
|
+
raise RuntimeError.new response if response['AccessToken'].nil?
|
19
|
+
TexMindbody::Api.config.auth_token = response['AccessToken']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tex_mindbody/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tex_mindbody-api"
|
8
|
+
spec.version = TexMindbody::Api::VERSION
|
9
|
+
spec.authors = ["Nich Young"]
|
10
|
+
spec.email = ["nich@meka.digital"]
|
11
|
+
|
12
|
+
spec.summary = %q{Mindbody v6 API}
|
13
|
+
spec.description = %q{TEX Mindbody v6 API wrapper}
|
14
|
+
spec.homepage = "https://github.com/meka-nich/tex_mindbody-api"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'httparty'
|
37
|
+
spec.add_runtime_dependency 'to_bool'
|
38
|
+
spec.add_runtime_dependency 'logger'
|
39
|
+
spec.add_runtime_dependency 'ostruct'
|
40
|
+
spec.add_runtime_dependency 'activesupport'
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tex_mindbody-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nich Young
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: to_bool
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: logger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ostruct
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: TEX Mindbody v6 API wrapper
|
126
|
+
email:
|
127
|
+
- nich@meka.digital
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- bin/console
|
139
|
+
- bin/setup
|
140
|
+
- lib/tex_mindbody/api.rb
|
141
|
+
- lib/tex_mindbody/api/configuration.rb
|
142
|
+
- lib/tex_mindbody/api/endpoint.rb
|
143
|
+
- lib/tex_mindbody/api/endpoint/client.rb
|
144
|
+
- lib/tex_mindbody/api/endpoint/usertoken.rb
|
145
|
+
- lib/tex_mindbody/api/model.rb
|
146
|
+
- lib/tex_mindbody/api/model/client.rb
|
147
|
+
- lib/tex_mindbody/api/version.rb
|
148
|
+
- tex_mindbody-api.gemspec
|
149
|
+
homepage: https://github.com/meka-nich/tex_mindbody-api
|
150
|
+
licenses: []
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.5.1
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Mindbody v6 API
|
172
|
+
test_files: []
|