wheniwork-ruby 1.0.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.
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,303 @@
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 'date'
23
+
24
+ module WhenIWork
25
+
26
+ class Shift
27
+ attr_accessor :start_time
28
+
29
+ attr_accessor :end_time
30
+
31
+ attr_accessor :created_at
32
+
33
+ attr_accessor :updated_at
34
+
35
+ attr_accessor :notified_at
36
+
37
+ attr_accessor :id
38
+
39
+ attr_accessor :account_id
40
+
41
+ attr_accessor :user_id
42
+
43
+ attr_accessor :location_id
44
+
45
+ attr_accessor :alerted
46
+
47
+ attr_accessor :is_open
48
+
49
+ attr_accessor :acknowledged
50
+
51
+ attr_accessor :notes
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'start_time' => :'start_time',
57
+ :'end_time' => :'end_time',
58
+ :'created_at' => :'created_at',
59
+ :'updated_at' => :'updated_at',
60
+ :'notified_at' => :'notified_at',
61
+ :'id' => :'id',
62
+ :'account_id' => :'account_id',
63
+ :'user_id' => :'user_id',
64
+ :'location_id' => :'location_id',
65
+ :'alerted' => :'alerted',
66
+ :'is_open' => :'is_open',
67
+ :'acknowledged' => :'acknowledged',
68
+ :'notes' => :'notes'
69
+ }
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.swagger_types
74
+ {
75
+ :'start_time' => :'DateTime',
76
+ :'end_time' => :'DateTime',
77
+ :'created_at' => :'DateTime',
78
+ :'updated_at' => :'DateTime',
79
+ :'notified_at' => :'DateTime',
80
+ :'id' => :'Integer',
81
+ :'account_id' => :'Integer',
82
+ :'user_id' => :'Integer',
83
+ :'location_id' => :'Integer',
84
+ :'alerted' => :'BOOLEAN',
85
+ :'is_open' => :'BOOLEAN',
86
+ :'acknowledged' => :'Integer',
87
+ :'notes' => :'String'
88
+ }
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ return unless attributes.is_a?(Hash)
95
+
96
+ # convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
98
+
99
+ if attributes.has_key?(:'start_time')
100
+ self.start_time = attributes[:'start_time']
101
+ end
102
+
103
+ if attributes.has_key?(:'end_time')
104
+ self.end_time = attributes[:'end_time']
105
+ end
106
+
107
+ if attributes.has_key?(:'created_at')
108
+ self.created_at = attributes[:'created_at']
109
+ end
110
+
111
+ if attributes.has_key?(:'updated_at')
112
+ self.updated_at = attributes[:'updated_at']
113
+ end
114
+
115
+ if attributes.has_key?(:'notified_at')
116
+ self.notified_at = attributes[:'notified_at']
117
+ end
118
+
119
+ if attributes.has_key?(:'id')
120
+ self.id = attributes[:'id']
121
+ end
122
+
123
+ if attributes.has_key?(:'account_id')
124
+ self.account_id = attributes[:'account_id']
125
+ end
126
+
127
+ if attributes.has_key?(:'user_id')
128
+ self.user_id = attributes[:'user_id']
129
+ end
130
+
131
+ if attributes.has_key?(:'location_id')
132
+ self.location_id = attributes[:'location_id']
133
+ end
134
+
135
+ if attributes.has_key?(:'alerted')
136
+ self.alerted = attributes[:'alerted']
137
+ end
138
+
139
+ if attributes.has_key?(:'is_open')
140
+ self.is_open = attributes[:'is_open']
141
+ end
142
+
143
+ if attributes.has_key?(:'acknowledged')
144
+ self.acknowledged = attributes[:'acknowledged']
145
+ end
146
+
147
+ if attributes.has_key?(:'notes')
148
+ self.notes = attributes[:'notes']
149
+ end
150
+
151
+ end
152
+
153
+ # Show invalid properties with the reasons. Usually used together with valid?
154
+ # @return Array for valid properies with the reasons
155
+ def list_invalid_properties
156
+ invalid_properties = Array.new
157
+ return invalid_properties
158
+ end
159
+
160
+ # Check to see if the all the properties in the model are valid
161
+ # @return true if the model is valid
162
+ def valid?
163
+ end
164
+
165
+ # Checks equality by comparing each attribute.
166
+ # @param [Object] Object to be compared
167
+ def ==(o)
168
+ return true if self.equal?(o)
169
+ self.class == o.class &&
170
+ start_time == o.start_time &&
171
+ end_time == o.end_time &&
172
+ created_at == o.created_at &&
173
+ updated_at == o.updated_at &&
174
+ notified_at == o.notified_at &&
175
+ id == o.id &&
176
+ account_id == o.account_id &&
177
+ user_id == o.user_id &&
178
+ location_id == o.location_id &&
179
+ alerted == o.alerted &&
180
+ is_open == o.is_open &&
181
+ acknowledged == o.acknowledged &&
182
+ notes == o.notes
183
+ end
184
+
185
+ # @see the `==` method
186
+ # @param [Object] Object to be compared
187
+ def eql?(o)
188
+ self == o
189
+ end
190
+
191
+ # Calculates hash code according to all attributes.
192
+ # @return [Fixnum] Hash code
193
+ def hash
194
+ [start_time, end_time, created_at, updated_at, notified_at, id, account_id, user_id, location_id, alerted, is_open, acknowledged, notes].hash
195
+ end
196
+
197
+ # Builds the object from hash
198
+ # @param [Hash] attributes Model attributes in the form of hash
199
+ # @return [Object] Returns the model itself
200
+ def build_from_hash(attributes)
201
+ return nil unless attributes.is_a?(Hash)
202
+ self.class.swagger_types.each_pair do |key, type|
203
+ if type =~ /^Array<(.*)>/i
204
+ # check to ensure the input is an array given that the the attribute
205
+ # is documented as an array but the input is not
206
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
207
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
208
+ end
209
+ elsif !attributes[self.class.attribute_map[key]].nil?
210
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
211
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
212
+ end
213
+
214
+ self
215
+ end
216
+
217
+ # Deserializes the data based on type
218
+ # @param string type Data type
219
+ # @param string value Value to be deserialized
220
+ # @return [Object] Deserialized data
221
+ def _deserialize(type, value)
222
+ case type.to_sym
223
+ when :DateTime
224
+ DateTime.parse(value)
225
+ when :Date
226
+ Date.parse(value)
227
+ when :String
228
+ value.to_s
229
+ when :Integer
230
+ value.to_i
231
+ when :Float
232
+ value.to_f
233
+ when :BOOLEAN
234
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
235
+ true
236
+ else
237
+ false
238
+ end
239
+ when :Object
240
+ # generic object (usually a Hash), return directly
241
+ value
242
+ when /\AArray<(?<inner_type>.+)>\z/
243
+ inner_type = Regexp.last_match[:inner_type]
244
+ value.map { |v| _deserialize(inner_type, v) }
245
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
246
+ k_type = Regexp.last_match[:k_type]
247
+ v_type = Regexp.last_match[:v_type]
248
+ {}.tap do |hash|
249
+ value.each do |k, v|
250
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
251
+ end
252
+ end
253
+ else # model
254
+ temp_model = WhenIWork.const_get(type).new
255
+ temp_model.build_from_hash(value)
256
+ end
257
+ end
258
+
259
+ # Returns the string representation of the object
260
+ # @return [String] String presentation of the object
261
+ def to_s
262
+ to_hash.to_s
263
+ end
264
+
265
+ # to_body is an alias to to_hash (backward compatibility)
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_body
268
+ to_hash
269
+ end
270
+
271
+ # Returns the object in the form of hash
272
+ # @return [Hash] Returns the object in the form of hash
273
+ def to_hash
274
+ hash = {}
275
+ self.class.attribute_map.each_pair do |attr, param|
276
+ value = self.send(attr)
277
+ next if value.nil?
278
+ hash[param] = _to_hash(value)
279
+ end
280
+ hash
281
+ end
282
+
283
+ # Outputs non-array value in the form of hash
284
+ # For object, use to_hash. Otherwise, just return the value
285
+ # @param [Object] value Any valid value
286
+ # @return [Hash] Returns the value in the form of hash
287
+ def _to_hash(value)
288
+ if value.is_a?(Array)
289
+ value.compact.map{ |v| _to_hash(v) }
290
+ elsif value.is_a?(Hash)
291
+ {}.tap do |hash|
292
+ value.each { |k, v| hash[k] = _to_hash(v) }
293
+ end
294
+ elsif value.respond_to? :to_hash
295
+ value.to_hash
296
+ else
297
+ value
298
+ end
299
+ end
300
+
301
+ end
302
+
303
+ end
@@ -0,0 +1,280 @@
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 'date'
23
+
24
+ module WhenIWork
25
+
26
+ class User
27
+ attr_accessor :id
28
+
29
+ attr_accessor :account_id
30
+
31
+ attr_accessor :role
32
+
33
+ attr_accessor :email
34
+
35
+ attr_accessor :first_name
36
+
37
+ attr_accessor :last_name
38
+
39
+ attr_accessor :phone_number
40
+
41
+ attr_accessor :employee_code
42
+
43
+ attr_accessor :positions
44
+
45
+ attr_accessor :locations
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'id' => :'id',
51
+ :'account_id' => :'account_id',
52
+ :'role' => :'role',
53
+ :'email' => :'email',
54
+ :'first_name' => :'first_name',
55
+ :'last_name' => :'last_name',
56
+ :'phone_number' => :'phone_number',
57
+ :'employee_code' => :'employee_code',
58
+ :'positions' => :'positions',
59
+ :'locations' => :'locations'
60
+ }
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.swagger_types
65
+ {
66
+ :'id' => :'Integer',
67
+ :'account_id' => :'Integer',
68
+ :'role' => :'Integer',
69
+ :'email' => :'String',
70
+ :'first_name' => :'String',
71
+ :'last_name' => :'String',
72
+ :'phone_number' => :'String',
73
+ :'employee_code' => :'String',
74
+ :'positions' => :'Array<Integer>',
75
+ :'locations' => :'Array<Integer>'
76
+ }
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ return unless attributes.is_a?(Hash)
83
+
84
+ # convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
86
+
87
+ if attributes.has_key?(:'id')
88
+ self.id = attributes[:'id']
89
+ end
90
+
91
+ if attributes.has_key?(:'account_id')
92
+ self.account_id = attributes[:'account_id']
93
+ end
94
+
95
+ if attributes.has_key?(:'role')
96
+ self.role = attributes[:'role']
97
+ end
98
+
99
+ if attributes.has_key?(:'email')
100
+ self.email = attributes[:'email']
101
+ end
102
+
103
+ if attributes.has_key?(:'first_name')
104
+ self.first_name = attributes[:'first_name']
105
+ end
106
+
107
+ if attributes.has_key?(:'last_name')
108
+ self.last_name = attributes[:'last_name']
109
+ end
110
+
111
+ if attributes.has_key?(:'phone_number')
112
+ self.phone_number = attributes[:'phone_number']
113
+ end
114
+
115
+ if attributes.has_key?(:'employee_code')
116
+ self.employee_code = attributes[:'employee_code']
117
+ end
118
+
119
+ if attributes.has_key?(:'positions')
120
+ if (value = attributes[:'positions']).is_a?(Array)
121
+ self.positions = value
122
+ end
123
+ end
124
+
125
+ if attributes.has_key?(:'locations')
126
+ if (value = attributes[:'locations']).is_a?(Array)
127
+ self.locations = value
128
+ end
129
+ end
130
+
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properies with the reasons
135
+ def list_invalid_properties
136
+ invalid_properties = Array.new
137
+ return invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ id == o.id &&
151
+ account_id == o.account_id &&
152
+ role == o.role &&
153
+ email == o.email &&
154
+ first_name == o.first_name &&
155
+ last_name == o.last_name &&
156
+ phone_number == o.phone_number &&
157
+ employee_code == o.employee_code &&
158
+ positions == o.positions &&
159
+ locations == o.locations
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Fixnum] Hash code
170
+ def hash
171
+ [id, account_id, role, email, first_name, last_name, phone_number, employee_code, positions, locations].hash
172
+ 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
+ end
279
+
280
+ end