merge_hris_client 2.0.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/docs/BankInfo.md +3 -1
  4. data/docs/BankInfoApi.md +7 -3
  5. data/docs/Benefit.md +3 -1
  6. data/docs/BenefitsApi.md +2 -2
  7. data/docs/CompaniesApi.md +2 -2
  8. data/docs/Company.md +3 -1
  9. data/docs/DataPassthroughRequest.md +3 -1
  10. data/docs/Deduction.md +3 -1
  11. data/docs/DeductionsApi.md +2 -2
  12. data/docs/Earning.md +4 -2
  13. data/docs/Employee.md +3 -1
  14. data/docs/EmployeePayrollRun.md +3 -1
  15. data/docs/EmployeePayrollRunsApi.md +2 -2
  16. data/docs/EmployeesApi.md +15 -3
  17. data/docs/Employment.md +4 -2
  18. data/docs/EmploymentsApi.md +7 -3
  19. data/docs/EndUserDetailsRequest.md +1 -1
  20. data/docs/ForceResyncApi.md +4 -4
  21. data/docs/Group.md +3 -1
  22. data/docs/GroupsApi.md +7 -3
  23. data/docs/LinkedAccountsApi.md +14 -14
  24. data/docs/Location.md +4 -2
  25. data/docs/LocationsApi.md +7 -3
  26. data/docs/PayGroup.md +3 -1
  27. data/docs/PayGroupsApi.md +2 -2
  28. data/docs/PayrollRun.md +3 -1
  29. data/docs/PayrollRunsApi.md +7 -3
  30. data/docs/RemoteResponse.md +2 -0
  31. data/docs/Tax.md +4 -2
  32. data/docs/Team.md +3 -1
  33. data/docs/TeamsApi.md +2 -2
  34. data/docs/TimeOff.md +3 -1
  35. data/docs/TimeOffApi.md +7 -3
  36. data/docs/TimeOffBalance.md +3 -1
  37. data/docs/TimeOffBalancesApi.md +7 -3
  38. data/lib/merge_hris_client/api/bank_info_api.rb +16 -3
  39. data/lib/merge_hris_client/api/benefits_api.rb +2 -2
  40. data/lib/merge_hris_client/api/companies_api.rb +2 -2
  41. data/lib/merge_hris_client/api/deductions_api.rb +2 -2
  42. data/lib/merge_hris_client/api/employee_payroll_runs_api.rb +2 -2
  43. data/lib/merge_hris_client/api/employees_api.rb +32 -2
  44. data/lib/merge_hris_client/api/employments_api.rb +16 -2
  45. data/lib/merge_hris_client/api/force_resync_api.rb +3 -3
  46. data/lib/merge_hris_client/api/groups_api.rb +16 -2
  47. data/lib/merge_hris_client/api/linked_accounts_api.rb +14 -14
  48. data/lib/merge_hris_client/api/locations_api.rb +16 -2
  49. data/lib/merge_hris_client/api/pay_groups_api.rb +2 -2
  50. data/lib/merge_hris_client/api/payroll_runs_api.rb +16 -2
  51. data/lib/merge_hris_client/api/teams_api.rb +2 -2
  52. data/lib/merge_hris_client/api/time_off_api.rb +16 -2
  53. data/lib/merge_hris_client/api/time_off_balances_api.rb +16 -2
  54. data/lib/merge_hris_client/api/webhook_receivers_api.rb +154 -0
  55. data/lib/merge_hris_client/models/account_details_and_actions_status_enum.rb +0 -1
  56. data/lib/merge_hris_client/models/account_type_enum.rb +0 -1
  57. data/lib/merge_hris_client/models/bank_info.rb +15 -5
  58. data/lib/merge_hris_client/models/benefit.rb +15 -5
  59. data/lib/merge_hris_client/models/categories_enum.rb +2 -1
  60. data/lib/merge_hris_client/models/category_enum.rb +2 -1
  61. data/lib/merge_hris_client/models/company.rb +15 -5
  62. data/lib/merge_hris_client/models/country_enum.rb +0 -1
  63. data/lib/merge_hris_client/models/data_passthrough_request.rb +14 -5
  64. data/lib/merge_hris_client/models/deduction.rb +15 -5
  65. data/lib/merge_hris_client/models/earning.rb +18 -6
  66. data/lib/merge_hris_client/models/earning_type_enum.rb +0 -1
  67. data/lib/merge_hris_client/models/employee.rb +14 -5
  68. data/lib/merge_hris_client/models/employee_payroll_run.rb +15 -5
  69. data/lib/merge_hris_client/models/employment.rb +15 -5
  70. data/lib/merge_hris_client/models/employment_status_enum.rb +0 -1
  71. data/lib/merge_hris_client/models/employment_type_enum.rb +0 -1
  72. data/lib/merge_hris_client/models/encoding_enum.rb +1 -1
  73. data/lib/merge_hris_client/models/ethnicity_enum.rb +0 -1
  74. data/lib/merge_hris_client/models/flsa_status_enum.rb +0 -1
  75. data/lib/merge_hris_client/models/gender_enum.rb +0 -1
  76. data/lib/merge_hris_client/models/group.rb +15 -5
  77. data/lib/merge_hris_client/models/group_type_enum.rb +0 -1
  78. data/lib/merge_hris_client/models/issue_status_enum.rb +0 -1
  79. data/lib/merge_hris_client/models/location.rb +15 -5
  80. data/lib/merge_hris_client/models/location_type_enum.rb +0 -1
  81. data/lib/merge_hris_client/models/marital_status_enum.rb +0 -1
  82. data/lib/merge_hris_client/models/method_enum.rb +0 -1
  83. data/lib/merge_hris_client/models/pay_currency_enum.rb +0 -1
  84. data/lib/merge_hris_client/models/pay_frequency_enum.rb +0 -1
  85. data/lib/merge_hris_client/models/pay_group.rb +15 -5
  86. data/lib/merge_hris_client/models/pay_period_enum.rb +0 -1
  87. data/lib/merge_hris_client/models/payroll_run.rb +15 -5
  88. data/lib/merge_hris_client/models/policy_type_enum.rb +0 -1
  89. data/lib/merge_hris_client/models/reason_enum.rb +0 -1
  90. data/lib/merge_hris_client/models/remote_response.rb +13 -2
  91. data/lib/merge_hris_client/models/request_format_enum.rb +0 -1
  92. data/lib/merge_hris_client/models/request_type_enum.rb +0 -1
  93. data/lib/merge_hris_client/models/run_state_enum.rb +0 -1
  94. data/lib/merge_hris_client/models/run_type_enum.rb +0 -1
  95. data/lib/merge_hris_client/models/sync_status_status_enum.rb +0 -1
  96. data/lib/merge_hris_client/models/tax.rb +18 -6
  97. data/lib/merge_hris_client/models/team.rb +15 -5
  98. data/lib/merge_hris_client/models/time_off.rb +14 -5
  99. data/lib/merge_hris_client/models/time_off_balance.rb +15 -5
  100. data/lib/merge_hris_client/models/time_off_status_enum.rb +0 -1
  101. data/lib/merge_hris_client/models/units_enum.rb +0 -1
  102. data/lib/merge_hris_client/version.rb +1 -1
  103. data/spec/api/bank_info_api_spec.rb +3 -1
  104. data/spec/api/benefits_api_spec.rb +1 -1
  105. data/spec/api/companies_api_spec.rb +1 -1
  106. data/spec/api/deductions_api_spec.rb +1 -1
  107. data/spec/api/employee_payroll_runs_api_spec.rb +1 -1
  108. data/spec/api/employees_api_spec.rb +7 -1
  109. data/spec/api/employments_api_spec.rb +3 -1
  110. data/spec/api/force_resync_api_spec.rb +1 -1
  111. data/spec/api/groups_api_spec.rb +3 -1
  112. data/spec/api/linked_accounts_api_spec.rb +7 -7
  113. data/spec/api/locations_api_spec.rb +3 -1
  114. data/spec/api/pay_groups_api_spec.rb +1 -1
  115. data/spec/api/payroll_runs_api_spec.rb +3 -1
  116. data/spec/api/teams_api_spec.rb +1 -1
  117. data/spec/api/time_off_api_spec.rb +3 -1
  118. data/spec/api/time_off_balances_api_spec.rb +3 -1
  119. data/spec/api/webhook_receivers_api_spec.rb +58 -0
  120. data/spec/models/bank_info_spec.rb +1 -1
  121. data/spec/models/benefit_spec.rb +1 -1
  122. data/spec/models/company_spec.rb +1 -1
  123. data/spec/models/data_passthrough_request_spec.rb +6 -0
  124. data/spec/models/deduction_spec.rb +1 -1
  125. data/spec/models/earning_spec.rb +1 -1
  126. data/spec/models/employee_payroll_run_spec.rb +1 -1
  127. data/spec/models/employee_spec.rb +2 -2
  128. data/spec/models/employment_spec.rb +1 -1
  129. data/spec/models/group_spec.rb +1 -1
  130. data/spec/models/linked_account_status_spec.rb +40 -0
  131. data/spec/models/location_spec.rb +1 -1
  132. data/spec/models/meta_response_spec.rb +52 -0
  133. data/spec/models/pay_group_spec.rb +1 -1
  134. data/spec/models/payroll_run_spec.rb +1 -1
  135. data/spec/models/remote_response_spec.rb +6 -0
  136. data/spec/models/tax_spec.rb +1 -1
  137. data/spec/models/team_spec.rb +1 -1
  138. data/spec/models/time_off_balance_spec.rb +1 -1
  139. data/spec/models/time_off_spec.rb +1 -1
  140. data/spec/models/webhook_receiver_request_spec.rb +46 -0
  141. data/spec/models/webhook_receiver_spec.rb +46 -0
  142. metadata +105 -107
  143. data/docs/BenefitPlanTypeEnum.md +0 -15
  144. data/docs/TypeEnum.md +0 -15
  145. data/lib/merge_hris_client/api/time_off_balance_api.rb +0 -196
  146. data/lib/merge_hris_client/models/benefit_plan_type_enum.rb +0 -56
  147. data/lib/merge_hris_client/models/data_passthrough.rb +0 -262
  148. data/lib/merge_hris_client/models/end_user_details.rb +0 -289
  149. data/lib/merge_hris_client/models/remote_key_for_regeneration.rb +0 -224
  150. data/lib/merge_hris_client/models/state_enum.rb +0 -93
  151. data/lib/merge_hris_client/models/type_enum.rb +0 -38
  152. data/spec/models/benefit_plan_type_enum_spec.rb +0 -28
  153. data/spec/models/type_enum_spec.rb +0 -28
@@ -1,262 +0,0 @@
1
- =begin
2
- #Merge HRIS API
3
-
4
- #The unified API for building rich integrations with multiple HR Information System platforms.
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: hello@merge.dev
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.0.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module MergeHRISClient
17
- # # The DataPassthrough Object ### Description The `DataPassthrough` object is used to send information to an otherwise-unsupported third-party endpoint. ### Usage Example Create a `DataPassthrough` to get team hierarchies from your Rippling integration.
18
- class DataPassthrough
19
- attr_accessor :method
20
-
21
- attr_accessor :path
22
-
23
- attr_accessor :data
24
-
25
- attr_accessor :headers
26
-
27
- # Attribute mapping from ruby-style variable name to JSON key.
28
- def self.attribute_map
29
- {
30
- :'method' => :'method',
31
- :'path' => :'path',
32
- :'data' => :'data',
33
- :'headers' => :'headers'
34
- }
35
- end
36
-
37
- # Returns all the JSON keys this model knows about
38
- def self.acceptable_attributes
39
- attribute_map.values
40
- end
41
-
42
- # Attribute type mapping.
43
- def self.openapi_types
44
- {
45
- :'method' => :'MethodEnum',
46
- :'path' => :'String',
47
- :'data' => :'Hash<String, AnyType>',
48
- :'headers' => :'Hash<String, AnyType>'
49
- }
50
- end
51
-
52
- # List of attributes with nullable: true
53
- def self.openapi_nullable
54
- Set.new([
55
- :'data',
56
- :'headers'
57
- ])
58
- end
59
-
60
- # Initializes the object
61
- # @param [Hash] attributes Model attributes in the form of hash
62
- def initialize(attributes = {})
63
- if (!attributes.is_a?(Hash))
64
- fail ArgumentError, "The input argument (attributes) must be a hash in `MergeHRISClient::DataPassthrough` initialize method"
65
- end
66
-
67
- # check to see if the attribute exists and convert string to symbol for hash key
68
- attributes = attributes.each_with_object({}) { |(k, v), h|
69
- if (!self.class.attribute_map.key?(k.to_sym))
70
- fail ArgumentError, "`#{k}` is not a valid attribute in `MergeHRISClient::DataPassthrough`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
- end
72
- h[k.to_sym] = v
73
- }
74
-
75
- if attributes.key?(:'method')
76
- self.method = attributes[:'method']
77
- end
78
-
79
- if attributes.key?(:'path')
80
- self.path = attributes[:'path']
81
- end
82
-
83
- if attributes.key?(:'data')
84
- if (value = attributes[:'data']).is_a?(Hash)
85
- self.data = value
86
- end
87
- end
88
-
89
- if attributes.key?(:'headers')
90
- if (value = attributes[:'headers']).is_a?(Hash)
91
- self.headers = value
92
- end
93
- end
94
- end
95
-
96
- # Show invalid properties with the reasons. Usually used together with valid?
97
- # @return Array for valid properties with the reasons
98
- def list_invalid_properties
99
- invalid_properties = Array.new
100
- if @method.nil?
101
- invalid_properties.push('invalid value for "method", method cannot be nil.')
102
- end
103
-
104
- if @path.nil?
105
- invalid_properties.push('invalid value for "path", path cannot be nil.')
106
- end
107
-
108
- invalid_properties
109
- end
110
-
111
- # Check to see if the all the properties in the model are valid
112
- # @return true if the model is valid
113
- def valid?
114
- return false if @method.nil?
115
- return false if @path.nil?
116
- true
117
- end
118
-
119
- # Checks equality by comparing each attribute.
120
- # @param [Object] Object to be compared
121
- def ==(o)
122
- return true if self.equal?(o)
123
- self.class == o.class &&
124
- method == o.method &&
125
- path == o.path &&
126
- data == o.data &&
127
- headers == o.headers
128
- end
129
-
130
- # @see the `==` method
131
- # @param [Object] Object to be compared
132
- def eql?(o)
133
- self == o
134
- end
135
-
136
- # Calculates hash code according to all attributes.
137
- # @return [Integer] Hash code
138
- def hash
139
- [method, path, data, headers].hash
140
- end
141
-
142
- # Builds the object from hash
143
- # @param [Hash] attributes Model attributes in the form of hash
144
- # @return [Object] Returns the model itself
145
- def self.build_from_hash(attributes)
146
- new.build_from_hash(attributes)
147
- end
148
-
149
- # Builds the object from hash
150
- # @param [Hash] attributes Model attributes in the form of hash
151
- # @return [Object] Returns the model itself
152
- def build_from_hash(attributes)
153
- return nil unless attributes.is_a?(Hash)
154
- self.class.openapi_types.each_pair do |key, type|
155
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
156
- self.send("#{key}=", nil)
157
- elsif type =~ /\AArray<(.*)>/i
158
- # check to ensure the input is an array given that the attribute
159
- # is documented as an array but the input is not
160
- if attributes[self.class.attribute_map[key]].is_a?(Array)
161
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
162
- end
163
- elsif !attributes[self.class.attribute_map[key]].nil?
164
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
165
- end
166
- end
167
-
168
- self
169
- end
170
-
171
- # Deserializes the data based on type
172
- # @param string type Data type
173
- # @param string value Value to be deserialized
174
- # @return [Object] Deserialized data
175
- def _deserialize(type, value)
176
- case type.to_sym
177
- when :Time
178
- Time.parse(value)
179
- when :Date
180
- Date.parse(value)
181
- when :String
182
- value.to_s
183
- when :Integer
184
- value.to_i
185
- when :Float
186
- value.to_f
187
- when :Boolean
188
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
- true
190
- else
191
- false
192
- end
193
- when :Object
194
- # generic object (usually a Hash), return directly
195
- value
196
- when /\AArray<(?<inner_type>.+)>\z/
197
- inner_type = Regexp.last_match[:inner_type]
198
- value.map { |v| _deserialize(inner_type, v) }
199
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
- k_type = Regexp.last_match[:k_type]
201
- v_type = Regexp.last_match[:v_type]
202
- {}.tap do |hash|
203
- value.each do |k, v|
204
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
- end
206
- end
207
- else # model
208
- # models (e.g. Pet) or oneOf
209
- klass = MergeHRISClient.const_get(type)
210
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
211
- end
212
- end
213
-
214
- # Returns the string representation of the object
215
- # @return [String] String presentation of the object
216
- def to_s
217
- to_hash.to_s
218
- end
219
-
220
- # to_body is an alias to to_hash (backward compatibility)
221
- # @return [Hash] Returns the object in the form of hash
222
- def to_body
223
- to_hash
224
- end
225
-
226
- # Returns the object in the form of hash
227
- # @return [Hash] Returns the object in the form of hash
228
- def to_hash
229
- hash = {}
230
- self.class.attribute_map.each_pair do |attr, param|
231
- value = self.send(attr)
232
- if value.nil?
233
- is_nullable = self.class.openapi_nullable.include?(attr)
234
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
235
- end
236
-
237
- hash[param] = _to_hash(value)
238
- end
239
- hash
240
- end
241
-
242
- # Outputs non-array value in the form of hash
243
- # For object, use to_hash. Otherwise, just return the value
244
- # @param [Object] value Any valid value
245
- # @return [Hash] Returns the value in the form of hash
246
- def _to_hash(value)
247
- if value.is_a?(Array)
248
- value.compact.map { |v| _to_hash(v) }
249
- elsif value.is_a?(Hash)
250
- {}.tap do |hash|
251
- value.each { |k, v| hash[k] = _to_hash(v) }
252
- end
253
- elsif value.respond_to? :to_hash
254
- value.to_hash
255
- else
256
- value
257
- end
258
- end
259
-
260
- end
261
-
262
- end
@@ -1,289 +0,0 @@
1
- =begin
2
- #Merge HRIS API
3
-
4
- #The unified API for building rich integrations with multiple HR Information System platforms.
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: hello@merge.dev
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.0.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module MergeHRISClient
17
- class EndUserDetails
18
- attr_accessor :end_user_email_address
19
-
20
- attr_accessor :end_user_organization_name
21
-
22
- attr_accessor :end_user_origin_id
23
-
24
- attr_accessor :categories
25
-
26
- class EnumAttributeValidator
27
- attr_reader :datatype
28
- attr_reader :allowable_values
29
-
30
- def initialize(datatype, allowable_values)
31
- @allowable_values = allowable_values.map do |value|
32
- case datatype.to_s
33
- when /Integer/i
34
- value.to_i
35
- when /Float/i
36
- value.to_f
37
- else
38
- value
39
- end
40
- end
41
- end
42
-
43
- def valid?(value)
44
- !value || allowable_values.include?(value)
45
- end
46
- end
47
-
48
- # Attribute mapping from ruby-style variable name to JSON key.
49
- def self.attribute_map
50
- {
51
- :'end_user_email_address' => :'end_user_email_address',
52
- :'end_user_organization_name' => :'end_user_organization_name',
53
- :'end_user_origin_id' => :'end_user_origin_id',
54
- :'categories' => :'categories'
55
- }
56
- end
57
-
58
- # Returns all the JSON keys this model knows about
59
- def self.acceptable_attributes
60
- attribute_map.values
61
- end
62
-
63
- # Attribute type mapping.
64
- def self.openapi_types
65
- {
66
- :'end_user_email_address' => :'String',
67
- :'end_user_organization_name' => :'String',
68
- :'end_user_origin_id' => :'String',
69
- :'categories' => :'Array<String>'
70
- }
71
- end
72
-
73
- # List of attributes with nullable: true
74
- def self.openapi_nullable
75
- Set.new([
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 `MergeHRISClient::EndUserDetails` 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 `MergeHRISClient::EndUserDetails`. 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?(:'end_user_email_address')
95
- self.end_user_email_address = attributes[:'end_user_email_address']
96
- end
97
-
98
- if attributes.key?(:'end_user_organization_name')
99
- self.end_user_organization_name = attributes[:'end_user_organization_name']
100
- end
101
-
102
- if attributes.key?(:'end_user_origin_id')
103
- self.end_user_origin_id = attributes[:'end_user_origin_id']
104
- end
105
-
106
- if attributes.key?(:'categories')
107
- if (value = attributes[:'categories']).is_a?(Array)
108
- self.categories = value
109
- end
110
- end
111
- end
112
-
113
- # Show invalid properties with the reasons. Usually used together with valid?
114
- # @return Array for valid properties with the reasons
115
- def list_invalid_properties
116
- invalid_properties = Array.new
117
- if @end_user_email_address.nil?
118
- invalid_properties.push('invalid value for "end_user_email_address", end_user_email_address cannot be nil.')
119
- end
120
-
121
- if @end_user_organization_name.nil?
122
- invalid_properties.push('invalid value for "end_user_organization_name", end_user_organization_name cannot be nil.')
123
- end
124
-
125
- if @end_user_origin_id.nil?
126
- invalid_properties.push('invalid value for "end_user_origin_id", end_user_origin_id cannot be nil.')
127
- end
128
-
129
- if @categories.nil?
130
- invalid_properties.push('invalid value for "categories", categories cannot be nil.')
131
- end
132
-
133
- invalid_properties
134
- end
135
-
136
- # Check to see if the all the properties in the model are valid
137
- # @return true if the model is valid
138
- def valid?
139
- return false if @end_user_email_address.nil?
140
- return false if @end_user_organization_name.nil?
141
- return false if @end_user_origin_id.nil?
142
- return false if @categories.nil?
143
- true
144
- end
145
-
146
- # Checks equality by comparing each attribute.
147
- # @param [Object] Object to be compared
148
- def ==(o)
149
- return true if self.equal?(o)
150
- self.class == o.class &&
151
- end_user_email_address == o.end_user_email_address &&
152
- end_user_organization_name == o.end_user_organization_name &&
153
- end_user_origin_id == o.end_user_origin_id &&
154
- categories == o.categories
155
- end
156
-
157
- # @see the `==` method
158
- # @param [Object] Object to be compared
159
- def eql?(o)
160
- self == o
161
- end
162
-
163
- # Calculates hash code according to all attributes.
164
- # @return [Integer] Hash code
165
- def hash
166
- [end_user_email_address, end_user_organization_name, end_user_origin_id, categories].hash
167
- end
168
-
169
- # Builds the object from hash
170
- # @param [Hash] attributes Model attributes in the form of hash
171
- # @return [Object] Returns the model itself
172
- def self.build_from_hash(attributes)
173
- new.build_from_hash(attributes)
174
- end
175
-
176
- # Builds the object from hash
177
- # @param [Hash] attributes Model attributes in the form of hash
178
- # @return [Object] Returns the model itself
179
- def build_from_hash(attributes)
180
- return nil unless attributes.is_a?(Hash)
181
- self.class.openapi_types.each_pair do |key, type|
182
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
183
- self.send("#{key}=", nil)
184
- elsif type =~ /\AArray<(.*)>/i
185
- # check to ensure the input is an array given that the attribute
186
- # is documented as an array but the input is not
187
- if attributes[self.class.attribute_map[key]].is_a?(Array)
188
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
189
- end
190
- elsif !attributes[self.class.attribute_map[key]].nil?
191
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
192
- end
193
- end
194
-
195
- self
196
- end
197
-
198
- # Deserializes the data based on type
199
- # @param string type Data type
200
- # @param string value Value to be deserialized
201
- # @return [Object] Deserialized data
202
- def _deserialize(type, value)
203
- case type.to_sym
204
- when :Time
205
- Time.parse(value)
206
- when :Date
207
- Date.parse(value)
208
- when :String
209
- value.to_s
210
- when :Integer
211
- value.to_i
212
- when :Float
213
- value.to_f
214
- when :Boolean
215
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
- true
217
- else
218
- false
219
- end
220
- when :Object
221
- # generic object (usually a Hash), return directly
222
- value
223
- when /\AArray<(?<inner_type>.+)>\z/
224
- inner_type = Regexp.last_match[:inner_type]
225
- value.map { |v| _deserialize(inner_type, v) }
226
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
- k_type = Regexp.last_match[:k_type]
228
- v_type = Regexp.last_match[:v_type]
229
- {}.tap do |hash|
230
- value.each do |k, v|
231
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
- end
233
- end
234
- else # model
235
- # models (e.g. Pet) or oneOf
236
- klass = MergeHRISClient.const_get(type)
237
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
238
- end
239
- end
240
-
241
- # Returns the string representation of the object
242
- # @return [String] String presentation of the object
243
- def to_s
244
- to_hash.to_s
245
- end
246
-
247
- # to_body is an alias to to_hash (backward compatibility)
248
- # @return [Hash] Returns the object in the form of hash
249
- def to_body
250
- to_hash
251
- end
252
-
253
- # Returns the object in the form of hash
254
- # @return [Hash] Returns the object in the form of hash
255
- def to_hash
256
- hash = {}
257
- self.class.attribute_map.each_pair do |attr, param|
258
- value = self.send(attr)
259
- if value.nil?
260
- is_nullable = self.class.openapi_nullable.include?(attr)
261
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
- end
263
-
264
- hash[param] = _to_hash(value)
265
- end
266
- hash
267
- end
268
-
269
- # Outputs non-array value in the form of hash
270
- # For object, use to_hash. Otherwise, just return the value
271
- # @param [Object] value Any valid value
272
- # @return [Hash] Returns the value in the form of hash
273
- def _to_hash(value)
274
- if value.is_a?(Array)
275
- value.compact.map { |v| _to_hash(v) }
276
- elsif value.is_a?(Hash)
277
- {}.tap do |hash|
278
- value.each { |k, v| hash[k] = _to_hash(v) }
279
- end
280
- elsif value.respond_to? :to_hash
281
- value.to_hash
282
- else
283
- value
284
- end
285
- end
286
-
287
- end
288
-
289
- end