shiftplanning 0.0.1

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.
data/lib/example.rb ADDED
@@ -0,0 +1,21 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'shiftplanning'
5
+ API_KEY = '9eea91f6fcaa9573b3949f4eb3b58b3d4624b2d0'#"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
6
+
7
+ interface = SP::Interface.new(API_KEY, :verbose => true, :outfile => '/home/krichardson/Desktop/output')
8
+ request = SP::Request.new
9
+
10
+ request.staff.login.params = {:username => 'krichardson@customerdirect.com', :password => 'T0p@z098765'}#{:username => 'hmoon@nabootique.com', :password => 'J@zZ'}
11
+
12
+ interface.submit(request.staff.login)
13
+ puts interface.token
14
+ puts request.staff.login.supported_methods.inspect
15
+ puts request.staff.login.required_params('get').inspect
16
+
17
+ interface.submit(request.api.config, request.api.methods)
18
+ puts interface.requests.inspect; puts
19
+ puts interface.responses.inspect; puts
20
+ puts interface.last_response.inspect; puts
21
+
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+
5
+ Copyright (C) 2013 Kyle Richardson
6
+
7
+ This program is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU General Public License
9
+ as published by the Free Software Foundation; either version 2
10
+ of the License, or (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program; if not, write to the Free Software
19
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+
21
+ =end
22
+
23
+ require 'rubygems'
24
+ require 'json'
25
+ require 'shiftplanning/interface'
26
+ require 'shiftplanning/http_error'
27
+
28
+ class ShiftPlanning; VERSION = '0.0.1' end
29
+ # Aliasing ShiftPlanning as SP
30
+ class SP < ShiftPlanning; end
@@ -0,0 +1,59 @@
1
+ =begin
2
+
3
+ Copyright (C) 2013 Kyle Richardson
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ =end
20
+
21
+ require 'uri'
22
+ require 'net/http'
23
+
24
+ class ShiftPlanning
25
+ class Config
26
+ # Setup class variables
27
+ @@uri = URI.parse("http://www.shiftplanning.com/api/")
28
+ @@http = Net::HTTP.new(@@uri.host, @@uri.port)
29
+ @@api_path = @@uri.path
30
+ @@return_types = %w(json xml html)
31
+
32
+ # Define getters and setters
33
+ attr_accessor :api_key, :token
34
+ attr_reader :output
35
+
36
+ # Constructor
37
+ #**********************************
38
+ def initialize _api_key, options = {}
39
+ self.api_key = _api_key
40
+ self.output=(options[:output]||'json')
41
+ self.token=(options[:token])
42
+ @session = options[:session]
43
+ self.token = @session[:sp_token] unless @session.nil?
44
+ @@http.set_debug_output(options[:outfile]||$stdout) if options[:verbose]
45
+ end
46
+
47
+ # Setter for output type
48
+ #**********************************
49
+ def output= _output
50
+ _output = _output.to_s
51
+
52
+ if @@return_types.include?(_output)
53
+ @output = _output
54
+ else
55
+ raise "#{_output} is not a valid output type"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,28 @@
1
+ =begin
2
+
3
+ Copyright (C) 2013 Kyle Richardson
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ =end
20
+
21
+ class ShiftPlanning
22
+ class HTTPError < Exception
23
+ def initialize code
24
+ super
25
+ message = code.to_s
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,108 @@
1
+ =begin
2
+
3
+ Copyright (C) 2013 Kyle Richardson
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ =end
20
+
21
+ require 'shiftplanning/config'
22
+ require 'shiftplanning/request'
23
+
24
+ class ShiftPlanning
25
+ class Interface < ShiftPlanning::Config
26
+ attr_reader(:last_request, :last_response, :requests, :responses, :last_response_raw)
27
+
28
+ #**********************************
29
+ def initialize api_key, options = {}
30
+ super(api_key, options)
31
+ @request = Net::HTTP::Post.new(@@api_path)
32
+ @last_response = nil
33
+ @last_request = nil
34
+ end
35
+
36
+ #**********************************
37
+ def submit *args
38
+ @requests = []; @responses = []
39
+ msgs = []
40
+
41
+ args.each{ |_request|
42
+ _request.params[:module] = _request.module
43
+ _request.params[:method] = _request.method
44
+ req = {:key => api_key, :output => output, :request => _request.params}
45
+ req[:token] = token unless token.nil?
46
+ @requests << req
47
+ req = JSON::generate(req)
48
+ self.last_request = req#_request.to_json
49
+
50
+ request.set_form_data({"data" => req})
51
+ response = @@http.request(request)
52
+ @last_response_raw = response
53
+
54
+ if http_error?(response)
55
+ raise HTTPError, response.code
56
+ else
57
+ (output == 'json' ?
58
+ (self.last_response = JSON.parse(response.body); @responses << JSON.parse(response.body)) :
59
+ (self.last_response = response.body; @responses << response.body)
60
+ )
61
+
62
+ @session[:sp_token] = last_response['token'] if(output == 'json' && @session != nil)
63
+ self.token = last_response['token'] if output == 'json'
64
+ self.token = @session[:sp_token] unless @session.nil?
65
+ msgs << response_msg(last_response['status']) if output == 'json'
66
+ end
67
+ }
68
+
69
+ msgs
70
+ end
71
+
72
+ private
73
+ def last_response=(response); @last_response = response end
74
+ def last_request=(request); @last_request = request end
75
+ def request; @request end
76
+ def request=(request); @request = request end
77
+ def http_error?(response); (response.code.to_i != 200) end
78
+
79
+ #**********************************
80
+ def response_msg code
81
+ case code.to_i
82
+ when -3 : 'Flagged API Key - Pemanently Banned'
83
+ when -2 : 'Flagged API Key - Too Many invalid access attempts - contact us'
84
+ when -1 : 'Flagged API Key - Temporarily Disabled - contact us'
85
+ when 1 : 'Success -'
86
+ when 2 : 'Invalid API key - App must be granted a valid key by ShiftPlanning'
87
+ when 3 : 'Invalid token key - Please re-authenticate'
88
+ when 4 : 'Invalid Method - No Method with that name exists in our API'
89
+ when 5 : 'Invalid Module - No Module with that name exists in our API'
90
+ when 6 : 'Invalid Action - No Action with that name exists in our API'
91
+ when 7 : 'Authentication Failed - You do not have permissions to access the service'
92
+ when 8 : 'Missing parameters - Your request is missing a required parameter'
93
+ when 9 : 'Invalid parameters - Your request has an invalid parameter type'
94
+ when 10 : 'Extra parameters - Your request has an extra/unallowed parameter type'
95
+ when 12 : 'Create Failed - Your CREATE request failed'
96
+ when 13 : 'Update Failed - Your UPDATE request failed'
97
+ when 14 : 'Delete Failed - Your DELETE request failed'
98
+ when 20 : 'Incorrect Permissions - You don\'t have the proper permissions to access this'
99
+ when 90 : 'Suspended API key - Access for your account has been suspended, please contact ShiftPlanning'
100
+ when 91 : 'Throttle exceeded - You have exceeded the max allowed requests. Try again later.'
101
+ when 98 : 'Bad API Paramaters - Invalid POST request. See Manual.'
102
+ when 99 : 'Service Offline - This service is temporarily offline. Try again later.'
103
+ else
104
+ 'Error code not found'
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+
3
+ Copyright (C) 2013 Kyle Richardson
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ =end
20
+
21
+ require 'shiftplanning/request/sp_module'
22
+
23
+ class ShiftPlanning
24
+ class Request < ShiftPlanning::Config
25
+ # Setup getters and setters
26
+ attr_reader(
27
+ :api, :admin, :messaging, :reports, :payroll, :schedule, :timeclock,
28
+ :staff, :availability, :location, :training, :group, :sales, :dashboard, :terminal
29
+ )
30
+
31
+ # Constructor
32
+ #**********************************
33
+ def initialize
34
+ @api = _api.new(SPModule.new('api.methods', 'GET'), SPModule.new('api.config', 'GET'))
35
+ @admin = _admin.new(
36
+ SPModule.new('admin.settings', 'GET', {}, %w(GET UPDATE), {:GET => ['token'], :UPDATE => ['token']}),
37
+ SPModule.new('admin.details', 'GET', {}, %w(GET UPDATE), {:GET => ['token'], :UPDATE => ['token']}),
38
+ SPModule.new('admin.files', 'GET', {}, %w(GET), {:GET => 'token'}),
39
+ SPModule.new('admin.file', 'GET', {}, %w(GET UPDATE DELETE CREATE), {
40
+ :GET => %w(token id), :UPDATE => %w(token id), :DELETE => %w(token id),
41
+ :CREATE => %W(token filename filedata filelength mimetype)
42
+ }),
43
+ SPModule.new('admin.backups', 'GET', {}, %w(GET), {:GET => ['token']}),
44
+ SPModule.new('admin.backup', 'GET', {}, %w(GET DELETE CREATE), {:GET => %w(token id), :CREATE => %w(token filename filedata filelength mimetype), :DELETE => %w(token id)}),
45
+ SPModule.new('admin.nrequests', 'GET', {}, %w(GET), {:GET => %w(token)}),
46
+ SPModule.new('admin.business', 'GET', {}, %w(GET), {:GET => %w(token)}),
47
+ SPModule.new('admin.group_perms', 'GET', {}, %w(GET UPDATE), {:GET => %w(token), :UPDATE => %w(token)})
48
+ )
49
+ @messaging = _messaging.new(
50
+ SPModule.new('messaging.messages', 'GET', {}, %w(GET), {:GET => %w(token)}),
51
+ SPModule.new('messaging.message', 'GET', {}, %w(GET CREATE DELETE UPDATE), {
52
+ :GET => %w(token id), :CREATE => %w(token subject message to), :UPDATE => %w(token id), :DELETE => %w(token id)
53
+ }),
54
+ SPModule.new('messaging.shift', 'CREATE', {}, %w(CREATE), {:CREATE => %w(token subject message id)}),
55
+ SPModule.new('messaging.wall', 'GET', {}, %w(GET CREATE DELETE), {:GET => %w(token), :CREATE => %w(token post), :DELETE => %w(token id delete)}),
56
+ SPModule.new('messaging.notice', 'GET', {}, %w(GET UPDATE CREATE DELETE), {
57
+ :GET => %w(token id), :CREATE => %w(token), :UPDATE => %w(token id), :DELETE => %w(token id)
58
+ }),
59
+ SPModule.new('messaging.notices', 'GET', {}, %w(GET), {:GET => %w(token)})
60
+ )
61
+ @reports = _reports.new(
62
+ SPModule.new('reports.schedule', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date type)}),
63
+ SPModule.new('reports.budget', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date)}),
64
+ SPModule.new('reports.timesheets', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date type)}),
65
+ SPModule.new('reports.employee', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date type)}),
66
+ SPModule.new('reports.custom', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date type fields)}),
67
+ SPModule.new('reports.daily_peak_hours_new', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date)}),
68
+ SPModule.new('reports.daily_peak_hours', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date)})
69
+ )
70
+ @payroll = _payroll.new(
71
+ SPModule.new('payroll.report', 'GET', {}, %w(GET), {:GET => %w(token type)}),
72
+ SPModule.new('payroll.ratecards', 'GET', {}, %w(GET), {:GET => %w(token)}),
73
+ SPModule.new('payroll.ratecard', 'GET', {}, %w(GET CREATE DELETE UPDATE), {:GET => %w(token id), :CREATE => %w(token name), :UPDATE => %w(token id), :DELETE => %w(token id)})
74
+ )
75
+ @schedule = _schedule.new(
76
+ SPModule.new('schedule.schedules', 'GET', {}, %w(GET), {:GET => %w(token)}),
77
+ SPModule.new('schedule.schedule', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
78
+ :GET => %w(token id), :CREATE => %w(token name), :UPDATE => %w(token id), :DELETE => %w(token id)
79
+ }),
80
+ SPModule.new('schedule.shifts', 'GET', {}, %w(GET), {:GET => %w(token)}),
81
+ SPModule.new('schedule.shift', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
82
+ :GET => %w(token id), :CREATE => %w(token start_time end_time start_date end_date), :UPDATE => %w(token id), :DELETE => %w(token id)
83
+ }),
84
+ SPModule.new('schedule.shiftapprove', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
85
+ :GET => %w(token id), :CREATE => %w(token id), :UPDATE => %w(token), :DELETE => %w(token id)
86
+ }),
87
+ SPModule.new('schedule.trade', 'GET', {}, %w(GET CREATE UDPATE), {:GET => %w(token id), :CREATE => %w(token shift tradewith reason), :UPDATE => %w(token trade action)}),
88
+ SPModule.new('schedule.trades', 'GET', {}, %w(GET), {:GET => %w(token)}),
89
+ SPModule.new('schedule.tradelist', 'GET', {}, %w(GET), {:GET => %w(token id)}),
90
+ SPModule.new('schedule.tradeswap', 'CREATE', {}, %w(CREATE UPDATE), {:CREATE => %w(token shift swap reason), :UPDATE => %w(token trade action)}),
91
+ SPModule.new('schedule.vacations', 'GET', {}, %w(GET), {:GET => %w(token)}),
92
+ SPModule.new('schedule.vacation', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
93
+ :GET => %w(token id), :CREATE => %w(token start_date end_date), :UPDATE => %w(token id), :DELETE => %w(token id)
94
+ }),
95
+ SPModule.new('schedule.conflicts', 'GET', {}, %w(GET), {:GET => %w(token)}),
96
+ SPModule.new('schedule.copy', 'GET', {}, %w(GET), {:GET => %w(token)}),
97
+ SPModule.new('schedule.clear', 'GET', {}, %w(GET), {:GET => %w(token)}),
98
+ SPModule.new('schedule.restore', 'GET', {}, %w(GET), {:GET => %w(token)}),
99
+ SPModule.new('schedule.wizard', 'GET', {}, %w(GET), {:GET => %w(token from_start from_end to_start to_end)}),
100
+ SPModule.new('schedule.adjust', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token from to budge)}),
101
+ SPModule.new('schedule.fill', 'GET', {}, %w(GET), {:GET => %w(token shifts)}),
102
+ SPModule.new('schedule.publish', 'GET', {}, %w(GET), {:GET => %w(token shifts)}),
103
+ SPModule.new('schedule.requests', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token id type mode)}),
104
+ SPModule.new('schedule.breakrule', 'GET', {}, %w(GET CREATE DELETE), {:GET => %w(token id), :CREATE => %w(token id break paid), :DELETE => %w(token id)}),
105
+ SPModule.new('schedule.shiftrequests', 'CREATE', {}, %w(CREATE), {:CREATE => %w(token shift)})
106
+ )
107
+ @timeclock = _timeclock.new(
108
+ SPModule.new('timeclock.timeclocks', 'GET', {}, %w(GET), {:GET => %w(token)}),
109
+ SPModule.new('timeclock.timeclock', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
110
+ :GET => %w(token id), :CREATE => %w(token start_date schedule employee start_time), :UPDATE => %w(token id), :DELETE => %w(token id)
111
+ }),
112
+ SPModule.new('timeclock.clockin', 'GET', {}, %w(GET), {:GET => %w(token)}),
113
+ SPModule.new('timeclock.preclockin', 'GET', {}, %w(GET CREATE), {:GET => %w(token), :CREATE => %w(token)}),
114
+ SPModule.new('timeclock.preclockins', 'GET', {}, %w(GET), {:GET => %w(token)}),
115
+ SPModule.new('timeclock.clockout', 'GET', {}, %w(GET), {:GET => %w(token)}),
116
+ SPModule.new('timeclock.status', 'GET', {}, %w(GET), {:GET => %w(token)}),
117
+ SPModule.new('timeclock.manage', 'GET', {}, %w(GET), {:GET => %w(token id action)}),
118
+ SPModule.new('timeclock.screenshot', 'GET', {}, %w(GET), {:GET => %w(token filedata)}),
119
+ SPModule.new('timeclock.event', 'CREATE', {}, %w(CREATE UPDATE DELETE), {
120
+ :CREATE => %w(token timeclock type), :UPDATE => %w(token timeclock type), :DELETE => %w(token timeclock type event)
121
+ }),
122
+ SPModule.new('timeclock.timesheets', 'GET', {}, %w(GET), {:GET => %w(token)}),
123
+ SPModule.new('timeclock.addclocktime', 'GET', {}, %w(GET), {:GET => %w(token employee datein dateout)}),
124
+ SPModule.new('timeclock.savenote', 'GET', {}, %w(GET), {:GET => %w(token id)}),
125
+ SPModule.new('timeclock.forceclockout', 'GET', {}, %w(GET), {:GET => %w(token id)}),
126
+ SPModule.new('timeclock.location', 'CREATE', {}, %w(CREATE DELETE), {:CREATE => %w(token name), :DELETE => %w(token id)}),
127
+ SPModule.new('timeclock.terminal', 'CREATE', {}, %w(DELETE CREATE UPDATE), {:CREATE => %w(token name location), :UPDATE => %w(token id), :DELETE => %w(token id)})
128
+ )
129
+ @staff = _staff.new(
130
+ SPModule.new('staff.login', 'GET', {}, %w(GET), {:GET => %w(username password)}),
131
+ SPModule.new('staff.logout', 'GET', {}, %w(GET), {:GET => %w(token)}),
132
+ SPModule.new('staff.employees', 'GET', {}, %w(GET CREATE), {:GET => %w(token), :CREATE => %w(token)}),
133
+ SPModule.new('staff.employee', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
134
+ :GET => %w(token), :CREATE => %w(token), :UPDATE => %w(token id), :DELETE => %w(token id)
135
+ }),
136
+ SPModule.new('staff.skills', 'GET', {}, %w(GET), {:GET => %w(token)}),
137
+ SPModule.new('staff.skill', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
138
+ :GET => %w(token id), :CREATE => %w(token name), :UPDATE => %w(token id name), :DELETE => %w(token id)
139
+ }),
140
+ SPModule.new('staff.customfields', 'GET', {}, %w(GET), {:GET => %w(token)}),
141
+ SPModule.new('staff.customfield', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
142
+ :GET => %w(token id), :CREATE => %w(token name type), :UPDATE => %w(token id), :DELETE => %w(token id)
143
+ }),
144
+ SPModule.new('staff.ping', 'GET', {}, %w(CREATE), {:CREATE => %w(token to message)})
145
+ )
146
+ @availability = _availability.new(
147
+ SPModule.new('availability.available', 'GET', {}, %w(GET), {:GET => %w(token start_date)}),
148
+ SPModule.new('availability.weekly', 'GET', {}, %w(GET UPDATE DELETE), {:GET => %w(token), :UPDATE => %w(token flag), :DELETE => %w(token start_time end_time)}),
149
+ SPModule.new('availability.future', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
150
+ :GET => %w(token), :CREATE => %w(token start_date), :UPDATE => %w(token id flag), :DELETE => %w(token id)
151
+ }),
152
+ SPModule.new('availability.approve', 'GET', {}, %w(GET UPDATE CREATE), {:GET => %w(token type), :CREATE => %w(token), :UPDATE => %w(token user type action)})
153
+ )
154
+ @location = _location.new(
155
+ SPModule.new('location.locations', 'GET', {}, %w(GET), {:GET => %w(token)}),
156
+ SPModule.new('location.location', 'GET', {}, %w(GET CREATE UPDATE DELETE), {
157
+ :GET => %w(token id), :CREATE => %w(token name type), :UPDATE => %w(token id), :DELETE => %w(token id)
158
+ })
159
+ )
160
+ @training = _training.new(
161
+ SPModule.new('training.progress', 'GET', {}, %w(GET), {:GET => %w(token)}),
162
+ SPModule.new('training.sections', 'GET', {}, %w(GET), {:GET => %w(token)}),
163
+ SPModule.new('training.section', 'GET', {}, %w(GET UPDATE DELETE CREATE), {
164
+ :GET => %w(token id), :CREATE => %w(token title), :UPDATE => %w(token id title), :DELETE => %w(token id)
165
+ }),
166
+ SPModule.new('training.modules', 'GET', {}, %w(GET), {:GET => %w(token)}),
167
+ SPModule.new('training.module', 'GET', {}, %w(GET UPDATE DELETE CREATE), {
168
+ :GET => %w(token id), :CREATE => %w(token title), :UPDATE => %w(token id), :DELETE => %w(token id)
169
+ }),
170
+ SPModule.new('training.complete', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token id)}),
171
+ SPModule.new('training.reorder', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token mode)}),
172
+ SPModule.new('training.digital_signature', 'GET', {}, %w(GET), {:GET => %w(token module_id)}),
173
+ SPModule.new('training.comments', 'GET', {}, %w(GET UPDATE), {:GET => %w(token module_id type), :UPDATE => %w(token module_id type)}),
174
+ SPModule.new('training.sync', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token id)}),
175
+ SPModule.new('training.quiz', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token answer)}),
176
+ SPModule.new('training.multiassign', 'UPDATE', {}, %w(UPDATE), {:UPDATE => %w(token assignments modules mode)}),
177
+ SPModule.new('training.tutorial', 'GET', {}, %w(GET), {:GET => %w(token tutorial_id)})
178
+ )
179
+ @group = _group.new(
180
+ SPModule.new('group.accounts', 'GET', {}, %w(GET CREATE), {:GET => %w(token), :CREATE => %w(token accounts)}),
181
+ SPModule.new('group.account', 'GET', {}, %w(GET UPDATE DELETE CREATE), {:GET => %w(token id), :CREATE => %w(token), :UPDATE => %w(token id), :DELETE => %w(token id)}),
182
+ SPModule.new('group.accountsplit', 'CREATE', {}, %w(CREATE), {:CREATE => %w(token location main_user_id)}),
183
+ SPModule.new('group.reports', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date type)})
184
+ )
185
+ @sales = _sales.new(
186
+ SPModule.new('sales.budgets', 'GET', {}, %w(GET), {:GET => %w(token start_date end_date)}),
187
+ SPModule.new('sales.budget', 'GET', {}, %w(GET UPDATE CREATE DELETE), {
188
+ :GET => %w(token start_date end_date), :CREATE => %w(token start_date end_date), :UPDATE => %w(token start_date end_date), :DELETE => %w(token start_date end_date)
189
+ })
190
+ )
191
+ @dashboard = _dashboard.new(
192
+ SPModule.new('dashboard.onnow', 'GET', {}, %w(GET), {:GET => %w(token)}),
193
+ SPModule.new('dashboard.notifications', 'GET', {}, %w(GET), {:GET => %w(token)})
194
+ )
195
+ @terminal = _terminal.new(
196
+ SPModule.new('terminal.login', 'GET', {}, %w(GET), {:GET => %w(token terminal_key)}),
197
+ SPModule.new('terminal.clockin', 'GET', {}, %w(GET), {:GET => %w(token terminal_key)}),
198
+ SPModule.new('terminal.clockout', 'GET', {}, %w(GET), {:GET => %w(token terminal_key)})
199
+ )
200
+ end
201
+
202
+ private # <<PRIVATE
203
+ def _api; Struct.new(:methods, :config) end
204
+ def _admin; Struct.new(:settings, :details, :files, :file, :backups, :backup, :nrequests, :business, :group_perms) end
205
+ def _messaging; Struct.new(:messages, :message, :shift, :wall, :notice, :notices) end
206
+ def _reports; Struct.new(:schedule, :budget, :timesheets, :employee, :custom, :daily_peak_hours_new, :daily_peak_hours) end
207
+ def _payroll; Struct.new(:report, :ratecards, :ratecard) end
208
+ def _staff; Struct.new(:login, :logout, :employees, :employee, :skills, :skill, :customfields, :customfield, :ping) end
209
+ def _availability; Struct.new(:available, :weekly, :future, :approve) end
210
+ def _location; Struct.new(:locations, :location) end
211
+ def _group; Struct.new(:accounts, :account, :accountsplit, :reports) end
212
+ def _sales; Struct.new(:budgets, :budget) end
213
+ def _dashboard; Struct.new(:onnow, :notifications) end
214
+ def _terminal; Struct.new(:login, :clockin, :clockout) end
215
+
216
+ def _schedule
217
+ Struct.new(
218
+ :schedules, :schedule, :shifts, :shift, :shiftapprove, :trade, :trades,
219
+ :tradelist, :tradeswap, :vacations, :vacation, :confilcts, :copy, :clear, :restore, :wizard,
220
+ :adjust, :fill, :publish, :requests, :breakrule, :shiftrequests
221
+ )
222
+ end
223
+
224
+ def _timeclock
225
+ Struct.new(
226
+ :timeclocks, :timeclock, :clockin, :preclockin, :preclockins, :clockout, :status, :manage,
227
+ :screenshot, :event, :timesheets, :addclocktime, :savenote, :forceclockout, :location, :terminal
228
+ )
229
+ end
230
+
231
+ def _training
232
+ Struct.new(
233
+ :progress, :sections, :section, :modules, :module, :complete, :reorder, :digital_signature,
234
+ :comments, :sync, :quiz, :multiassign, :tutorial
235
+ )
236
+ end
237
+ # PRIVATE
238
+ end
239
+ end
@@ -0,0 +1,52 @@
1
+ =begin
2
+
3
+ Copyright (C) 2013 Kyle Richardson
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
19
+ =end
20
+
21
+ class SPModule
22
+ # Setup getters and setters
23
+ attr_reader :supported_methods, :module
24
+ attr_accessor :params, :method
25
+
26
+ # Constructor
27
+ #**********************************
28
+ def initialize _module = '', _method = '', _params = {}, supported_methods = %w(GET), required_params = {:GET => []}
29
+ @supported_methods = supported_methods
30
+ @required_params = required_params
31
+ @params = _params
32
+ @module = _module
33
+ @method = _method
34
+ end
35
+
36
+ #**********************************
37
+ def required_params method
38
+ case method.class.to_s
39
+ when 'Symbol' : method = method.to_s.upcase.to_sym
40
+ when 'String' : method = method.upcase.to_sym
41
+ else
42
+ raise %q('method' should be a String or a Symbol)
43
+ end
44
+
45
+ case method
46
+ when :GET : @required_params[:GET]||'Unsupported method'
47
+ when :CREATE : @required_params[:CREATE]||'Unsupported method'
48
+ when :UPDATE : @required_params[:UPDATE]||'Unsupported method'
49
+ when :DELETE : @required_params[:DELETE]||'Unsupported method'
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shiftplanning
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - FractalPenguin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-03-29 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: " Copyright (C) 2013 Kyle Richardson\n\n This program is free software; you can redistribute it and/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"
36
+ email: kylerchrdsn@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - lib/example.rb
45
+ - lib/shiftplanning.rb
46
+ - lib/shiftplanning/request/sp_module.rb
47
+ - lib/shiftplanning/interface.rb
48
+ - lib/shiftplanning/http_error.rb
49
+ - lib/shiftplanning/request.rb
50
+ - lib/shiftplanning/config.rb
51
+ has_rdoc: true
52
+ homepage: https://github.com/Kylerchrdsn/ShiftPlanning-ruby
53
+ licenses:
54
+ - GPL-2
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.4.2
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Aids in interacting with ShiftPlanning API. Their site has SDKs for Javascript, PHP, C#, ASP.NET, and Python, but not Ruby @.@
85
+ test_files: []
86
+