change_healthcare-eligibility 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +130 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -0
  7. data/Gemfile +4 -0
  8. data/Gemfile.lock +59 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +64 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +11 -0
  13. data/bin/rspec +29 -0
  14. data/bin/setup +8 -0
  15. data/change_healthcare-eligibility.gemspec +44 -0
  16. data/lib/change_healthcare/eligibility.rb +13 -0
  17. data/lib/change_healthcare/eligibility/inspector.rb +82 -0
  18. data/lib/change_healthcare/eligibility/swagger_client.rb +81 -0
  19. data/lib/change_healthcare/eligibility/swagger_client/api_client.rb +388 -0
  20. data/lib/change_healthcare/eligibility/swagger_client/api_error.rb +40 -0
  21. data/lib/change_healthcare/eligibility/swagger_client/configuration.rb +202 -0
  22. data/lib/change_healthcare/eligibility/swagger_client/eligibility_api.rb +198 -0
  23. data/lib/change_healthcare/eligibility/swagger_client/models/additional_identification.rb +266 -0
  24. data/lib/change_healthcare/eligibility/swagger_client/models/additional_information.rb +185 -0
  25. data/lib/change_healthcare/eligibility/swagger_client/models/address.rb +218 -0
  26. data/lib/change_healthcare/eligibility/swagger_client/models/benefits_additional_information.rb +376 -0
  27. data/lib/change_healthcare/eligibility/swagger_client/models/benefits_date_information.rb +340 -0
  28. data/lib/change_healthcare/eligibility/swagger_client/models/benefits_information.rb +338 -0
  29. data/lib/change_healthcare/eligibility/swagger_client/models/benefits_related_entity.rb +240 -0
  30. data/lib/change_healthcare/eligibility/swagger_client/models/benefits_service_delivery.rb +220 -0
  31. data/lib/change_healthcare/eligibility/swagger_client/models/composite_medical_procedure_identifier.rb +218 -0
  32. data/lib/change_healthcare/eligibility/swagger_client/models/eligibility_additional_information.rb +200 -0
  33. data/lib/change_healthcare/eligibility/swagger_client/models/encounter.rb +359 -0
  34. data/lib/change_healthcare/eligibility/swagger_client/models/error.rb +205 -0
  35. data/lib/change_healthcare/eligibility/swagger_client/models/health_care_diagnosis_code.rb +190 -0
  36. data/lib/change_healthcare/eligibility/swagger_client/models/health_care_information.rb +229 -0
  37. data/lib/change_healthcare/eligibility/swagger_client/models/health_check.rb +190 -0
  38. data/lib/change_healthcare/eligibility/swagger_client/models/information_receiver_name.rb +303 -0
  39. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2000_cd2100_cd_segment_nm1_ref_dmg_ins_mpi_prv_notes_response_member.rb +429 -0
  40. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_nm1_and_per_notes_information_source_name.rb +293 -0
  41. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_per_element_per03_8_notes_communication.rb +194 -0
  42. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_per_notes_information_source_contact_information.rb +198 -0
  43. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_bcd_segment_nm1_prv_notes_provider.rb +322 -0
  44. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_cd_segment_trn_notes_subscriber_trace_numbers.rb +218 -0
  45. data/lib/change_healthcare/eligibility/swagger_client/models/loop_2110_cd_segments_ref_notes_subscriber_dependent_additional_identification.rb +488 -0
  46. data/lib/change_healthcare/eligibility/swagger_client/models/medical_eligibility.rb +272 -0
  47. data/lib/change_healthcare/eligibility/swagger_client/models/medical_procedure.rb +254 -0
  48. data/lib/change_healthcare/eligibility/swagger_client/models/plan_date_information.rb +340 -0
  49. data/lib/change_healthcare/eligibility/swagger_client/models/plan_status.rb +204 -0
  50. data/lib/change_healthcare/eligibility/swagger_client/models/provider.rb +304 -0
  51. data/lib/change_healthcare/eligibility/swagger_client/models/provider_information.rb +190 -0
  52. data/lib/change_healthcare/eligibility/swagger_client/models/raw_x12_request.rb +190 -0
  53. data/lib/change_healthcare/eligibility/swagger_client/models/request_dependent.rb +452 -0
  54. data/lib/change_healthcare/eligibility/swagger_client/models/request_subscriber.rb +456 -0
  55. data/lib/change_healthcare/eligibility/swagger_client/models/response.rb +322 -0
  56. data/lib/change_healthcare/eligibility/swagger_client/version.rb +17 -0
  57. data/lib/change_healthcare/eligibility/version.rb +5 -0
  58. data/lib/change_healthcare/eligibility/wrapper.rb +124 -0
  59. metadata +214 -0
@@ -0,0 +1,272 @@
1
+ # #Eligibility
2
+ #
3
+ # Reference for developers
4
+ #
5
+ # OpenAPI spec version: v3
6
+ #
7
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
8
+ # Swagger Codegen version: 2.4.17
9
+ #
10
+
11
+ require 'date'
12
+
13
+ module ChangeHealthcare
14
+ module Eligibility
15
+ module SwaggerClient
16
+ # Eligibility 270 Request Model
17
+ class MedicalEligibility
18
+ # Segment: ISA, Element: ISA13, Notes: Required, Interchange Control Number - must be exactly 9 positive unsigned numeric characters.
19
+ attr_accessor :control_number
20
+
21
+ # Loop: 2000D, Notes: Dependent Detail
22
+ attr_accessor :dependents
23
+
24
+ # Loop: 2110[C|D], Notes: Subscriber or Dependent Eligibility or Benefit Inquiry
25
+ attr_accessor :encounter
26
+
27
+ attr_accessor :information_receiver_name, :partner_id, :subscriber
28
+
29
+ # Loop: 2100B, Segment: REF, Element: REF02, Notes: Personal Identification Number (PIN) REF01=4A
30
+ attr_accessor :portal_password
31
+
32
+ # Loop: 2100B, Segment: REF, Element: REF02, Notes: User Identification REF01=JD
33
+ attr_accessor :portal_username
34
+
35
+ # Loop: 2100B, Segment: NM1, Notes: Information Receiver
36
+ attr_accessor :provider
37
+
38
+ # This property is a feature of Trading Partner API, if you are not using Trading Partner API, please use tradingPartnerServiceId as the payorId
39
+ attr_accessor :trading_partner_id
40
+
41
+ # Loop: 2100A, Segment: NM1, Element: NM103, Notes: organizational name
42
+ attr_accessor :trading_partner_name
43
+
44
+ # Loop: 2100A Segment: NM1, Element: NM109, Notes: , we send this as MN108 as PI
45
+ attr_accessor :trading_partner_service_id
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ 'control_number': :controlNumber,
51
+ 'dependents': :dependents,
52
+ 'encounter': :encounter,
53
+ 'information_receiver_name': :informationReceiverName,
54
+ 'partner_id': :partnerId,
55
+ 'portal_password': :portalPassword,
56
+ 'portal_username': :portalUsername,
57
+ 'provider': :provider,
58
+ 'subscriber': :subscriber,
59
+ 'trading_partner_id': :tradingPartnerId,
60
+ 'trading_partner_name': :tradingPartnerName,
61
+ 'trading_partner_service_id': :tradingPartnerServiceId
62
+ }
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.swagger_types
67
+ {
68
+ 'control_number': :String,
69
+ 'dependents': :'Array<RequestDependent>',
70
+ 'encounter': :Encounter,
71
+ 'information_receiver_name': :InformationReceiverName,
72
+ 'partner_id': :BOOLEAN,
73
+ 'portal_password': :String,
74
+ 'portal_username': :String,
75
+ 'provider': :Provider,
76
+ 'subscriber': :RequestSubscriber,
77
+ 'trading_partner_id': :String,
78
+ 'trading_partner_name': :String,
79
+ 'trading_partner_service_id': :String
80
+ }
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ return unless attributes.is_a?(Hash)
87
+
88
+ # convert string to symbol for hash key
89
+ attributes = attributes.transform_keys(&:to_sym)
90
+
91
+ self.control_number = attributes[:controlNumber] if attributes.key?(:controlNumber)
92
+
93
+ if attributes.key?(:dependents)
94
+ if (value = attributes[:dependents]).is_a?(Array)
95
+ self.dependents = value
96
+ end
97
+ end
98
+
99
+ self.encounter = attributes[:encounter] if attributes.key?(:encounter)
100
+
101
+ self.information_receiver_name = attributes[:informationReceiverName] if attributes.key?(:informationReceiverName)
102
+
103
+ self.partner_id = attributes[:partnerId] if attributes.key?(:partnerId)
104
+
105
+ self.portal_password = attributes[:portalPassword] if attributes.key?(:portalPassword)
106
+
107
+ self.portal_username = attributes[:portalUsername] if attributes.key?(:portalUsername)
108
+
109
+ self.provider = attributes[:provider] if attributes.key?(:provider)
110
+
111
+ self.subscriber = attributes[:subscriber] if attributes.key?(:subscriber)
112
+
113
+ self.trading_partner_id = attributes[:tradingPartnerId] if attributes.key?(:tradingPartnerId)
114
+
115
+ self.trading_partner_name = attributes[:tradingPartnerName] if attributes.key?(:tradingPartnerName)
116
+
117
+ self.trading_partner_service_id = attributes[:tradingPartnerServiceId] if attributes.key?(:tradingPartnerServiceId)
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ []
124
+ end
125
+
126
+ # Check to see if the all the properties in the model are valid
127
+ # @return true if the model is valid
128
+ def valid?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if equal?(o)
136
+
137
+ self.class == o.class &&
138
+ control_number == o.control_number &&
139
+ dependents == o.dependents &&
140
+ encounter == o.encounter &&
141
+ information_receiver_name == o.information_receiver_name &&
142
+ partner_id == o.partner_id &&
143
+ portal_password == o.portal_password &&
144
+ portal_username == o.portal_username &&
145
+ provider == o.provider &&
146
+ subscriber == o.subscriber &&
147
+ trading_partner_id == o.trading_partner_id &&
148
+ trading_partner_name == o.trading_partner_name &&
149
+ trading_partner_service_id == o.trading_partner_service_id
150
+ end
151
+
152
+ # @see the `==` method
153
+ # @param [Object] Object to be compared
154
+ def eql?(o)
155
+ self == o
156
+ end
157
+
158
+ # Calculates hash code according to all attributes.
159
+ # @return [Fixnum] Hash code
160
+ def hash
161
+ [control_number, dependents, encounter, information_receiver_name, partner_id, portal_password, portal_username, provider, subscriber, trading_partner_id, trading_partner_name, trading_partner_service_id].hash
162
+ end
163
+
164
+ # Builds the object from hash
165
+ # @param [Hash] attributes Model attributes in the form of hash
166
+ # @return [Object] Returns the model itself
167
+ def build_from_hash(attributes)
168
+ return nil unless attributes.is_a?(Hash)
169
+
170
+ self.class.swagger_types.each_pair do |key, type|
171
+ if type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
175
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
176
+ end
177
+ elsif !attributes[self.class.attribute_map[key]].nil?
178
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
179
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
180
+ end
181
+
182
+ self
183
+ end
184
+
185
+ # Deserializes the data based on type
186
+ # @param string type Data type
187
+ # @param string value Value to be deserialized
188
+ # @return [Object] Deserialized data
189
+ def _deserialize(type, value)
190
+ case type.to_sym
191
+ when :DateTime
192
+ DateTime.parse(value)
193
+ when :Date
194
+ Date.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :BOOLEAN
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ temp_model = SwaggerClient.const_get(type).new
223
+ temp_model.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = send(attr)
245
+ next if value.nil?
246
+
247
+ hash[param] = _to_hash(value)
248
+ end
249
+ hash
250
+ end
251
+
252
+ # Outputs non-array value in the form of hash
253
+ # For object, use to_hash. Otherwise, just return the value
254
+ # @param [Object] value Any valid value
255
+ # @return [Hash] Returns the value in the form of hash
256
+ def _to_hash(value)
257
+ if value.is_a?(Array)
258
+ value.compact.map { |v| _to_hash(v) }
259
+ elsif value.is_a?(Hash)
260
+ {}.tap do |hash|
261
+ value.each { |k, v| hash[k] = _to_hash(v) }
262
+ end
263
+ elsif value.respond_to? :to_hash
264
+ value.to_hash
265
+ else
266
+ value
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
272
+ end
@@ -0,0 +1,254 @@
1
+ # #Eligibility
2
+ #
3
+ # Reference for developers
4
+ #
5
+ # OpenAPI spec version: v3
6
+ #
7
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
8
+ # Swagger Codegen version: 2.4.17
9
+ #
10
+
11
+ require 'date'
12
+
13
+ module ChangeHealthcare
14
+ module Eligibility
15
+ module SwaggerClient
16
+ # Loop: 2110[C|D], Notes: Eligibility or Benefit Information, EQ02 and beyond only
17
+ class MedicalProcedure
18
+ # Loop: 2110[C|D], Segment: EQ, Element: EQ05, Notes: Composite Diagnosis Code Pointer
19
+ attr_accessor :diagnosis_code_pointer
20
+
21
+ # Loop: 2110[C|D], Segment: EQ, Element: EQ02-2, Notes: Composite Medical Procedure Identifier - Procedure Code
22
+ attr_accessor :procedure_code
23
+
24
+ # Loop: 2110[C|D], Segment: EQ, Element: EQ02-3, Notes: Composite Medical Procedure Identifier - Procedure Modifier
25
+ attr_accessor :procedure_modifiers
26
+
27
+ # Loop: 2110[C|D], Segment: EQ, Element: EQ02-1, Notes: Composite Medical Procedure Identifier - Product or Service ID Qualifier, Allowed Values are: 'AD' American Dental Association Codes, 'CJ' Current Procedural Terminology (CPT) Codes,'HC' Health Care Financing Administration Common Procedural Coding System (HCPCS) Codes,'ID' International Classification of Diseases, 9th Revision, Clinical Modification (ICD-9-CM) - Procedure, 'IV' Home Infusion EDI Coalition (HIEC) Product/Service Code, 'N4' National Drug Code in 5-4-2 Format, 'ZZ' Mutually Defined
28
+ attr_accessor :product_or_service_id_qualifier
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype, :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ 'diagnosis_code_pointer': :diagnosisCodePointer,
55
+ 'procedure_code': :procedureCode,
56
+ 'procedure_modifiers': :procedureModifiers,
57
+ 'product_or_service_id_qualifier': :productOrServiceIDQualifier
58
+ }
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.swagger_types
63
+ {
64
+ 'diagnosis_code_pointer': :'Array<String>',
65
+ 'procedure_code': :String,
66
+ 'procedure_modifiers': :'Array<String>',
67
+ 'product_or_service_id_qualifier': :String
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.transform_keys(&:to_sym)
78
+
79
+ if attributes.key?(:diagnosisCodePointer)
80
+ if (value = attributes[:diagnosisCodePointer]).is_a?(Array)
81
+ self.diagnosis_code_pointer = value
82
+ end
83
+ end
84
+
85
+ self.procedure_code = attributes[:procedureCode] if attributes.key?(:procedureCode)
86
+
87
+ if attributes.key?(:procedureModifiers)
88
+ if (value = attributes[:procedureModifiers]).is_a?(Array)
89
+ self.procedure_modifiers = value
90
+ end
91
+ end
92
+
93
+ self.product_or_service_id_qualifier = attributes[:productOrServiceIDQualifier] if attributes.key?(:productOrServiceIDQualifier)
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
+ []
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ product_or_service_id_qualifier_validator = EnumAttributeValidator.new('String', %w[AD CJ HC ID IV N4 ZZ])
106
+ return false unless product_or_service_id_qualifier_validator.valid?(@product_or_service_id_qualifier)
107
+
108
+ true
109
+ end
110
+
111
+ # Custom attribute writer method checking allowed values (enum).
112
+ # @param [Object] product_or_service_id_qualifier Object to be assigned
113
+ def product_or_service_id_qualifier=(product_or_service_id_qualifier)
114
+ validator = EnumAttributeValidator.new('String', %w[AD CJ HC ID IV N4 ZZ])
115
+ unless validator.valid?(product_or_service_id_qualifier)
116
+ raise ArgumentError, %(invalid value for "product_or_service_id_qualifier", must be one of #{validator.allowable_values}.)
117
+ end
118
+
119
+ @product_or_service_id_qualifier = product_or_service_id_qualifier
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if equal?(o)
126
+
127
+ self.class == o.class &&
128
+ diagnosis_code_pointer == o.diagnosis_code_pointer &&
129
+ procedure_code == o.procedure_code &&
130
+ procedure_modifiers == o.procedure_modifiers &&
131
+ product_or_service_id_qualifier == o.product_or_service_id_qualifier
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Fixnum] Hash code
142
+ def hash
143
+ [diagnosis_code_pointer, procedure_code, procedure_modifiers, product_or_service_id_qualifier].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+
152
+ self.class.swagger_types.each_pair do |key, type|
153
+ if type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
162
+ end
163
+
164
+ self
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def _deserialize(type, value)
172
+ case type.to_sym
173
+ when :DateTime
174
+ DateTime.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :BOOLEAN
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ temp_model = SwaggerClient.const_get(type).new
205
+ temp_model.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = send(attr)
227
+ next if value.nil?
228
+
229
+ hash[param] = _to_hash(value)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
254
+ end