change_healthcare-eligibility 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +130 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/bin/console +11 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/change_healthcare-eligibility.gemspec +44 -0
- data/lib/change_healthcare/eligibility.rb +13 -0
- data/lib/change_healthcare/eligibility/inspector.rb +82 -0
- data/lib/change_healthcare/eligibility/swagger_client.rb +81 -0
- data/lib/change_healthcare/eligibility/swagger_client/api_client.rb +388 -0
- data/lib/change_healthcare/eligibility/swagger_client/api_error.rb +40 -0
- data/lib/change_healthcare/eligibility/swagger_client/configuration.rb +202 -0
- data/lib/change_healthcare/eligibility/swagger_client/eligibility_api.rb +198 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/additional_identification.rb +266 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/additional_information.rb +185 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/address.rb +218 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/benefits_additional_information.rb +376 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/benefits_date_information.rb +340 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/benefits_information.rb +338 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/benefits_related_entity.rb +240 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/benefits_service_delivery.rb +220 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/composite_medical_procedure_identifier.rb +218 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/eligibility_additional_information.rb +200 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/encounter.rb +359 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/error.rb +205 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/health_care_diagnosis_code.rb +190 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/health_care_information.rb +229 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/health_check.rb +190 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/information_receiver_name.rb +303 -0
- 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
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_nm1_and_per_notes_information_source_name.rb +293 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_per_element_per03_8_notes_communication.rb +194 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_a_segments_per_notes_information_source_contact_information.rb +198 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_bcd_segment_nm1_prv_notes_provider.rb +322 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2100_cd_segment_trn_notes_subscriber_trace_numbers.rb +218 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/loop_2110_cd_segments_ref_notes_subscriber_dependent_additional_identification.rb +488 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/medical_eligibility.rb +272 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/medical_procedure.rb +254 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/plan_date_information.rb +340 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/plan_status.rb +204 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/provider.rb +304 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/provider_information.rb +190 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/raw_x12_request.rb +190 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/request_dependent.rb +452 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/request_subscriber.rb +456 -0
- data/lib/change_healthcare/eligibility/swagger_client/models/response.rb +322 -0
- data/lib/change_healthcare/eligibility/swagger_client/version.rb +17 -0
- data/lib/change_healthcare/eligibility/version.rb +5 -0
- data/lib/change_healthcare/eligibility/wrapper.rb +124 -0
- metadata +214 -0
@@ -0,0 +1,304 @@
|
|
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: 2100B, Segment: NM1, Notes: Information Receiver
|
17
|
+
class Provider
|
18
|
+
# Loop: 2100B Segment: MN1, Element: NM104, Notes: NM101=PR when providerType='payer' && payerId is present otherwise 1P for Provider, NM102=1 Person, firstName 1-35 alphanumberic characters
|
19
|
+
attr_accessor :first_name
|
20
|
+
|
21
|
+
# Loop: 2100B Segment: MN1, Element: NM103, Notes: NM101=PR when providerType='payer' && payerId is present otherwise 1P for Provider, NM102=1 Person, lastName 1-60 alphanumberic characters
|
22
|
+
attr_accessor :last_name
|
23
|
+
|
24
|
+
attr_accessor :name, :person
|
25
|
+
|
26
|
+
# Loop: 2100B Segment: MN1, Element: NM109, Notes: NM108=XX Centers for Medicare and Medicaid Services National Provider Identifier 2-80 alphanumberic characters
|
27
|
+
attr_accessor :npi
|
28
|
+
|
29
|
+
# Loop: 2100B Segment: MN1, Element: NM103, Notes: NM101=PR when providerType='payer' && payerId is present otherwise 1P for Provider, NM102=2 Non-Person Entity, organizationName 1-60 alphanumberic characters
|
30
|
+
attr_accessor :organization_name
|
31
|
+
|
32
|
+
# Loop: 2100B Segment: MN1, Element: NM109, Notes: NM101=PR when providerType='payer' && payerId is present otherwise 1P for Provider, NM108=PI Payor Identification 2-80 alphanumberic characters
|
33
|
+
attr_accessor :payor_id
|
34
|
+
|
35
|
+
# Loop: 2100B Segment: PRV, Element: PRV01, Notes: PRV02=PXC Allowed Values are: 'AD' Admitting, 'AT' Attending, 'BI' Billing, 'CO' Consulting, 'CV' Covering, 'H' Hospital, 'HH' Home Health Care, 'LA' Laboratory, 'OT' Other Physician, 'P1' Pharmacist, 'P2' Pharmacy, 'PC' Primary Care Physician, 'PE' Performing, 'R' Rural Health Clinic, 'RF' Referring, 'SB' Submitting, 'SK' Skilled Nursing Facility, 'SU' Supervising
|
36
|
+
attr_accessor :provider_code
|
37
|
+
|
38
|
+
# Loop: 2100B Segment: MN1, Notes: NM101=PR when providerType='payer' && payerId is present otherwise 1P for Provider
|
39
|
+
attr_accessor :provider_type
|
40
|
+
|
41
|
+
# Loop: 2100B Segment: PRV, Element: PRV03, Notes: PRV02=PXC referenceIdentification and controlNumber into PRV03
|
42
|
+
attr_accessor :reference_identification
|
43
|
+
|
44
|
+
# Loop: 2100B Segment: MN1, Element: NM109, Notes: NM108=SV Service Provider Number 2-80 alphanumberic characters
|
45
|
+
attr_accessor :service_provider_number
|
46
|
+
|
47
|
+
# Loop: 2100B Segment: MN1, Element: NM109, Notes: NM108=FI Federal Taxpayer’s Identification Number 2-80 alphanumberic characters
|
48
|
+
attr_accessor :tax_id
|
49
|
+
|
50
|
+
class EnumAttributeValidator
|
51
|
+
attr_reader :datatype, :allowable_values
|
52
|
+
|
53
|
+
def initialize(datatype, allowable_values)
|
54
|
+
@allowable_values = allowable_values.map do |value|
|
55
|
+
case datatype.to_s
|
56
|
+
when /Integer/i
|
57
|
+
value.to_i
|
58
|
+
when /Float/i
|
59
|
+
value.to_f
|
60
|
+
else
|
61
|
+
value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def valid?(value)
|
67
|
+
!value || allowable_values.include?(value)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
72
|
+
def self.attribute_map
|
73
|
+
{
|
74
|
+
'first_name': :firstName,
|
75
|
+
'last_name': :lastName,
|
76
|
+
'name': :name,
|
77
|
+
'npi': :npi,
|
78
|
+
'organization_name': :organizationName,
|
79
|
+
'payor_id': :payorId,
|
80
|
+
'person': :person,
|
81
|
+
'provider_code': :providerCode,
|
82
|
+
'provider_type': :providerType,
|
83
|
+
'reference_identification': :referenceIdentification,
|
84
|
+
'service_provider_number': :serviceProviderNumber,
|
85
|
+
'tax_id': :taxId
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
# Attribute type mapping.
|
90
|
+
def self.swagger_types
|
91
|
+
{
|
92
|
+
'first_name': :String,
|
93
|
+
'last_name': :String,
|
94
|
+
'name': :BOOLEAN,
|
95
|
+
'npi': :String,
|
96
|
+
'organization_name': :String,
|
97
|
+
'payor_id': :String,
|
98
|
+
'person': :BOOLEAN,
|
99
|
+
'provider_code': :String,
|
100
|
+
'provider_type': :String,
|
101
|
+
'reference_identification': :String,
|
102
|
+
'service_provider_number': :String,
|
103
|
+
'tax_id': :String
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
# Initializes the object
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
def initialize(attributes = {})
|
110
|
+
return unless attributes.is_a?(Hash)
|
111
|
+
|
112
|
+
# convert string to symbol for hash key
|
113
|
+
attributes = attributes.transform_keys(&:to_sym)
|
114
|
+
|
115
|
+
self.first_name = attributes[:firstName] if attributes.key?(:firstName)
|
116
|
+
|
117
|
+
self.last_name = attributes[:lastName] if attributes.key?(:lastName)
|
118
|
+
|
119
|
+
self.name = attributes[:name] if attributes.key?(:name)
|
120
|
+
|
121
|
+
self.npi = attributes[:npi] if attributes.key?(:npi)
|
122
|
+
|
123
|
+
self.organization_name = attributes[:organizationName] if attributes.key?(:organizationName)
|
124
|
+
|
125
|
+
self.payor_id = attributes[:payorId] if attributes.key?(:payorId)
|
126
|
+
|
127
|
+
self.person = attributes[:person] if attributes.key?(:person)
|
128
|
+
|
129
|
+
self.provider_code = attributes[:providerCode] if attributes.key?(:providerCode)
|
130
|
+
|
131
|
+
self.provider_type = attributes[:providerType] if attributes.key?(:providerType)
|
132
|
+
|
133
|
+
self.reference_identification = attributes[:referenceIdentification] if attributes.key?(:referenceIdentification)
|
134
|
+
|
135
|
+
self.service_provider_number = attributes[:serviceProviderNumber] if attributes.key?(:serviceProviderNumber)
|
136
|
+
|
137
|
+
self.tax_id = attributes[:taxId] if attributes.key?(:taxId)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
141
|
+
# @return Array for valid properties with the reasons
|
142
|
+
def list_invalid_properties
|
143
|
+
[]
|
144
|
+
end
|
145
|
+
|
146
|
+
# Check to see if the all the properties in the model are valid
|
147
|
+
# @return true if the model is valid
|
148
|
+
def valid?
|
149
|
+
provider_code_validator = EnumAttributeValidator.new('String', %w[AD AT BI CO CV H HH LA OT P1 P2 PC PE R RF SB SK SU])
|
150
|
+
return false unless provider_code_validator.valid?(@provider_code)
|
151
|
+
|
152
|
+
true
|
153
|
+
end
|
154
|
+
|
155
|
+
# Custom attribute writer method checking allowed values (enum).
|
156
|
+
# @param [Object] provider_code Object to be assigned
|
157
|
+
def provider_code=(provider_code)
|
158
|
+
validator = EnumAttributeValidator.new('String', %w[AD AT BI CO CV H HH LA OT P1 P2 PC PE R RF SB SK SU])
|
159
|
+
raise ArgumentError, %(invalid value for "provider_code", must be one of #{validator.allowable_values}.) unless validator.valid?(provider_code)
|
160
|
+
|
161
|
+
@provider_code = provider_code
|
162
|
+
end
|
163
|
+
|
164
|
+
# Checks equality by comparing each attribute.
|
165
|
+
# @param [Object] Object to be compared
|
166
|
+
def ==(o)
|
167
|
+
return true if equal?(o)
|
168
|
+
|
169
|
+
self.class == o.class &&
|
170
|
+
first_name == o.first_name &&
|
171
|
+
last_name == o.last_name &&
|
172
|
+
name == o.name &&
|
173
|
+
npi == o.npi &&
|
174
|
+
organization_name == o.organization_name &&
|
175
|
+
payor_id == o.payor_id &&
|
176
|
+
person == o.person &&
|
177
|
+
provider_code == o.provider_code &&
|
178
|
+
provider_type == o.provider_type &&
|
179
|
+
reference_identification == o.reference_identification &&
|
180
|
+
service_provider_number == o.service_provider_number &&
|
181
|
+
tax_id == o.tax_id
|
182
|
+
end
|
183
|
+
|
184
|
+
# @see the `==` method
|
185
|
+
# @param [Object] Object to be compared
|
186
|
+
def eql?(o)
|
187
|
+
self == o
|
188
|
+
end
|
189
|
+
|
190
|
+
# Calculates hash code according to all attributes.
|
191
|
+
# @return [Fixnum] Hash code
|
192
|
+
def hash
|
193
|
+
[first_name, last_name, name, npi, organization_name, payor_id, person, provider_code, provider_type, reference_identification, service_provider_number, tax_id].hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Builds the object from hash
|
197
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
198
|
+
# @return [Object] Returns the model itself
|
199
|
+
def build_from_hash(attributes)
|
200
|
+
return nil unless attributes.is_a?(Hash)
|
201
|
+
|
202
|
+
self.class.swagger_types.each_pair do |key, type|
|
203
|
+
if type =~ /\AArray<(.*)>/i
|
204
|
+
# check to ensure the input is an array given that the attribute
|
205
|
+
# is documented as an array but the input is not
|
206
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
207
|
+
send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
|
208
|
+
end
|
209
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
210
|
+
send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
211
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
212
|
+
end
|
213
|
+
|
214
|
+
self
|
215
|
+
end
|
216
|
+
|
217
|
+
# Deserializes the data based on type
|
218
|
+
# @param string type Data type
|
219
|
+
# @param string value Value to be deserialized
|
220
|
+
# @return [Object] Deserialized data
|
221
|
+
def _deserialize(type, value)
|
222
|
+
case type.to_sym
|
223
|
+
when :DateTime
|
224
|
+
DateTime.parse(value)
|
225
|
+
when :Date
|
226
|
+
Date.parse(value)
|
227
|
+
when :String
|
228
|
+
value.to_s
|
229
|
+
when :Integer
|
230
|
+
value.to_i
|
231
|
+
when :Float
|
232
|
+
value.to_f
|
233
|
+
when :BOOLEAN
|
234
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
235
|
+
true
|
236
|
+
else
|
237
|
+
false
|
238
|
+
end
|
239
|
+
when :Object
|
240
|
+
# generic object (usually a Hash), return directly
|
241
|
+
value
|
242
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
243
|
+
inner_type = Regexp.last_match[:inner_type]
|
244
|
+
value.map { |v| _deserialize(inner_type, v) }
|
245
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
246
|
+
k_type = Regexp.last_match[:k_type]
|
247
|
+
v_type = Regexp.last_match[:v_type]
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each do |k, v|
|
250
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
else # model
|
254
|
+
temp_model = SwaggerClient.const_get(type).new
|
255
|
+
temp_model.build_from_hash(value)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# Returns the string representation of the object
|
260
|
+
# @return [String] String presentation of the object
|
261
|
+
def to_s
|
262
|
+
to_hash.to_s
|
263
|
+
end
|
264
|
+
|
265
|
+
# to_body is an alias to to_hash (backward compatibility)
|
266
|
+
# @return [Hash] Returns the object in the form of hash
|
267
|
+
def to_body
|
268
|
+
to_hash
|
269
|
+
end
|
270
|
+
|
271
|
+
# Returns the object in the form of hash
|
272
|
+
# @return [Hash] Returns the object in the form of hash
|
273
|
+
def to_hash
|
274
|
+
hash = {}
|
275
|
+
self.class.attribute_map.each_pair do |attr, param|
|
276
|
+
value = send(attr)
|
277
|
+
next if value.nil?
|
278
|
+
|
279
|
+
hash[param] = _to_hash(value)
|
280
|
+
end
|
281
|
+
hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# Outputs non-array value in the form of hash
|
285
|
+
# For object, use to_hash. Otherwise, just return the value
|
286
|
+
# @param [Object] value Any valid value
|
287
|
+
# @return [Hash] Returns the value in the form of hash
|
288
|
+
def _to_hash(value)
|
289
|
+
if value.is_a?(Array)
|
290
|
+
value.compact.map { |v| _to_hash(v) }
|
291
|
+
elsif value.is_a?(Hash)
|
292
|
+
{}.tap do |hash|
|
293
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
294
|
+
end
|
295
|
+
elsif value.respond_to? :to_hash
|
296
|
+
value.to_hash
|
297
|
+
else
|
298
|
+
value
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
@@ -0,0 +1,190 @@
|
|
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
|
+
class ProviderInformation
|
17
|
+
attr_accessor :provider_code, :reference_identification
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
'provider_code': :providerCode,
|
23
|
+
'reference_identification': :referenceIdentification
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.swagger_types
|
29
|
+
{
|
30
|
+
'provider_code': :String,
|
31
|
+
'reference_identification': :String
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.transform_keys(&:to_sym)
|
42
|
+
|
43
|
+
self.provider_code = attributes[:providerCode] if attributes.key?(:providerCode)
|
44
|
+
|
45
|
+
self.reference_identification = attributes[:referenceIdentification] if attributes.key?(:referenceIdentification)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
49
|
+
# @return Array for valid properties with the reasons
|
50
|
+
def list_invalid_properties
|
51
|
+
[]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check to see if the all the properties in the model are valid
|
55
|
+
# @return true if the model is valid
|
56
|
+
def valid?
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
# Checks equality by comparing each attribute.
|
61
|
+
# @param [Object] Object to be compared
|
62
|
+
def ==(o)
|
63
|
+
return true if equal?(o)
|
64
|
+
|
65
|
+
self.class == o.class &&
|
66
|
+
provider_code == o.provider_code &&
|
67
|
+
reference_identification == o.reference_identification
|
68
|
+
end
|
69
|
+
|
70
|
+
# @see the `==` method
|
71
|
+
# @param [Object] Object to be compared
|
72
|
+
def eql?(o)
|
73
|
+
self == o
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculates hash code according to all attributes.
|
77
|
+
# @return [Fixnum] Hash code
|
78
|
+
def hash
|
79
|
+
[provider_code, reference_identification].hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds the object from hash
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
# @return [Object] Returns the model itself
|
85
|
+
def build_from_hash(attributes)
|
86
|
+
return nil unless attributes.is_a?(Hash)
|
87
|
+
|
88
|
+
self.class.swagger_types.each_pair do |key, type|
|
89
|
+
if type =~ /\AArray<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
+
send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
|
94
|
+
end
|
95
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
+
send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
+
end
|
99
|
+
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
# Deserializes the data based on type
|
104
|
+
# @param string type Data type
|
105
|
+
# @param string value Value to be deserialized
|
106
|
+
# @return [Object] Deserialized data
|
107
|
+
def _deserialize(type, value)
|
108
|
+
case type.to_sym
|
109
|
+
when :DateTime
|
110
|
+
DateTime.parse(value)
|
111
|
+
when :Date
|
112
|
+
Date.parse(value)
|
113
|
+
when :String
|
114
|
+
value.to_s
|
115
|
+
when :Integer
|
116
|
+
value.to_i
|
117
|
+
when :Float
|
118
|
+
value.to_f
|
119
|
+
when :BOOLEAN
|
120
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
+
true
|
122
|
+
else
|
123
|
+
false
|
124
|
+
end
|
125
|
+
when :Object
|
126
|
+
# generic object (usually a Hash), return directly
|
127
|
+
value
|
128
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
+
inner_type = Regexp.last_match[:inner_type]
|
130
|
+
value.map { |v| _deserialize(inner_type, v) }
|
131
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
+
k_type = Regexp.last_match[:k_type]
|
133
|
+
v_type = Regexp.last_match[:v_type]
|
134
|
+
{}.tap do |hash|
|
135
|
+
value.each do |k, v|
|
136
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
else # model
|
140
|
+
temp_model = SwaggerClient.const_get(type).new
|
141
|
+
temp_model.build_from_hash(value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the string representation of the object
|
146
|
+
# @return [String] String presentation of the object
|
147
|
+
def to_s
|
148
|
+
to_hash.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# to_body is an alias to to_hash (backward compatibility)
|
152
|
+
# @return [Hash] Returns the object in the form of hash
|
153
|
+
def to_body
|
154
|
+
to_hash
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the object in the form of hash
|
158
|
+
# @return [Hash] Returns the object in the form of hash
|
159
|
+
def to_hash
|
160
|
+
hash = {}
|
161
|
+
self.class.attribute_map.each_pair do |attr, param|
|
162
|
+
value = send(attr)
|
163
|
+
next if value.nil?
|
164
|
+
|
165
|
+
hash[param] = _to_hash(value)
|
166
|
+
end
|
167
|
+
hash
|
168
|
+
end
|
169
|
+
|
170
|
+
# Outputs non-array value in the form of hash
|
171
|
+
# For object, use to_hash. Otherwise, just return the value
|
172
|
+
# @param [Object] value Any valid value
|
173
|
+
# @return [Hash] Returns the value in the form of hash
|
174
|
+
def _to_hash(value)
|
175
|
+
if value.is_a?(Array)
|
176
|
+
value.compact.map { |v| _to_hash(v) }
|
177
|
+
elsif value.is_a?(Hash)
|
178
|
+
{}.tap do |hash|
|
179
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
180
|
+
end
|
181
|
+
elsif value.respond_to? :to_hash
|
182
|
+
value.to_hash
|
183
|
+
else
|
184
|
+
value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|