wheniwork-ruby 1.0.0 → 1.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.
@@ -22,26 +22,18 @@ limitations under the License.
22
22
  require 'date'
23
23
 
24
24
  module WhenIWork
25
-
26
25
  class User
27
- attr_accessor :id
26
+ include WhenIWork::Response
28
27
 
28
+ attr_accessor :id
29
29
  attr_accessor :account_id
30
-
31
30
  attr_accessor :role
32
-
33
31
  attr_accessor :email
34
-
35
32
  attr_accessor :first_name
36
-
37
33
  attr_accessor :last_name
38
-
39
34
  attr_accessor :phone_number
40
-
41
35
  attr_accessor :employee_code
42
-
43
36
  attr_accessor :positions
44
-
45
37
  attr_accessor :locations
46
38
 
47
39
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -159,122 +151,10 @@ module WhenIWork
159
151
  locations == o.locations
160
152
  end
161
153
 
162
- # @see the `==` method
163
- # @param [Object] Object to be compared
164
- def eql?(o)
165
- self == o
166
- end
167
-
168
154
  # Calculates hash code according to all attributes.
169
155
  # @return [Fixnum] Hash code
170
156
  def hash
171
157
  [id, account_id, role, email, first_name, last_name, phone_number, employee_code, positions, locations].hash
172
158
  end
173
-
174
- # Builds the object from hash
175
- # @param [Hash] attributes Model attributes in the form of hash
176
- # @return [Object] Returns the model itself
177
- def build_from_hash(attributes)
178
- return nil unless attributes.is_a?(Hash)
179
- self.class.swagger_types.each_pair do |key, type|
180
- if type =~ /^Array<(.*)>/i
181
- # check to ensure the input is an array given that the the attribute
182
- # is documented as an array but the input is not
183
- if attributes[self.class.attribute_map[key]].is_a?(Array)
184
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
185
- end
186
- elsif !attributes[self.class.attribute_map[key]].nil?
187
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
188
- end # or else data not found in attributes(hash), not an issue as the data can be optional
189
- end
190
-
191
- self
192
- end
193
-
194
- # Deserializes the data based on type
195
- # @param string type Data type
196
- # @param string value Value to be deserialized
197
- # @return [Object] Deserialized data
198
- def _deserialize(type, value)
199
- case type.to_sym
200
- when :DateTime
201
- DateTime.parse(value)
202
- when :Date
203
- Date.parse(value)
204
- when :String
205
- value.to_s
206
- when :Integer
207
- value.to_i
208
- when :Float
209
- value.to_f
210
- when :BOOLEAN
211
- if value.to_s =~ /^(true|t|yes|y|1)$/i
212
- true
213
- else
214
- false
215
- end
216
- when :Object
217
- # generic object (usually a Hash), return directly
218
- value
219
- when /\AArray<(?<inner_type>.+)>\z/
220
- inner_type = Regexp.last_match[:inner_type]
221
- value.map { |v| _deserialize(inner_type, v) }
222
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
223
- k_type = Regexp.last_match[:k_type]
224
- v_type = Regexp.last_match[:v_type]
225
- {}.tap do |hash|
226
- value.each do |k, v|
227
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
- end
229
- end
230
- else # model
231
- temp_model = WhenIWork.const_get(type).new
232
- temp_model.build_from_hash(value)
233
- end
234
- end
235
-
236
- # Returns the string representation of the object
237
- # @return [String] String presentation of the object
238
- def to_s
239
- to_hash.to_s
240
- end
241
-
242
- # to_body is an alias to to_hash (backward compatibility)
243
- # @return [Hash] Returns the object in the form of hash
244
- def to_body
245
- to_hash
246
- end
247
-
248
- # Returns the object in the form of hash
249
- # @return [Hash] Returns the object in the form of hash
250
- def to_hash
251
- hash = {}
252
- self.class.attribute_map.each_pair do |attr, param|
253
- value = self.send(attr)
254
- next if value.nil?
255
- hash[param] = _to_hash(value)
256
- end
257
- hash
258
- end
259
-
260
- # Outputs non-array value in the form of hash
261
- # For object, use to_hash. Otherwise, just return the value
262
- # @param [Object] value Any valid value
263
- # @return [Hash] Returns the value in the form of hash
264
- def _to_hash(value)
265
- if value.is_a?(Array)
266
- value.compact.map{ |v| _to_hash(v) }
267
- elsif value.is_a?(Hash)
268
- {}.tap do |hash|
269
- value.each { |k, v| hash[k] = _to_hash(v) }
270
- end
271
- elsif value.respond_to? :to_hash
272
- value.to_hash
273
- else
274
- value
275
- end
276
- end
277
-
278
159
  end
279
-
280
160
  end
@@ -0,0 +1,117 @@
1
+ module WhenIWork
2
+ module Response
3
+ attr_accessor :raw_data
4
+
5
+ # Builds the object from hash
6
+ # @param [Hash] attributes Model attributes in the form of hash
7
+ # @return [Object] Returns the model itself
8
+ def build_from_hash(attributes)
9
+ return nil unless attributes.is_a?(Hash)
10
+ self.raw_data = attributes
11
+
12
+ self.class.swagger_types.each_pair do |key, type|
13
+ if type =~ /^Array<(.*)>/i
14
+ # check to ensure the input is an array given that the the attribute
15
+ # is documented as an array but the input is not
16
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
17
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
18
+ end
19
+ elsif !attributes[self.class.attribute_map[key]].nil?
20
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
21
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
22
+ end
23
+
24
+ self
25
+ end
26
+
27
+ # @see the `==` method
28
+ # @param [Object] Object to be compared
29
+ def eql?(other)
30
+ self == other
31
+ end
32
+
33
+ # Returns the string representation of the object
34
+ # @return [String] String presentation of the object
35
+ def to_s
36
+ to_hash.to_s
37
+ end
38
+
39
+ # to_body is an alias to to_hash (backward compatibility)
40
+ # @return [Hash] Returns the object in the form of hash
41
+ def to_body
42
+ to_hash
43
+ end
44
+
45
+ # Returns the object in the form of hash
46
+ # @return [Hash] Returns the object in the form of hash
47
+ def to_hash
48
+ hash = {}
49
+ self.class.attribute_map.each_pair do |attr, param|
50
+ value = send(attr)
51
+ next if value.nil?
52
+ hash[param] = _to_hash(value)
53
+ end
54
+ hash
55
+ end
56
+
57
+ # Outputs non-array value in the form of hash
58
+ # For object, use to_hash. Otherwise, just return the value
59
+ # @param [Object] value Any valid value
60
+ # @return [Hash] Returns the value in the form of hash
61
+ def _to_hash(value)
62
+ if value.is_a?(Array)
63
+ value.compact.map { |v| _to_hash(v) }
64
+ elsif value.is_a?(Hash)
65
+ {}.tap do |hash|
66
+ value.each { |k, v| hash[k] = _to_hash(v) }
67
+ end
68
+ elsif value.respond_to? :to_hash
69
+ value.to_hash
70
+ else
71
+ value
72
+ end
73
+ end
74
+
75
+ # Deserializes the data based on type
76
+ # @param string type Data type
77
+ # @param string value Value to be deserialized
78
+ # @return [Object] Deserialized data
79
+ def _deserialize(type, value)
80
+ case type.to_sym
81
+ when :DateTime
82
+ DateTime.parse(value)
83
+ when :Date
84
+ Date.parse(value)
85
+ when :String
86
+ value.to_s
87
+ when :Integer
88
+ value.to_i
89
+ when :Float
90
+ value.to_f
91
+ when :BOOLEAN
92
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
93
+ true
94
+ else
95
+ false
96
+ end
97
+ when :Object
98
+ # generic object (usually a Hash), return directly
99
+ value
100
+ when /\AArray<(?<inner_type>.+)>\z/
101
+ inner_type = Regexp.last_match[:inner_type]
102
+ value.map { |v| _deserialize(inner_type, v) }
103
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
104
+ k_type = Regexp.last_match[:k_type]
105
+ v_type = Regexp.last_match[:v_type]
106
+ {}.tap do |hash|
107
+ value.each do |k, v|
108
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
109
+ end
110
+ end
111
+ else # model
112
+ temp_model = WhenIWork.const_get(type).new
113
+ temp_model.build_from_hash(value)
114
+ end
115
+ end
116
+ end
117
+ end
@@ -20,5 +20,5 @@ limitations under the License.
20
20
  =end
21
21
 
22
22
  module WhenIWork
23
- VERSION = "1.0.0"
23
+ VERSION = "1.1.0"
24
24
  end
@@ -0,0 +1,51 @@
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::InlineResponse2004
27
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
28
+ # Please update as you see appropriate
29
+ describe 'InlineResponse2004' do
30
+ before do
31
+ # run before each test
32
+ @instance = WhenIWork::InlineResponse2004.new
33
+ end
34
+
35
+ after do
36
+ # run after each test
37
+ end
38
+
39
+ describe 'test an instance of InlineResponse2004' do
40
+ it 'should create an instact of InlineResponse2004' do
41
+ expect(@instance).to be_instance_of(WhenIWork::InlineResponse2004)
42
+ end
43
+ end
44
+ describe 'test attribute "user"' 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
+ end
51
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wheniwork-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swagger-Codegen
@@ -201,11 +201,11 @@ files:
201
201
  - Gemfile.lock
202
202
  - LICENSE
203
203
  - README.md
204
- - docs/DefaultApi.md
205
204
  - docs/InlineResponse200.md
206
205
  - docs/InlineResponse2001.md
207
206
  - docs/InlineResponse2002.md
208
207
  - docs/InlineResponse2003.md
208
+ - docs/InlineResponse2004.md
209
209
  - docs/Position.md
210
210
  - docs/Shift.md
211
211
  - docs/User.md
@@ -219,9 +219,11 @@ files:
219
219
  - lib/wheniwork-ruby/models/inline_response_200_1.rb
220
220
  - lib/wheniwork-ruby/models/inline_response_200_2.rb
221
221
  - lib/wheniwork-ruby/models/inline_response_200_3.rb
222
+ - lib/wheniwork-ruby/models/inline_response_200_4.rb
222
223
  - lib/wheniwork-ruby/models/position.rb
223
224
  - lib/wheniwork-ruby/models/shift.rb
224
225
  - lib/wheniwork-ruby/models/user.rb
226
+ - lib/wheniwork-ruby/modules/response.rb
225
227
  - lib/wheniwork-ruby/version.rb
226
228
  - spec/api/api_spec.rb
227
229
  - spec/api_client_spec.rb
@@ -229,6 +231,7 @@ files:
229
231
  - spec/models/inline_response_200_1_spec.rb
230
232
  - spec/models/inline_response_200_2_spec.rb
231
233
  - spec/models/inline_response_200_3_spec.rb
234
+ - spec/models/inline_response_200_4_spec.rb
232
235
  - spec/models/inline_response_200_spec.rb
233
236
  - spec/models/position_spec.rb
234
237
  - spec/models/shift_spec.rb
@@ -266,6 +269,7 @@ test_files:
266
269
  - spec/models/inline_response_200_1_spec.rb
267
270
  - spec/models/inline_response_200_2_spec.rb
268
271
  - spec/models/inline_response_200_3_spec.rb
272
+ - spec/models/inline_response_200_4_spec.rb
269
273
  - spec/models/inline_response_200_spec.rb
270
274
  - spec/models/position_spec.rb
271
275
  - spec/models/shift_spec.rb
@@ -1,240 +0,0 @@
1
- # WhenIWork::Api
2
-
3
- All URIs are relative to *https://api.wheniwork.com/2*
4
-
5
- Method | HTTP request | Description
6
- ------------- | ------------- | -------------
7
- [**get_positions**](Api.md#get_positions) | **GET** /positions |
8
- [**get_shift**](Api.md#get_shift) | **GET** /shifts/{shift-id} |
9
- [**get_shifts**](Api.md#get_shifts) | **GET** /shifts |
10
- [**get_user**](Api.md#get_user) | **GET** /users/{user-id} |
11
-
12
-
13
- # **get_positions**
14
- > InlineResponse200 get_positions(opts)
15
-
16
-
17
-
18
- This method allows you to get a list of all positions in your account.
19
-
20
- ### Example
21
- ```ruby
22
- # load the gem
23
- require 'wheniwork-ruby'
24
- # setup authorization
25
- WhenIWork.configure do |config|
26
- # Configure API key authorization: apiKey
27
- config.api_key['W-Token'] = 'YOUR API KEY'
28
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
29
- #config.api_key_prefix['W-Token'] = 'Bearer'
30
- end
31
-
32
- api_instance = WhenIWork::Api.new
33
-
34
- opts = {
35
- show_deleted: true # BOOLEAN | Whether to show positions that have been deleted.
36
- }
37
-
38
- begin
39
- result = api_instance.get_positions(opts)
40
- p result
41
- rescue WhenIWork::ApiError => e
42
- puts "Exception when calling Api->get_positions: #{e}"
43
- end
44
- ```
45
-
46
- ### Parameters
47
-
48
- Name | Type | Description | Notes
49
- ------------- | ------------- | ------------- | -------------
50
- **show_deleted** | **BOOLEAN**| Whether to show positions that have been deleted. | [optional]
51
-
52
- ### Return type
53
-
54
- [**InlineResponse200**](InlineResponse200.md)
55
-
56
- ### Authorization
57
-
58
- [apiKey](../README.md#apiKey)
59
-
60
- ### HTTP request headers
61
-
62
- - **Content-Type**: application/json
63
- - **Accept**: application/json
64
-
65
-
66
-
67
- # **get_shift**
68
- > InlineResponse2002 get_shift(shift_id)
69
-
70
-
71
-
72
- Gets the details of an existing shift.
73
-
74
- ### Example
75
- ```ruby
76
- # load the gem
77
- require 'wheniwork-ruby'
78
- # setup authorization
79
- WhenIWork.configure do |config|
80
- # Configure API key authorization: apiKey
81
- config.api_key['W-Token'] = 'YOUR API KEY'
82
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
83
- #config.api_key_prefix['W-Token'] = 'Bearer'
84
- end
85
-
86
- api_instance = WhenIWork::Api.new
87
-
88
- shift_id = 56 # Integer | max records to return
89
-
90
-
91
- begin
92
- result = api_instance.get_shift(shift_id)
93
- p result
94
- rescue WhenIWork::ApiError => e
95
- puts "Exception when calling Api->get_shift: #{e}"
96
- end
97
- ```
98
-
99
- ### Parameters
100
-
101
- Name | Type | Description | Notes
102
- ------------- | ------------- | ------------- | -------------
103
- **shift_id** | **Integer**| max records to return |
104
-
105
- ### Return type
106
-
107
- [**InlineResponse2002**](InlineResponse2002.md)
108
-
109
- ### Authorization
110
-
111
- [apiKey](../README.md#apiKey)
112
-
113
- ### HTTP request headers
114
-
115
- - **Content-Type**: application/json
116
- - **Accept**: application/json
117
-
118
-
119
-
120
- # **get_shifts**
121
- > InlineResponse2001 get_shifts(opts)
122
-
123
-
124
-
125
- Get a list of shifts.
126
-
127
- ### Example
128
- ```ruby
129
- # load the gem
130
- require 'wheniwork-ruby'
131
- # setup authorization
132
- WhenIWork.configure do |config|
133
- # Configure API key authorization: apiKey
134
- config.api_key['W-Token'] = 'YOUR API KEY'
135
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
136
- #config.api_key_prefix['W-Token'] = 'Bearer'
137
- end
138
-
139
- api_instance = WhenIWork::Api.new
140
-
141
- opts = {
142
- user_id: "user_id_example", # String | 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).
143
- start: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | Start time for the search window. The default is the current date and time
144
- _end: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | End time for the search window. The default is exactly three days from the start time.
145
- location_id: "location_id_example", # String | The ID of the location to get shifts for. For multiple locations, enter a list of location IDs separated by commas.
146
- position_id: "position_id_example", # String | The ID of the position to get shifts for. For multiple position, enter a list of position IDs separated by commas.
147
- include_open: true, # BOOLEAN | Whether to include OpenShifts in the results.
148
- include_onlyopen: true, # BOOLEAN | Whether to include OpenShifts in the results.
149
- unpublished: true # BOOLEAN | Whether unpublished shifts should be included in the results.
150
- }
151
-
152
- begin
153
- result = api_instance.get_shifts(opts)
154
- p result
155
- rescue WhenIWork::ApiError => e
156
- puts "Exception when calling Api->get_shifts: #{e}"
157
- end
158
- ```
159
-
160
- ### Parameters
161
-
162
- Name | Type | Description | Notes
163
- ------------- | ------------- | ------------- | -------------
164
- **user_id** | **String**| 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). | [optional]
165
- **start** | **DateTime**| Start time for the search window. The default is the current date and time | [optional]
166
- **_end** | **DateTime**| End time for the search window. The default is exactly three days from the start time. | [optional]
167
- **location_id** | **String**| The ID of the location to get shifts for. For multiple locations, enter a list of location IDs separated by commas. | [optional]
168
- **position_id** | **String**| The ID of the position to get shifts for. For multiple position, enter a list of position IDs separated by commas. | [optional]
169
- **include_open** | **BOOLEAN**| Whether to include OpenShifts in the results. | [optional]
170
- **include_onlyopen** | **BOOLEAN**| Whether to include OpenShifts in the results. | [optional]
171
- **unpublished** | **BOOLEAN**| Whether unpublished shifts should be included in the results. | [optional]
172
-
173
- ### Return type
174
-
175
- [**InlineResponse2001**](InlineResponse2001.md)
176
-
177
- ### Authorization
178
-
179
- [apiKey](../README.md#apiKey)
180
-
181
- ### HTTP request headers
182
-
183
- - **Content-Type**: application/json
184
- - **Accept**: application/json
185
-
186
-
187
-
188
- # **get_user**
189
- > InlineResponse2003 get_user(user_id)
190
-
191
-
192
-
193
- Get a specific user by their ID.
194
-
195
- ### Example
196
- ```ruby
197
- # load the gem
198
- require 'wheniwork-ruby'
199
- # setup authorization
200
- WhenIWork.configure do |config|
201
- # Configure API key authorization: apiKey
202
- config.api_key['W-Token'] = 'YOUR API KEY'
203
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
204
- #config.api_key_prefix['W-Token'] = 'Bearer'
205
- end
206
-
207
- api_instance = WhenIWork::Api.new
208
-
209
- user_id = 56 # Integer | The user identifier number
210
-
211
-
212
- begin
213
- result = api_instance.get_user(user_id)
214
- p result
215
- rescue WhenIWork::ApiError => e
216
- puts "Exception when calling Api->get_user: #{e}"
217
- end
218
- ```
219
-
220
- ### Parameters
221
-
222
- Name | Type | Description | Notes
223
- ------------- | ------------- | ------------- | -------------
224
- **user_id** | **Integer**| The user identifier number |
225
-
226
- ### Return type
227
-
228
- [**InlineResponse2003**](InlineResponse2003.md)
229
-
230
- ### Authorization
231
-
232
- [apiKey](../README.md#apiKey)
233
-
234
- ### HTTP request headers
235
-
236
- - **Content-Type**: application/json
237
- - **Accept**: application/json
238
-
239
-
240
-