stackone_hris_client 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +31 -5
  4. data/docs/Account.md +1 -1
  5. data/docs/AccountMeta.md +22 -0
  6. data/docs/AccountsApi.md +70 -2
  7. data/docs/CompaniesApi.md +1 -1
  8. data/docs/ConnectSessionsApi.md +1 -1
  9. data/docs/CreateEmployeeResult.md +22 -0
  10. data/docs/Employee.md +56 -54
  11. data/docs/EmployeeApiModel.md +80 -0
  12. data/docs/EmployeeApiModelAvatar.md +20 -0
  13. data/docs/EmployeeApiModelEmploymentStatus.md +20 -0
  14. data/docs/EmployeeApiModelEmploymentType.md +20 -0
  15. data/docs/EmployeeApiModelEthnicity.md +20 -0
  16. data/docs/EmployeeApiModelGender.md +20 -0
  17. data/docs/EmployeeApiModelHomeLocation.md +38 -0
  18. data/docs/EmployeeApiModelMaritalStatus.md +20 -0
  19. data/docs/EmployeeApiModelWorkLocation.md +38 -0
  20. data/docs/EmployeeCustomFieldTypeEnum.md +20 -0
  21. data/docs/EmployeeCustomFields.md +30 -0
  22. data/docs/EmployeeCustomFieldsType.md +20 -0
  23. data/docs/EmployeeResult.md +1 -1
  24. data/docs/EmployeesApi.md +219 -5
  25. data/docs/EmployeesPaginated.md +1 -1
  26. data/docs/Employment.md +17 -15
  27. data/docs/EmploymentEmploymentContractType.md +20 -0
  28. data/docs/EmploymentEmploymentType.md +20 -0
  29. data/docs/EmploymentPayFrequency.md +20 -0
  30. data/docs/EmploymentPayPeriod.md +20 -0
  31. data/docs/EmploymentScheduleTypeEnum.md +20 -0
  32. data/docs/EmploymentsApi.md +3 -3
  33. data/docs/HrisCreateEmployeeRequestDto.md +80 -0
  34. data/docs/Location.md +20 -20
  35. data/docs/LocationCountry.md +20 -0
  36. data/docs/LocationLocationType.md +20 -0
  37. data/docs/LocationsApi.md +1 -1
  38. data/gem-config.yml +2 -2
  39. data/generate_gem.sh +0 -0
  40. data/lib/stackone_hris_client/api/accounts_api.rb +61 -0
  41. data/lib/stackone_hris_client/api/employees_api.rb +231 -0
  42. data/lib/stackone_hris_client/models/account.rb +0 -5
  43. data/lib/stackone_hris_client/models/account_meta.rb +284 -0
  44. data/lib/stackone_hris_client/models/country_code_enum.rb +0 -6
  45. data/lib/stackone_hris_client/models/create_employee_result.rb +250 -0
  46. data/lib/stackone_hris_client/models/employee.rb +110 -126
  47. data/lib/stackone_hris_client/models/employee_api_model.rb +523 -0
  48. data/lib/stackone_hris_client/models/employee_api_model_avatar.rb +234 -0
  49. data/lib/stackone_hris_client/models/employee_api_model_employment_status.rb +272 -0
  50. data/lib/stackone_hris_client/models/employee_api_model_employment_type.rb +272 -0
  51. data/lib/stackone_hris_client/models/employee_api_model_ethnicity.rb +272 -0
  52. data/lib/stackone_hris_client/models/employee_api_model_gender.rb +272 -0
  53. data/lib/stackone_hris_client/models/employee_api_model_home_location.rb +324 -0
  54. data/lib/stackone_hris_client/models/employee_api_model_marital_status.rb +272 -0
  55. data/lib/stackone_hris_client/models/employee_api_model_work_location.rb +324 -0
  56. data/lib/stackone_hris_client/models/employee_custom_field_type_enum.rb +264 -0
  57. data/lib/stackone_hris_client/models/employee_custom_fields.rb +279 -0
  58. data/lib/stackone_hris_client/models/employee_custom_fields_type.rb +272 -0
  59. data/lib/stackone_hris_client/models/employment.rb +21 -6
  60. data/lib/stackone_hris_client/models/employment_employment_contract_type.rb +272 -0
  61. data/lib/stackone_hris_client/models/employment_employment_type.rb +272 -0
  62. data/lib/stackone_hris_client/models/employment_pay_frequency.rb +272 -0
  63. data/lib/stackone_hris_client/models/employment_pay_period.rb +272 -0
  64. data/lib/stackone_hris_client/models/employment_schedule_type_enum.rb +264 -0
  65. data/lib/stackone_hris_client/models/employment_status_enum.rb +0 -6
  66. data/lib/stackone_hris_client/models/employment_type_enum.rb +0 -6
  67. data/lib/stackone_hris_client/models/ethnicity_enum.rb +0 -6
  68. data/lib/stackone_hris_client/models/gender_enum.rb +0 -6
  69. data/lib/stackone_hris_client/models/hris_create_employee_request_dto.rb +523 -0
  70. data/lib/stackone_hris_client/models/location.rb +11 -7
  71. data/lib/stackone_hris_client/models/location_country.rb +272 -0
  72. data/lib/stackone_hris_client/models/location_location_type.rb +272 -0
  73. data/lib/stackone_hris_client/models/location_type_enum.rb +0 -6
  74. data/lib/stackone_hris_client/models/marital_status_enum.rb +0 -6
  75. data/lib/stackone_hris_client/models/pay_frequency_enum.rb +0 -6
  76. data/lib/stackone_hris_client/models/pay_period_enum.rb +0 -6
  77. data/lib/stackone_hris_client/version.rb +1 -1
  78. data/lib/stackone_hris_client.rb +22 -0
  79. data/spec/api/accounts_api_spec.rb +30 -8
  80. data/spec/api/companies_api_spec.rb +13 -13
  81. data/spec/api/connect_sessions_api_spec.rb +8 -8
  82. data/spec/api/employees_api_spec.rb +60 -18
  83. data/spec/api/employments_api_spec.rb +13 -13
  84. data/spec/api/locations_api_spec.rb +9 -9
  85. data/spec/models/account_meta_spec.rb +50 -0
  86. data/spec/models/account_spec.rb +18 -12
  87. data/spec/models/companies_paginated_spec.rb +4 -4
  88. data/spec/models/company_result_spec.rb +3 -3
  89. data/spec/models/company_spec.rb +4 -4
  90. data/spec/models/connect_session_authenticate_spec.rb +5 -5
  91. data/spec/models/connect_session_create_spec.rb +17 -11
  92. data/spec/models/connect_session_spec.rb +14 -14
  93. data/spec/models/connect_session_token_spec.rb +15 -15
  94. data/spec/models/country_code_enum_spec.rb +4 -4
  95. data/spec/models/create_employee_result_spec.rb +46 -0
  96. data/spec/models/employee.rb +220 -0
  97. data/spec/models/employee_api_model_avatar_spec.rb +40 -0
  98. data/spec/models/employee_api_model_employment_status_spec.rb +44 -0
  99. data/spec/models/employee_api_model_employment_type_spec.rb +44 -0
  100. data/spec/models/employee_api_model_ethnicity_spec.rb +44 -0
  101. data/spec/models/employee_api_model_gender_spec.rb +44 -0
  102. data/spec/models/employee_api_model_home_location_spec.rb +94 -0
  103. data/spec/models/employee_api_model_marital_status_spec.rb +44 -0
  104. data/spec/models/employee_api_model_spec.rb +220 -0
  105. data/spec/models/employee_api_model_work_location_spec.rb +94 -0
  106. data/spec/models/employee_custom_field_type_enum_spec.rb +44 -0
  107. data/spec/models/employee_custom_fields_spec.rb +70 -0
  108. data/spec/models/employee_custom_fields_type_spec.rb +44 -0
  109. data/spec/models/employee_result_spec.rb +6 -6
  110. data/spec/models/employees_paginated_spec.rb +7 -7
  111. data/spec/models/employment_employment_contract_type_spec.rb +44 -0
  112. data/spec/models/employment_employment_type_spec.rb +44 -0
  113. data/spec/models/employment_pay_frequency_spec.rb +44 -0
  114. data/spec/models/employment_pay_period_spec.rb +44 -0
  115. data/spec/models/employment_result_spec.rb +3 -3
  116. data/spec/models/employment_schedule_type_enum_spec.rb +44 -0
  117. data/spec/models/employment_spec.rb +16 -10
  118. data/spec/models/employment_status_enum_spec.rb +4 -4
  119. data/spec/models/employment_type_enum_spec.rb +4 -4
  120. data/spec/models/employments_paginated_spec.rb +4 -4
  121. data/spec/models/ethnicity_enum_spec.rb +4 -4
  122. data/spec/models/gender_enum_spec.rb +4 -4
  123. data/spec/models/hris_create_employee_request_dto_spec.rb +220 -0
  124. data/spec/models/image_spec.rb +3 -3
  125. data/spec/models/location_country_spec.rb +44 -0
  126. data/spec/models/location_location_type_spec.rb +44 -0
  127. data/spec/models/location_result_spec.rb +3 -3
  128. data/spec/models/location_spec.rb +12 -12
  129. data/spec/models/location_type_enum_spec.rb +3 -3
  130. data/spec/models/locations_paginated_spec.rb +4 -4
  131. data/spec/models/marital_status_enum_spec.rb +4 -4
  132. data/spec/models/pay_frequency_enum_spec.rb +4 -4
  133. data/spec/models/pay_period_enum_spec.rb +3 -3
  134. metadata +92 -4
  135. data/spec/models/employee_spec.rb +0 -124
@@ -0,0 +1,272 @@
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.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module StackOneHRIS
17
+ # The employee employment type
18
+ class EmployeeApiModelEmploymentType
19
+ attr_accessor :value
20
+
21
+ attr_accessor :source_value
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'value' => :'value',
49
+ :'source_value' => :'source_value'
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'value' => :'String',
62
+ :'source_value' => :'String'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ ])
70
+ end
71
+
72
+ # List of class defined in allOf (OpenAPI v3)
73
+ def self.openapi_all_of
74
+ [
75
+ :'EmploymentTypeEnum'
76
+ ]
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHRIS::EmployeeApiModelEmploymentType` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHRIS::EmployeeApiModelEmploymentType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'value')
95
+ self.value = attributes[:'value']
96
+ end
97
+
98
+ if attributes.key?(:'source_value')
99
+ self.source_value = attributes[:'source_value']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ if @value.nil?
108
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
109
+ end
110
+
111
+ if @source_value.nil?
112
+ invalid_properties.push('invalid value for "source_value", source_value cannot be nil.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @value.nil?
122
+ return false if @source_value.nil?
123
+ true
124
+ end
125
+
126
+ # Custom attribute writer method checking allowed values (enum).
127
+ # @param [Object] value Object to be assigned
128
+ def value=(value)
129
+ @value = value
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ value == o.value &&
138
+ source_value == o.source_value
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [value, source_value].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ new.build_from_hash(attributes)
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ attributes = attributes.transform_keys(&:to_sym)
166
+ self.class.openapi_types.each_pair do |key, type|
167
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
168
+ self.send("#{key}=", nil)
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = StackOneHRIS.const_get(type)
222
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+ end
272
+ end
@@ -0,0 +1,272 @@
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.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module StackOneHRIS
17
+ # The employee ethnicity
18
+ class EmployeeApiModelEthnicity
19
+ attr_accessor :value
20
+
21
+ attr_accessor :source_value
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'value' => :'value',
49
+ :'source_value' => :'source_value'
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'value' => :'String',
62
+ :'source_value' => :'String'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ ])
70
+ end
71
+
72
+ # List of class defined in allOf (OpenAPI v3)
73
+ def self.openapi_all_of
74
+ [
75
+ :'EthnicityEnum'
76
+ ]
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ if (!attributes.is_a?(Hash))
83
+ fail ArgumentError, "The input argument (attributes) must be a hash in `StackOneHRIS::EmployeeApiModelEthnicity` initialize method"
84
+ end
85
+
86
+ # check to see if the attribute exists and convert string to symbol for hash key
87
+ attributes = attributes.each_with_object({}) { |(k, v), h|
88
+ if (!self.class.attribute_map.key?(k.to_sym))
89
+ fail ArgumentError, "`#{k}` is not a valid attribute in `StackOneHRIS::EmployeeApiModelEthnicity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
+ end
91
+ h[k.to_sym] = v
92
+ }
93
+
94
+ if attributes.key?(:'value')
95
+ self.value = attributes[:'value']
96
+ end
97
+
98
+ if attributes.key?(:'source_value')
99
+ self.source_value = attributes[:'source_value']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ if @value.nil?
108
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
109
+ end
110
+
111
+ if @source_value.nil?
112
+ invalid_properties.push('invalid value for "source_value", source_value cannot be nil.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @value.nil?
122
+ return false if @source_value.nil?
123
+ true
124
+ end
125
+
126
+ # Custom attribute writer method checking allowed values (enum).
127
+ # @param [Object] value Object to be assigned
128
+ def value=(value)
129
+ @value = value
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ value == o.value &&
138
+ source_value == o.source_value
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [value, source_value].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ new.build_from_hash(attributes)
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ attributes = attributes.transform_keys(&:to_sym)
166
+ self.class.openapi_types.each_pair do |key, type|
167
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
168
+ self.send("#{key}=", nil)
169
+ elsif type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = StackOneHRIS.const_get(type)
222
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+ end
272
+ end