wheniwork-ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +19 -0
  3. data/Gemfile.lock +106 -0
  4. data/LICENSE +201 -0
  5. data/README.md +111 -0
  6. data/docs/DefaultApi.md +240 -0
  7. data/docs/InlineResponse200.md +8 -0
  8. data/docs/InlineResponse2001.md +10 -0
  9. data/docs/InlineResponse2002.md +8 -0
  10. data/docs/InlineResponse2003.md +8 -0
  11. data/docs/Position.md +11 -0
  12. data/docs/Shift.md +20 -0
  13. data/docs/User.md +17 -0
  14. data/git_push.sh +67 -0
  15. data/lib/wheniwork-ruby.rb +56 -0
  16. data/lib/wheniwork-ruby/api/api.rb +279 -0
  17. data/lib/wheniwork-ruby/api_client.rb +371 -0
  18. data/lib/wheniwork-ruby/api_error.rb +45 -0
  19. data/lib/wheniwork-ruby/configuration.rb +191 -0
  20. data/lib/wheniwork-ruby/models/inline_response_200.rb +195 -0
  21. data/lib/wheniwork-ruby/models/inline_response_200_1.rb +215 -0
  22. data/lib/wheniwork-ruby/models/inline_response_200_2.rb +195 -0
  23. data/lib/wheniwork-ruby/models/inline_response_200_3.rb +195 -0
  24. data/lib/wheniwork-ruby/models/position.rb +222 -0
  25. data/lib/wheniwork-ruby/models/shift.rb +303 -0
  26. data/lib/wheniwork-ruby/models/user.rb +280 -0
  27. data/lib/wheniwork-ruby/version.rb +24 -0
  28. data/spec/api/api_spec.rb +99 -0
  29. data/spec/api_client_spec.rb +260 -0
  30. data/spec/configuration_spec.rb +46 -0
  31. data/spec/models/inline_response_200_1_spec.rb +63 -0
  32. data/spec/models/inline_response_200_2_spec.rb +51 -0
  33. data/spec/models/inline_response_200_3_spec.rb +51 -0
  34. data/spec/models/inline_response_200_spec.rb +51 -0
  35. data/spec/models/position_spec.rb +69 -0
  36. data/spec/models/shift_spec.rb +123 -0
  37. data/spec/models/user_spec.rb +105 -0
  38. data/spec/spec_helper.rb +120 -0
  39. data/wheniwork-ruby.gemspec +53 -0
  40. metadata +273 -0
@@ -0,0 +1,24 @@
1
+ =begin
2
+ Wheniwork
3
+
4
+ OpenAPI spec version: v2
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ =end
21
+
22
+ module WhenIWork
23
+ VERSION = "1.0.0"
24
+ end
@@ -0,0 +1,99 @@
1
+ =begin
2
+ Wheniwork
3
+
4
+ OpenAPI spec version: v2
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ =end
21
+
22
+ require 'spec_helper'
23
+ require 'json'
24
+
25
+ # Unit tests for WhenIWork::Api
26
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
27
+ # Please update as you see appropriate
28
+ describe 'Api' do
29
+ before do
30
+ # run before each test
31
+ @instance = WhenIWork::Api.new
32
+ end
33
+
34
+ after do
35
+ # run after each test
36
+ end
37
+
38
+ describe 'test an instance of Api' do
39
+ it 'should create an instact of Api' do
40
+ expect(@instance).to be_instance_of(WhenIWork::Api)
41
+ end
42
+ end
43
+
44
+ # unit tests for get_positions
45
+ #
46
+ # This method allows you to get a list of all positions in your account.
47
+ # @param [Hash] opts the optional parameters
48
+ # @option opts [BOOLEAN] :show_deleted Whether to show positions that have been deleted.
49
+ # @return [InlineResponse200]
50
+ describe 'get_positions test' do
51
+ it "should work" do
52
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
53
+ end
54
+ end
55
+
56
+ # unit tests for get_shift
57
+ #
58
+ # Gets the details of an existing shift.
59
+ # @param shift_id max records to return
60
+ # @param [Hash] opts the optional parameters
61
+ # @return [InlineResponse2002]
62
+ describe 'get_shift test' do
63
+ it "should work" do
64
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
65
+ end
66
+ end
67
+
68
+ # unit tests for get_shifts
69
+ #
70
+ # Get a list of shifts.
71
+ # @param [Hash] opts the optional parameters
72
+ # @option opts [String] :user_id The ID of the user to get shifts for. For multiple users, enter a list of user IDs separated by commas (e.g. 1,5,3).
73
+ # @option opts [DateTime] :start Start time for the search window. The default is the current date and time
74
+ # @option opts [DateTime] :_end End time for the search window. The default is exactly three days from the start time.
75
+ # @option opts [String] :location_id The ID of the location to get shifts for. For multiple locations, enter a list of location IDs separated by commas.
76
+ # @option opts [String] :position_id The ID of the position to get shifts for. For multiple position, enter a list of position IDs separated by commas.
77
+ # @option opts [BOOLEAN] :include_open Whether to include OpenShifts in the results.
78
+ # @option opts [BOOLEAN] :include_onlyopen Whether to include OpenShifts in the results.
79
+ # @option opts [BOOLEAN] :unpublished Whether unpublished shifts should be included in the results.
80
+ # @return [InlineResponse2001]
81
+ describe 'get_shifts test' do
82
+ it "should work" do
83
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
84
+ end
85
+ end
86
+
87
+ # unit tests for get_user
88
+ #
89
+ # Get a specific user by their ID.
90
+ # @param user_id The user identifier number
91
+ # @param [Hash] opts the optional parameters
92
+ # @return [InlineResponse2003]
93
+ describe 'get_user test' do
94
+ it "should work" do
95
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,260 @@
1
+ =begin
2
+ Wheniwork
3
+
4
+ OpenAPI spec version: v2
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ =end
21
+
22
+ require 'spec_helper'
23
+
24
+ describe WhenIWork::ApiClient do
25
+ context 'initialization' do
26
+ context 'URL stuff' do
27
+ context 'host' do
28
+ it 'removes http from host' do
29
+ WhenIWork.configure { |c| c.host = 'http://example.com' }
30
+ expect(WhenIWork::Configuration.default.host).to eq('example.com')
31
+ end
32
+
33
+ it 'removes https from host' do
34
+ WhenIWork.configure { |c| c.host = 'https://wookiee.com' }
35
+ expect(WhenIWork::ApiClient.default.config.host).to eq('wookiee.com')
36
+ end
37
+
38
+ it 'removes trailing path from host' do
39
+ WhenIWork.configure { |c| c.host = 'hobo.com/v4' }
40
+ expect(WhenIWork::Configuration.default.host).to eq('hobo.com')
41
+ end
42
+ end
43
+
44
+ context 'base_path' do
45
+ it "prepends a slash to base_path" do
46
+ WhenIWork.configure { |c| c.base_path = 'v4/dog' }
47
+ expect(WhenIWork::Configuration.default.base_path).to eq('/v4/dog')
48
+ end
49
+
50
+ it "doesn't prepend a slash if one is already there" do
51
+ WhenIWork.configure { |c| c.base_path = '/v4/dog' }
52
+ expect(WhenIWork::Configuration.default.base_path).to eq('/v4/dog')
53
+ end
54
+
55
+ it "ends up as a blank string if nil" do
56
+ WhenIWork.configure { |c| c.base_path = nil }
57
+ expect(WhenIWork::Configuration.default.base_path).to eq('')
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#update_params_for_auth!" do
64
+ it "sets header api-key parameter without prefix" do
65
+ WhenIWork.configure do |c|
66
+ c.api_key['W-Token'] = 'special-key'
67
+ end
68
+
69
+ api_client = WhenIWork::ApiClient.new
70
+
71
+ header_params = {}
72
+ query_params = {}
73
+ auth_names = ['api_key', 'unknown']
74
+ api_client.update_params_for_auth! header_params, query_params, auth_names
75
+ expect(api_client.config.api_key).to eq({'W-Token' => 'special-key'})
76
+ end
77
+ end
78
+
79
+ describe "timeout in #build_request" do
80
+ let(:config) { WhenIWork::Configuration.new }
81
+ let(:api_client) { WhenIWork::ApiClient.new(config) }
82
+
83
+ it "defaults to 0" do
84
+ expect(WhenIWork::Configuration.default.timeout).to eq(0)
85
+ expect(config.timeout).to eq(0)
86
+
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(0)
89
+ end
90
+
91
+ it "can be customized" do
92
+ config.timeout = 100
93
+ request = api_client.build_request(:get, '/test')
94
+ expect(request.options[:timeout]).to eq(100)
95
+ end
96
+ end
97
+
98
+ describe "#deserialize" do
99
+ it "handles Array<Integer>" do
100
+ api_client = WhenIWork::ApiClient.new
101
+ headers = {'Content-Type' => 'application/json'}
102
+ response = double('response', headers: headers, body: '[12, 34]')
103
+ data = api_client.deserialize(response, 'Array<Integer>')
104
+ expect(data).to be_instance_of(Array)
105
+ expect(data).to eq([12, 34])
106
+ end
107
+
108
+ it "handles Array<Array<Integer>>" do
109
+ api_client = WhenIWork::ApiClient.new
110
+ headers = {'Content-Type' => 'application/json'}
111
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
112
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
113
+ expect(data).to be_instance_of(Array)
114
+ expect(data).to eq([[12, 34], [56]])
115
+ end
116
+
117
+ it "handles Hash<String, String>" do
118
+ api_client = WhenIWork::ApiClient.new
119
+ headers = {'Content-Type' => 'application/json'}
120
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
121
+ data = api_client.deserialize(response, 'Hash<String, String>')
122
+ expect(data).to be_instance_of(Hash)
123
+ expect(data).to eq({:message => 'Hello'})
124
+ end
125
+
126
+ it "handles Hash<String, Shift>" do
127
+ api_client = WhenIWork::ApiClient.new
128
+ headers = {'Content-Type' => 'application/json'}
129
+ response = double('response', headers: headers, body: '{"shift": {"id": 1}}')
130
+ data = api_client.deserialize(response, 'Hash<String, Shift>')
131
+ expect(data).to be_instance_of(Hash)
132
+ expect(data.keys).to eq([:shift])
133
+
134
+ shift = data[:shift]
135
+ expect(shift).to be_instance_of(WhenIWork::Shift)
136
+ expect(shift.id).to eq(1)
137
+ end
138
+
139
+ it "handles Hash<String, Hash<String, Shift>>" do
140
+ api_client = WhenIWork::ApiClient.new
141
+ headers = {'Content-Type' => 'application/json'}
142
+ response = double('response', headers: headers, body: '{"data": {"shift": {"id": 1}}}')
143
+ result = api_client.deserialize(response, 'Hash<String, Hash<String, Shift>>')
144
+ expect(result).to be_instance_of(Hash)
145
+ expect(result.keys).to match_array([:data])
146
+
147
+ data = result[:data]
148
+ expect(data).to be_instance_of(Hash)
149
+ expect(data.keys).to match_array([:shift])
150
+
151
+ pet = data[:shift]
152
+ expect(pet).to be_instance_of(WhenIWork::Shift)
153
+ expect(pet.id).to eq(1)
154
+ end
155
+ end
156
+
157
+ describe "#object_to_hash" do
158
+ it "ignores nils and includes empty arrays" do
159
+ api_client = WhenIWork::ApiClient.new
160
+ shift = WhenIWork::Shift.new
161
+ shift.id = 1
162
+ shift.notes = nil
163
+ expected = { id: 1 }
164
+ expect(api_client.object_to_hash(shift)).to eq(expected)
165
+ end
166
+ end
167
+
168
+ describe "#build_collection_param" do
169
+ let(:param) { ['aa', 'bb', 'cc'] }
170
+ let(:api_client) { WhenIWork::ApiClient.new }
171
+
172
+ it "works for csv" do
173
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
174
+ end
175
+
176
+ it "works for ssv" do
177
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
178
+ end
179
+
180
+ it "works for tsv" do
181
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
182
+ end
183
+
184
+ it "works for pipes" do
185
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
186
+ end
187
+
188
+ it "works for multi" do
189
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
190
+ end
191
+
192
+ it "fails for invalid collection format" do
193
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
194
+ end
195
+ end
196
+
197
+ describe "#json_mime?" do
198
+ let(:api_client) { WhenIWork::ApiClient.new }
199
+
200
+ it "works" do
201
+ expect(api_client.json_mime?(nil)).to eq false
202
+ expect(api_client.json_mime?('')).to eq false
203
+
204
+ expect(api_client.json_mime?('application/json')).to eq true
205
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
206
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
207
+
208
+ expect(api_client.json_mime?('application/xml')).to eq false
209
+ expect(api_client.json_mime?('text/plain')).to eq false
210
+ expect(api_client.json_mime?('application/jsonp')).to eq false
211
+ end
212
+ end
213
+
214
+ describe "#select_header_accept" do
215
+ let(:api_client) { WhenIWork::ApiClient.new }
216
+
217
+ it "works" do
218
+ expect(api_client.select_header_accept(nil)).to be_nil
219
+ expect(api_client.select_header_accept([])).to be_nil
220
+
221
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
222
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
223
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
224
+
225
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
226
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
227
+ end
228
+ end
229
+
230
+ describe "#select_header_content_type" do
231
+ let(:api_client) { WhenIWork::ApiClient.new }
232
+
233
+ it "works" do
234
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
235
+ expect(api_client.select_header_content_type([])).to eq('application/json')
236
+
237
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
238
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
239
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
240
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
241
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
242
+ end
243
+ end
244
+
245
+ describe "#sanitize_filename" do
246
+ let(:api_client) { WhenIWork::ApiClient.new }
247
+
248
+ it "works" do
249
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
250
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
251
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
252
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
253
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
254
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
255
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
256
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
257
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
258
+ end
259
+ end
260
+ end
@@ -0,0 +1,46 @@
1
+ =begin
2
+ Wheniwork
3
+
4
+ OpenAPI spec version: v2
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ =end
21
+
22
+ require 'spec_helper'
23
+
24
+ describe WhenIWork::Configuration do
25
+ let(:config) { WhenIWork::Configuration.default }
26
+
27
+ before(:each) do
28
+ WhenIWork.configure do |c|
29
+ c.host = 'petstore.swagger.io'
30
+ c.base_path = 'v2'
31
+ end
32
+ end
33
+
34
+ describe '#base_url' do
35
+ it 'should have the default value' do
36
+ expect(config.base_url).to eq('https://petstore.swagger.io/v2')
37
+ end
38
+
39
+ it 'should remove trailing slashes' do
40
+ [nil, '', '/', '//'].each do |base_path|
41
+ config.base_path = base_path
42
+ expect(config.base_url).to eq('https://petstore.swagger.io')
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,63 @@
1
+ =begin
2
+ Wheniwork
3
+
4
+ OpenAPI spec version: v2
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ =end
21
+
22
+ require 'spec_helper'
23
+ require 'json'
24
+ require 'date'
25
+
26
+ # Unit tests for WhenIWork::InlineResponse2001
27
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
28
+ # Please update as you see appropriate
29
+ describe 'InlineResponse2001' do
30
+ before do
31
+ # run before each test
32
+ @instance = WhenIWork::InlineResponse2001.new
33
+ end
34
+
35
+ after do
36
+ # run after each test
37
+ end
38
+
39
+ describe 'test an instance of InlineResponse2001' do
40
+ it 'should create an instact of InlineResponse2001' do
41
+ expect(@instance).to be_instance_of(WhenIWork::InlineResponse2001)
42
+ end
43
+ end
44
+ describe 'test attribute "start"' do
45
+ it 'should work' do
46
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
47
+ end
48
+ end
49
+
50
+ describe 'test attribute "_end"' do
51
+ it 'should work' do
52
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
53
+ end
54
+ end
55
+
56
+ describe 'test attribute "shifts"' do
57
+ it 'should work' do
58
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
59
+ end
60
+ end
61
+
62
+ end
63
+