stackone_hris_client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +73 -0
- data/README.md +107 -0
- data/Rakefile +10 -0
- data/docs/Employee.md +48 -0
- data/docs/EmployeeResult.md +20 -0
- data/docs/EmployeesApi.md +169 -0
- data/docs/EmployeesPaginated.md +22 -0
- data/gem-config.yml +14 -0
- data/generate_gem.sh +1 -0
- data/git_push.sh +57 -0
- data/lib/stackone_hris_client/api/employees_api.rb +182 -0
- data/lib/stackone_hris_client/api_client.rb +392 -0
- data/lib/stackone_hris_client/api_error.rb +58 -0
- data/lib/stackone_hris_client/configuration.rb +306 -0
- data/lib/stackone_hris_client/models/employee.rb +427 -0
- data/lib/stackone_hris_client/models/employee_result.rb +231 -0
- data/lib/stackone_hris_client/models/employees_paginated.rb +247 -0
- data/lib/stackone_hris_client/version.rb +15 -0
- data/lib/stackone_hris_client.rb +42 -0
- data/spec/api/employees_api_spec.rb +68 -0
- data/spec/api_client_spec.rb +228 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/employee_result_spec.rb +40 -0
- data/spec/models/employee_spec.rb +124 -0
- data/spec/models/employees_paginated_spec.rb +46 -0
- data/spec/spec_helper.rb +111 -0
- data/stackone_hris_client.gemspec +38 -0
- metadata +118 -0
@@ -0,0 +1,427 @@
|
|
1
|
+
=begin
|
2
|
+
#StackOne Unified API
|
3
|
+
|
4
|
+
#The documentation for the StackOne Unified API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module StackOneHrisClient
|
17
|
+
class Employee
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :first_name
|
21
|
+
|
22
|
+
attr_accessor :last_name
|
23
|
+
|
24
|
+
attr_accessor :name
|
25
|
+
|
26
|
+
attr_accessor :display_name
|
27
|
+
|
28
|
+
attr_accessor :avatar_url
|
29
|
+
|
30
|
+
attr_accessor :personal_email
|
31
|
+
|
32
|
+
attr_accessor :personal_phone_number
|
33
|
+
|
34
|
+
attr_accessor :gender
|
35
|
+
|
36
|
+
attr_accessor :work_email
|
37
|
+
|
38
|
+
attr_accessor :work_phone_number
|
39
|
+
|
40
|
+
attr_accessor :title
|
41
|
+
|
42
|
+
attr_accessor :department
|
43
|
+
|
44
|
+
attr_accessor :manager_id
|
45
|
+
|
46
|
+
attr_accessor :birth_date
|
47
|
+
|
48
|
+
attr_accessor :start_date
|
49
|
+
|
50
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
51
|
+
def self.attribute_map
|
52
|
+
{
|
53
|
+
:'id' => :'id',
|
54
|
+
:'first_name' => :'first_name',
|
55
|
+
:'last_name' => :'last_name',
|
56
|
+
:'name' => :'name',
|
57
|
+
:'display_name' => :'display_name',
|
58
|
+
:'avatar_url' => :'avatar_url',
|
59
|
+
:'personal_email' => :'personal_email',
|
60
|
+
:'personal_phone_number' => :'personal_phone_number',
|
61
|
+
:'gender' => :'gender',
|
62
|
+
:'work_email' => :'work_email',
|
63
|
+
:'work_phone_number' => :'work_phone_number',
|
64
|
+
:'title' => :'title',
|
65
|
+
:'department' => :'department',
|
66
|
+
:'manager_id' => :'manager_id',
|
67
|
+
:'birth_date' => :'birth_date',
|
68
|
+
:'start_date' => :'start_date'
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns all the JSON keys this model knows about
|
73
|
+
def self.acceptable_attributes
|
74
|
+
attribute_map.values
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute type mapping.
|
78
|
+
def self.openapi_types
|
79
|
+
{
|
80
|
+
:'id' => :'String',
|
81
|
+
:'first_name' => :'String',
|
82
|
+
:'last_name' => :'String',
|
83
|
+
:'name' => :'String',
|
84
|
+
:'display_name' => :'String',
|
85
|
+
:'avatar_url' => :'String',
|
86
|
+
:'personal_email' => :'String',
|
87
|
+
:'personal_phone_number' => :'String',
|
88
|
+
:'gender' => :'String',
|
89
|
+
:'work_email' => :'String',
|
90
|
+
:'work_phone_number' => :'String',
|
91
|
+
:'title' => :'String',
|
92
|
+
:'department' => :'String',
|
93
|
+
:'manager_id' => :'String',
|
94
|
+
:'birth_date' => :'Time',
|
95
|
+
:'start_date' => :'Time'
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
# List of attributes with nullable: true
|
100
|
+
def self.openapi_nullable
|
101
|
+
Set.new([
|
102
|
+
])
|
103
|
+
end
|
104
|
+
|
105
|
+
# Initializes the object
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
def initialize(attributes = {})
|
108
|
+
if (!attributes.is_a?(Hash))
|
109
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHrisClient::Employee` initialize method"
|
110
|
+
end
|
111
|
+
|
112
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
113
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
114
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
115
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHrisClient::Employee`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
116
|
+
end
|
117
|
+
h[k.to_sym] = v
|
118
|
+
}
|
119
|
+
|
120
|
+
if attributes.key?(:'id')
|
121
|
+
self.id = attributes[:'id']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'first_name')
|
125
|
+
self.first_name = attributes[:'first_name']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'last_name')
|
129
|
+
self.last_name = attributes[:'last_name']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'name')
|
133
|
+
self.name = attributes[:'name']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'display_name')
|
137
|
+
self.display_name = attributes[:'display_name']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'avatar_url')
|
141
|
+
self.avatar_url = attributes[:'avatar_url']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:'personal_email')
|
145
|
+
self.personal_email = attributes[:'personal_email']
|
146
|
+
end
|
147
|
+
|
148
|
+
if attributes.key?(:'personal_phone_number')
|
149
|
+
self.personal_phone_number = attributes[:'personal_phone_number']
|
150
|
+
end
|
151
|
+
|
152
|
+
if attributes.key?(:'gender')
|
153
|
+
self.gender = attributes[:'gender']
|
154
|
+
end
|
155
|
+
|
156
|
+
if attributes.key?(:'work_email')
|
157
|
+
self.work_email = attributes[:'work_email']
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.key?(:'work_phone_number')
|
161
|
+
self.work_phone_number = attributes[:'work_phone_number']
|
162
|
+
end
|
163
|
+
|
164
|
+
if attributes.key?(:'title')
|
165
|
+
self.title = attributes[:'title']
|
166
|
+
end
|
167
|
+
|
168
|
+
if attributes.key?(:'department')
|
169
|
+
self.department = attributes[:'department']
|
170
|
+
end
|
171
|
+
|
172
|
+
if attributes.key?(:'manager_id')
|
173
|
+
self.manager_id = attributes[:'manager_id']
|
174
|
+
end
|
175
|
+
|
176
|
+
if attributes.key?(:'birth_date')
|
177
|
+
self.birth_date = attributes[:'birth_date']
|
178
|
+
end
|
179
|
+
|
180
|
+
if attributes.key?(:'start_date')
|
181
|
+
self.start_date = attributes[:'start_date']
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
186
|
+
# @return Array for valid properties with the reasons
|
187
|
+
def list_invalid_properties
|
188
|
+
invalid_properties = Array.new
|
189
|
+
if @id.nil?
|
190
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
191
|
+
end
|
192
|
+
|
193
|
+
if @first_name.nil?
|
194
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
195
|
+
end
|
196
|
+
|
197
|
+
if @last_name.nil?
|
198
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
199
|
+
end
|
200
|
+
|
201
|
+
if @name.nil?
|
202
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
203
|
+
end
|
204
|
+
|
205
|
+
if @display_name.nil?
|
206
|
+
invalid_properties.push('invalid value for "display_name", display_name cannot be nil.')
|
207
|
+
end
|
208
|
+
|
209
|
+
if @personal_email.nil?
|
210
|
+
invalid_properties.push('invalid value for "personal_email", personal_email cannot be nil.')
|
211
|
+
end
|
212
|
+
|
213
|
+
if @personal_phone_number.nil?
|
214
|
+
invalid_properties.push('invalid value for "personal_phone_number", personal_phone_number cannot be nil.')
|
215
|
+
end
|
216
|
+
|
217
|
+
if @gender.nil?
|
218
|
+
invalid_properties.push('invalid value for "gender", gender cannot be nil.')
|
219
|
+
end
|
220
|
+
|
221
|
+
if @work_email.nil?
|
222
|
+
invalid_properties.push('invalid value for "work_email", work_email cannot be nil.')
|
223
|
+
end
|
224
|
+
|
225
|
+
if @work_phone_number.nil?
|
226
|
+
invalid_properties.push('invalid value for "work_phone_number", work_phone_number cannot be nil.')
|
227
|
+
end
|
228
|
+
|
229
|
+
if @title.nil?
|
230
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
231
|
+
end
|
232
|
+
|
233
|
+
if @department.nil?
|
234
|
+
invalid_properties.push('invalid value for "department", department cannot be nil.')
|
235
|
+
end
|
236
|
+
|
237
|
+
if @manager_id.nil?
|
238
|
+
invalid_properties.push('invalid value for "manager_id", manager_id cannot be nil.')
|
239
|
+
end
|
240
|
+
|
241
|
+
if @birth_date.nil?
|
242
|
+
invalid_properties.push('invalid value for "birth_date", birth_date cannot be nil.')
|
243
|
+
end
|
244
|
+
|
245
|
+
if @start_date.nil?
|
246
|
+
invalid_properties.push('invalid value for "start_date", start_date cannot be nil.')
|
247
|
+
end
|
248
|
+
|
249
|
+
invalid_properties
|
250
|
+
end
|
251
|
+
|
252
|
+
# Check to see if the all the properties in the model are valid
|
253
|
+
# @return true if the model is valid
|
254
|
+
def valid?
|
255
|
+
return false if @id.nil?
|
256
|
+
return false if @first_name.nil?
|
257
|
+
return false if @last_name.nil?
|
258
|
+
return false if @name.nil?
|
259
|
+
return false if @display_name.nil?
|
260
|
+
return false if @personal_email.nil?
|
261
|
+
return false if @personal_phone_number.nil?
|
262
|
+
return false if @gender.nil?
|
263
|
+
return false if @work_email.nil?
|
264
|
+
return false if @work_phone_number.nil?
|
265
|
+
return false if @title.nil?
|
266
|
+
return false if @department.nil?
|
267
|
+
return false if @manager_id.nil?
|
268
|
+
return false if @birth_date.nil?
|
269
|
+
return false if @start_date.nil?
|
270
|
+
true
|
271
|
+
end
|
272
|
+
|
273
|
+
# Checks equality by comparing each attribute.
|
274
|
+
# @param [Object] Object to be compared
|
275
|
+
def ==(o)
|
276
|
+
return true if self.equal?(o)
|
277
|
+
self.class == o.class &&
|
278
|
+
id == o.id &&
|
279
|
+
first_name == o.first_name &&
|
280
|
+
last_name == o.last_name &&
|
281
|
+
name == o.name &&
|
282
|
+
display_name == o.display_name &&
|
283
|
+
avatar_url == o.avatar_url &&
|
284
|
+
personal_email == o.personal_email &&
|
285
|
+
personal_phone_number == o.personal_phone_number &&
|
286
|
+
gender == o.gender &&
|
287
|
+
work_email == o.work_email &&
|
288
|
+
work_phone_number == o.work_phone_number &&
|
289
|
+
title == o.title &&
|
290
|
+
department == o.department &&
|
291
|
+
manager_id == o.manager_id &&
|
292
|
+
birth_date == o.birth_date &&
|
293
|
+
start_date == o.start_date
|
294
|
+
end
|
295
|
+
|
296
|
+
# @see the `==` method
|
297
|
+
# @param [Object] Object to be compared
|
298
|
+
def eql?(o)
|
299
|
+
self == o
|
300
|
+
end
|
301
|
+
|
302
|
+
# Calculates hash code according to all attributes.
|
303
|
+
# @return [Integer] Hash code
|
304
|
+
def hash
|
305
|
+
[id, first_name, last_name, name, display_name, avatar_url, personal_email, personal_phone_number, gender, work_email, work_phone_number, title, department, manager_id, birth_date, start_date].hash
|
306
|
+
end
|
307
|
+
|
308
|
+
# Builds the object from hash
|
309
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
310
|
+
# @return [Object] Returns the model itself
|
311
|
+
def self.build_from_hash(attributes)
|
312
|
+
new.build_from_hash(attributes)
|
313
|
+
end
|
314
|
+
|
315
|
+
# Builds the object from hash
|
316
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
317
|
+
# @return [Object] Returns the model itself
|
318
|
+
def build_from_hash(attributes)
|
319
|
+
return nil unless attributes.is_a?(Hash)
|
320
|
+
attributes = attributes.transform_keys(&:to_sym)
|
321
|
+
self.class.openapi_types.each_pair do |key, type|
|
322
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
323
|
+
self.send("#{key}=", nil)
|
324
|
+
elsif type =~ /\AArray<(.*)>/i
|
325
|
+
# check to ensure the input is an array given that the attribute
|
326
|
+
# is documented as an array but the input is not
|
327
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
328
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
329
|
+
end
|
330
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
331
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
self
|
336
|
+
end
|
337
|
+
|
338
|
+
# Deserializes the data based on type
|
339
|
+
# @param string type Data type
|
340
|
+
# @param string value Value to be deserialized
|
341
|
+
# @return [Object] Deserialized data
|
342
|
+
def _deserialize(type, value)
|
343
|
+
case type.to_sym
|
344
|
+
when :Time
|
345
|
+
Time.parse(value)
|
346
|
+
when :Date
|
347
|
+
Date.parse(value)
|
348
|
+
when :String
|
349
|
+
value.to_s
|
350
|
+
when :Integer
|
351
|
+
value.to_i
|
352
|
+
when :Float
|
353
|
+
value.to_f
|
354
|
+
when :Boolean
|
355
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
356
|
+
true
|
357
|
+
else
|
358
|
+
false
|
359
|
+
end
|
360
|
+
when :Object
|
361
|
+
# generic object (usually a Hash), return directly
|
362
|
+
value
|
363
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
364
|
+
inner_type = Regexp.last_match[:inner_type]
|
365
|
+
value.map { |v| _deserialize(inner_type, v) }
|
366
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
367
|
+
k_type = Regexp.last_match[:k_type]
|
368
|
+
v_type = Regexp.last_match[:v_type]
|
369
|
+
{}.tap do |hash|
|
370
|
+
value.each do |k, v|
|
371
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
else # model
|
375
|
+
# models (e.g. Pet) or oneOf
|
376
|
+
klass = StackOneHrisClient.const_get(type)
|
377
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
# Returns the string representation of the object
|
382
|
+
# @return [String] String presentation of the object
|
383
|
+
def to_s
|
384
|
+
to_hash.to_s
|
385
|
+
end
|
386
|
+
|
387
|
+
# to_body is an alias to to_hash (backward compatibility)
|
388
|
+
# @return [Hash] Returns the object in the form of hash
|
389
|
+
def to_body
|
390
|
+
to_hash
|
391
|
+
end
|
392
|
+
|
393
|
+
# Returns the object in the form of hash
|
394
|
+
# @return [Hash] Returns the object in the form of hash
|
395
|
+
def to_hash
|
396
|
+
hash = {}
|
397
|
+
self.class.attribute_map.each_pair do |attr, param|
|
398
|
+
value = self.send(attr)
|
399
|
+
if value.nil?
|
400
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
401
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
402
|
+
end
|
403
|
+
|
404
|
+
hash[param] = _to_hash(value)
|
405
|
+
end
|
406
|
+
hash
|
407
|
+
end
|
408
|
+
|
409
|
+
# Outputs non-array value in the form of hash
|
410
|
+
# For object, use to_hash. Otherwise, just return the value
|
411
|
+
# @param [Object] value Any valid value
|
412
|
+
# @return [Hash] Returns the value in the form of hash
|
413
|
+
def _to_hash(value)
|
414
|
+
if value.is_a?(Array)
|
415
|
+
value.compact.map { |v| _to_hash(v) }
|
416
|
+
elsif value.is_a?(Hash)
|
417
|
+
{}.tap do |hash|
|
418
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
419
|
+
end
|
420
|
+
elsif value.respond_to? :to_hash
|
421
|
+
value.to_hash
|
422
|
+
else
|
423
|
+
value
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
=begin
|
2
|
+
#StackOne Unified API
|
3
|
+
|
4
|
+
#The documentation for the StackOne Unified API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module StackOneHrisClient
|
17
|
+
class EmployeeResult
|
18
|
+
attr_accessor :data
|
19
|
+
|
20
|
+
attr_accessor :raw
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'data' => :'data',
|
26
|
+
:'raw' => :'raw'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'data' => :'Employee',
|
39
|
+
:'raw' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHrisClient::EmployeeResult` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHrisClient::EmployeeResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'data')
|
65
|
+
self.data = attributes[:'data']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'raw')
|
69
|
+
self.raw = attributes[:'raw']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
if @data.nil?
|
78
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
79
|
+
end
|
80
|
+
|
81
|
+
invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
return false if @data.nil?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
data == o.data &&
|
97
|
+
raw == o.raw
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Integer] Hash code
|
108
|
+
def hash
|
109
|
+
[data, raw].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def self.build_from_hash(attributes)
|
116
|
+
new.build_from_hash(attributes)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Builds the object from hash
|
120
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
121
|
+
# @return [Object] Returns the model itself
|
122
|
+
def build_from_hash(attributes)
|
123
|
+
return nil unless attributes.is_a?(Hash)
|
124
|
+
attributes = attributes.transform_keys(&:to_sym)
|
125
|
+
self.class.openapi_types.each_pair do |key, type|
|
126
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
127
|
+
self.send("#{key}=", nil)
|
128
|
+
elsif type =~ /\AArray<(.*)>/i
|
129
|
+
# check to ensure the input is an array given that the attribute
|
130
|
+
# is documented as an array but the input is not
|
131
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
132
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
133
|
+
end
|
134
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
135
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
self
|
140
|
+
end
|
141
|
+
|
142
|
+
# Deserializes the data based on type
|
143
|
+
# @param string type Data type
|
144
|
+
# @param string value Value to be deserialized
|
145
|
+
# @return [Object] Deserialized data
|
146
|
+
def _deserialize(type, value)
|
147
|
+
case type.to_sym
|
148
|
+
when :Time
|
149
|
+
Time.parse(value)
|
150
|
+
when :Date
|
151
|
+
Date.parse(value)
|
152
|
+
when :String
|
153
|
+
value.to_s
|
154
|
+
when :Integer
|
155
|
+
value.to_i
|
156
|
+
when :Float
|
157
|
+
value.to_f
|
158
|
+
when :Boolean
|
159
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
160
|
+
true
|
161
|
+
else
|
162
|
+
false
|
163
|
+
end
|
164
|
+
when :Object
|
165
|
+
# generic object (usually a Hash), return directly
|
166
|
+
value
|
167
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
168
|
+
inner_type = Regexp.last_match[:inner_type]
|
169
|
+
value.map { |v| _deserialize(inner_type, v) }
|
170
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
171
|
+
k_type = Regexp.last_match[:k_type]
|
172
|
+
v_type = Regexp.last_match[:v_type]
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each do |k, v|
|
175
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else # model
|
179
|
+
# models (e.g. Pet) or oneOf
|
180
|
+
klass = StackOneHrisClient.const_get(type)
|
181
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the string representation of the object
|
186
|
+
# @return [String] String presentation of the object
|
187
|
+
def to_s
|
188
|
+
to_hash.to_s
|
189
|
+
end
|
190
|
+
|
191
|
+
# to_body is an alias to to_hash (backward compatibility)
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_body
|
194
|
+
to_hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the object in the form of hash
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_hash
|
200
|
+
hash = {}
|
201
|
+
self.class.attribute_map.each_pair do |attr, param|
|
202
|
+
value = self.send(attr)
|
203
|
+
if value.nil?
|
204
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
205
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
206
|
+
end
|
207
|
+
|
208
|
+
hash[param] = _to_hash(value)
|
209
|
+
end
|
210
|
+
hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Outputs non-array value in the form of hash
|
214
|
+
# For object, use to_hash. Otherwise, just return the value
|
215
|
+
# @param [Object] value Any valid value
|
216
|
+
# @return [Hash] Returns the value in the form of hash
|
217
|
+
def _to_hash(value)
|
218
|
+
if value.is_a?(Array)
|
219
|
+
value.compact.map { |v| _to_hash(v) }
|
220
|
+
elsif value.is_a?(Hash)
|
221
|
+
{}.tap do |hash|
|
222
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
223
|
+
end
|
224
|
+
elsif value.respond_to? :to_hash
|
225
|
+
value.to_hash
|
226
|
+
else
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|