stackone_hris_client 1.0.0 → 1.2.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +42 -15
  4. data/docs/Account.md +32 -0
  5. data/docs/AccountsApi.md +218 -0
  6. data/docs/CompaniesApi.md +175 -0
  7. data/docs/CompaniesPaginated.md +22 -0
  8. data/docs/Company.md +22 -0
  9. data/docs/CompanyResult.md +20 -0
  10. data/docs/ConnectSession.md +34 -0
  11. data/docs/ConnectSessionAuthenticate.md +18 -0
  12. data/docs/ConnectSessionCreate.md +28 -0
  13. data/docs/ConnectSessionToken.md +36 -0
  14. data/docs/ConnectSessionsApi.md +145 -0
  15. data/docs/Employee.md +36 -12
  16. data/docs/EmployeeResult.md +2 -2
  17. data/docs/EmployeesApi.md +19 -13
  18. data/docs/EmployeesPaginated.md +2 -2
  19. data/docs/Employment.md +34 -0
  20. data/docs/EmploymentResult.md +20 -0
  21. data/docs/EmploymentsApi.md +175 -0
  22. data/docs/EmploymentsPaginated.md +22 -0
  23. data/docs/Location.md +38 -0
  24. data/docs/LocationResult.md +20 -0
  25. data/docs/LocationsApi.md +175 -0
  26. data/docs/LocationsPaginated.md +22 -0
  27. data/gem-config.yml +4 -4
  28. data/lib/stackone_hris_client/api/accounts_api.rb +205 -0
  29. data/lib/stackone_hris_client/api/companies_api.rb +188 -0
  30. data/lib/stackone_hris_client/api/connect_sessions_api.rb +154 -0
  31. data/lib/stackone_hris_client/api/employees_api.rb +10 -4
  32. data/lib/stackone_hris_client/api/employments_api.rb +188 -0
  33. data/lib/stackone_hris_client/api/locations_api.rb +188 -0
  34. data/lib/stackone_hris_client/api_client.rb +5 -5
  35. data/lib/stackone_hris_client/api_error.rb +4 -4
  36. data/lib/stackone_hris_client/configuration.rb +13 -12
  37. data/lib/stackone_hris_client/models/account.rb +322 -0
  38. data/lib/stackone_hris_client/models/companies_paginated.rb +249 -0
  39. data/lib/stackone_hris_client/models/company.rb +237 -0
  40. data/lib/stackone_hris_client/models/company_result.rb +233 -0
  41. data/lib/stackone_hris_client/models/connect_session.rb +350 -0
  42. data/lib/stackone_hris_client/models/connect_session_authenticate.rb +225 -0
  43. data/lib/stackone_hris_client/models/connect_session_create.rb +304 -0
  44. data/lib/stackone_hris_client/models/connect_session_token.rb +364 -0
  45. data/lib/stackone_hris_client/models/employee.rb +145 -60
  46. data/lib/stackone_hris_client/models/employee_result.rb +9 -7
  47. data/lib/stackone_hris_client/models/employees_paginated.rb +9 -7
  48. data/lib/stackone_hris_client/models/employment.rb +296 -0
  49. data/lib/stackone_hris_client/models/employment_result.rb +233 -0
  50. data/lib/stackone_hris_client/models/employments_paginated.rb +249 -0
  51. data/lib/stackone_hris_client/models/location.rb +314 -0
  52. data/lib/stackone_hris_client/models/location_result.rb +233 -0
  53. data/lib/stackone_hris_client/models/locations_paginated.rb +249 -0
  54. data/lib/stackone_hris_client/version.rb +5 -5
  55. data/lib/stackone_hris_client.rb +23 -4
  56. data/spec/api/accounts_api_spec.rb +58 -0
  57. data/spec/api/companies_api_spec.rb +70 -0
  58. data/spec/api/connect_sessions_api_spec.rb +57 -0
  59. data/spec/api/employments_api_spec.rb +70 -0
  60. data/spec/api/locations_api_spec.rb +70 -0
  61. data/spec/api_client_spec.rb +32 -32
  62. data/spec/configuration_spec.rb +6 -6
  63. data/spec/models/account_spec.rb +76 -0
  64. data/spec/models/companies_paginated_spec.rb +46 -0
  65. data/spec/models/company_result_spec.rb +40 -0
  66. data/spec/models/company_spec.rb +46 -0
  67. data/spec/models/connect_session_authenticate_spec.rb +34 -0
  68. data/spec/models/connect_session_create_spec.rb +68 -0
  69. data/spec/models/connect_session_spec.rb +86 -0
  70. data/spec/models/connect_session_token_spec.rb +92 -0
  71. data/spec/models/employment_result_spec.rb +40 -0
  72. data/spec/models/employment_spec.rb +82 -0
  73. data/spec/models/employments_paginated_spec.rb +46 -0
  74. data/spec/models/location_result_spec.rb +40 -0
  75. data/spec/models/location_spec.rb +94 -0
  76. data/spec/models/locations_paginated_spec.rb +46 -0
  77. data/spec/spec_helper.rb +3 -3
  78. data/stackone_hris_client.gemspec +5 -5
  79. metadata +79 -3
@@ -1,16 +1,16 @@
1
1
  =begin
2
- #StackOne Unified API
2
+ #StackOne Unified API - HRIS
3
3
 
4
- #The documentation for the StackOne Unified API
4
+ #The documentation for the StackOne Unified API - HRIS
5
5
 
6
- The version of the OpenAPI document: 1.0
6
+ The version of the OpenAPI document: 1.0.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 6.4.0
10
10
 
11
11
  =end
12
12
 
13
- module StackOneHrisClient
13
+ module StackOneHRIS
14
14
  class Configuration
15
15
  # Defines url scheme
16
16
  attr_accessor :scheme
@@ -147,12 +147,6 @@ module StackOneHrisClient
147
147
 
148
148
  attr_accessor :force_ending_format
149
149
 
150
- # Defines the region slug used to choose the API base url.
151
- # Default to eu1.
152
- #
153
- # @return [String]
154
- attr_accessor :region_slug
155
-
156
150
  def initialize
157
151
  @scheme = 'https'
158
152
  @host = 'stackone.com'
@@ -174,7 +168,6 @@ module StackOneHrisClient
174
168
  @debugging = false
175
169
  @inject_format = false
176
170
  @force_ending_format = false
177
- @region_slug = 'eu1'
178
171
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
179
172
 
180
173
  yield(self) if block_given?
@@ -205,8 +198,16 @@ module StackOneHrisClient
205
198
  @base_path = '' if @base_path == '/'
206
199
  end
207
200
 
201
+ def extract_region_slug_from_api_key_token
202
+ return nil if api_key_token.nil? || api_key_token.empty?
203
+
204
+ api_key_token.split('.')[1]
205
+ end
206
+
208
207
  def region_slug_subdomain
209
- return '' if region_slug.nil? || region_slug.empty?
208
+ region_slug = extract_region_slug_from_api_key_token
209
+
210
+ return '' if region_slug.nil? || region_slug.empty? || region_slug == 'dev'
210
211
 
211
212
  "api.#{region_slug}."
212
213
  end
@@ -0,0 +1,322 @@
1
+ =begin
2
+ #StackOne Unified API - HRIS
3
+
4
+ #The documentation for the StackOne Unified API - HRIS
5
+
6
+ The version of the OpenAPI document: 1.0.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 StackOneHRIS
17
+ class Account
18
+ attr_accessor :id
19
+
20
+ attr_accessor :provider
21
+
22
+ attr_accessor :origin_owner_id
23
+
24
+ attr_accessor :origin_owner_name
25
+
26
+ attr_accessor :origin_username
27
+
28
+ attr_accessor :credentials
29
+
30
+ attr_accessor :created_at
31
+
32
+ attr_accessor :updated_at
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'id' => :'id',
38
+ :'provider' => :'provider',
39
+ :'origin_owner_id' => :'origin_owner_id',
40
+ :'origin_owner_name' => :'origin_owner_name',
41
+ :'origin_username' => :'origin_username',
42
+ :'credentials' => :'credentials',
43
+ :'created_at' => :'created_at',
44
+ :'updated_at' => :'updated_at'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'id' => :'String',
57
+ :'provider' => :'String',
58
+ :'origin_owner_id' => :'String',
59
+ :'origin_owner_name' => :'String',
60
+ :'origin_username' => :'String',
61
+ :'credentials' => :'Object',
62
+ :'created_at' => :'Time',
63
+ :'updated_at' => :'Time'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHRIS::Account` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHRIS::Account`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'id')
89
+ self.id = attributes[:'id']
90
+ end
91
+
92
+ if attributes.key?(:'provider')
93
+ self.provider = attributes[:'provider']
94
+ end
95
+
96
+ if attributes.key?(:'origin_owner_id')
97
+ self.origin_owner_id = attributes[:'origin_owner_id']
98
+ end
99
+
100
+ if attributes.key?(:'origin_owner_name')
101
+ self.origin_owner_name = attributes[:'origin_owner_name']
102
+ end
103
+
104
+ if attributes.key?(:'origin_username')
105
+ self.origin_username = attributes[:'origin_username']
106
+ end
107
+
108
+ if attributes.key?(:'credentials')
109
+ self.credentials = attributes[:'credentials']
110
+ end
111
+
112
+ if attributes.key?(:'created_at')
113
+ self.created_at = attributes[:'created_at']
114
+ end
115
+
116
+ if attributes.key?(:'updated_at')
117
+ self.updated_at = attributes[:'updated_at']
118
+ end
119
+ end
120
+
121
+ # Show invalid properties with the reasons. Usually used together with valid?
122
+ # @return Array for valid properties with the reasons
123
+ def list_invalid_properties
124
+ invalid_properties = Array.new
125
+ if @id.nil?
126
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
127
+ end
128
+
129
+ if @provider.nil?
130
+ invalid_properties.push('invalid value for "provider", provider cannot be nil.')
131
+ end
132
+
133
+ if @origin_owner_id.nil?
134
+ invalid_properties.push('invalid value for "origin_owner_id", origin_owner_id cannot be nil.')
135
+ end
136
+
137
+ if @origin_owner_name.nil?
138
+ invalid_properties.push('invalid value for "origin_owner_name", origin_owner_name cannot be nil.')
139
+ end
140
+
141
+ if @origin_username.nil?
142
+ invalid_properties.push('invalid value for "origin_username", origin_username cannot be nil.')
143
+ end
144
+
145
+ if @credentials.nil?
146
+ invalid_properties.push('invalid value for "credentials", credentials cannot be nil.')
147
+ end
148
+
149
+ if @created_at.nil?
150
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
151
+ end
152
+
153
+ if @updated_at.nil?
154
+ invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
155
+ end
156
+
157
+ 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
+ return false if @id.nil?
164
+ return false if @provider.nil?
165
+ return false if @origin_owner_id.nil?
166
+ return false if @origin_owner_name.nil?
167
+ return false if @origin_username.nil?
168
+ return false if @credentials.nil?
169
+ return false if @created_at.nil?
170
+ return false if @updated_at.nil?
171
+ true
172
+ end
173
+
174
+ # Checks equality by comparing each attribute.
175
+ # @param [Object] Object to be compared
176
+ def ==(o)
177
+ return true if self.equal?(o)
178
+ self.class == o.class &&
179
+ id == o.id &&
180
+ provider == o.provider &&
181
+ origin_owner_id == o.origin_owner_id &&
182
+ origin_owner_name == o.origin_owner_name &&
183
+ origin_username == o.origin_username &&
184
+ credentials == o.credentials &&
185
+ created_at == o.created_at &&
186
+ updated_at == o.updated_at
187
+ end
188
+
189
+ # @see the `==` method
190
+ # @param [Object] Object to be compared
191
+ def eql?(o)
192
+ self == o
193
+ end
194
+
195
+ # Calculates hash code according to all attributes.
196
+ # @return [Integer] Hash code
197
+ def hash
198
+ [id, provider, origin_owner_id, origin_owner_name, origin_username, credentials, created_at, updated_at].hash
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def self.build_from_hash(attributes)
205
+ new.build_from_hash(attributes)
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def build_from_hash(attributes)
212
+ return nil unless attributes.is_a?(Hash)
213
+ attributes = attributes.transform_keys(&:to_sym)
214
+ self.class.openapi_types.each_pair do |key, type|
215
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
216
+ self.send("#{key}=", nil)
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
221
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
222
+ end
223
+ elsif !attributes[self.class.attribute_map[key]].nil?
224
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
225
+ end
226
+ end
227
+
228
+ self
229
+ end
230
+
231
+ # Deserializes the data based on type
232
+ # @param string type Data type
233
+ # @param string value Value to be deserialized
234
+ # @return [Object] Deserialized data
235
+ def _deserialize(type, value)
236
+ case type.to_sym
237
+ when :Time
238
+ Time.parse(value)
239
+ when :Date
240
+ Date.parse(value)
241
+ when :String
242
+ value.to_s
243
+ when :Integer
244
+ value.to_i
245
+ when :Float
246
+ value.to_f
247
+ when :Boolean
248
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
249
+ true
250
+ else
251
+ false
252
+ end
253
+ when :Object
254
+ # generic object (usually a Hash), return directly
255
+ value
256
+ when /\AArray<(?<inner_type>.+)>\z/
257
+ inner_type = Regexp.last_match[:inner_type]
258
+ value.map { |v| _deserialize(inner_type, v) }
259
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
260
+ k_type = Regexp.last_match[:k_type]
261
+ v_type = Regexp.last_match[:v_type]
262
+ {}.tap do |hash|
263
+ value.each do |k, v|
264
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
265
+ end
266
+ end
267
+ else # model
268
+ # models (e.g. Pet) or oneOf
269
+ klass = StackOneHRIS.const_get(type)
270
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ if value.nil?
293
+ is_nullable = self.class.openapi_nullable.include?(attr)
294
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
295
+ end
296
+
297
+ hash[param] = _to_hash(value)
298
+ end
299
+ hash
300
+ end
301
+
302
+ # Outputs non-array value in the form of hash
303
+ # For object, use to_hash. Otherwise, just return the value
304
+ # @param [Object] value Any valid value
305
+ # @return [Hash] Returns the value in the form of hash
306
+ def _to_hash(value)
307
+ if value.is_a?(Array)
308
+ value.compact.map { |v| _to_hash(v) }
309
+ elsif value.is_a?(Hash)
310
+ {}.tap do |hash|
311
+ value.each { |k, v| hash[k] = _to_hash(v) }
312
+ end
313
+ elsif value.respond_to? :to_hash
314
+ value.to_hash
315
+ else
316
+ value
317
+ end
318
+ end
319
+
320
+ end
321
+
322
+ end
@@ -0,0 +1,249 @@
1
+ =begin
2
+ #StackOne Unified API - HRIS
3
+
4
+ #The documentation for the StackOne Unified API - HRIS
5
+
6
+ The version of the OpenAPI document: 1.0.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 StackOneHRIS
17
+ class CompaniesPaginated
18
+ attr_accessor :next_page
19
+
20
+ attr_accessor :data
21
+
22
+ attr_accessor :raw
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'next_page' => :'next_page',
28
+ :'data' => :'data',
29
+ :'raw' => :'raw'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'next_page' => :'String',
42
+ :'data' => :'Array<Company>',
43
+ :'raw' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHRIS::CompaniesPaginated` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHRIS::CompaniesPaginated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'next_page')
69
+ self.next_page = attributes[:'next_page']
70
+ end
71
+
72
+ if attributes.key?(:'data')
73
+ if (value = attributes[:'data']).is_a?(Array)
74
+ self.data = value
75
+ end
76
+ end
77
+
78
+ if attributes.key?(:'raw')
79
+ self.raw = attributes[:'raw']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @next_page.nil?
88
+ invalid_properties.push('invalid value for "next_page", next_page cannot be nil.')
89
+ end
90
+
91
+ if @data.nil?
92
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
93
+ end
94
+
95
+ invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ return false if @next_page.nil?
102
+ return false if @data.nil?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ next_page == o.next_page &&
112
+ data == o.data &&
113
+ raw == o.raw
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [next_page, data, raw].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ new.build_from_hash(attributes)
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ attributes = attributes.transform_keys(&:to_sym)
141
+ self.class.openapi_types.each_pair do |key, type|
142
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
143
+ self.send("#{key}=", nil)
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = StackOneHRIS.const_get(type)
197
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end