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,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 HealthCheck
|
17
|
+
attr_accessor :status, :version
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
'status': :status,
|
23
|
+
'version': :version
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.swagger_types
|
29
|
+
{
|
30
|
+
'status': :String,
|
31
|
+
'version': :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.status = attributes[:status] if attributes.key?(:status)
|
44
|
+
|
45
|
+
self.version = attributes[:version] if attributes.key?(:version)
|
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
|
+
status == o.status &&
|
67
|
+
version == o.version
|
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
|
+
[status, version].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
|
@@ -0,0 +1,303 @@
|
|
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, Notes: Information Receiver Name
|
17
|
+
class InformationReceiverName
|
18
|
+
# Loop: 2100B, Segment: N3 and N4, Notes: Information Receiver Address
|
19
|
+
attr_accessor :address
|
20
|
+
|
21
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=CT Contact Number
|
22
|
+
attr_accessor :contact_number
|
23
|
+
|
24
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=EL Electronic Device Pin Number
|
25
|
+
attr_accessor :device_pin_number
|
26
|
+
|
27
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=1J Facility ID Number
|
28
|
+
attr_accessor :facility_id_number
|
29
|
+
|
30
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=N7 Facility Network Identification Number
|
31
|
+
attr_accessor :facility_network_id_number
|
32
|
+
|
33
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=TJ Federal Taxpayer’s Identification Number
|
34
|
+
attr_accessor :federal_taxpayer_identification_number
|
35
|
+
|
36
|
+
# Loop: 2100B, Segment: REF, Element: REF03, Notes: REF01=0B REF02=stateLicenceNumber Federal Taxpayer’s Identification Number
|
37
|
+
attr_accessor :information_receiver_additional_identifier_state
|
38
|
+
|
39
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=1D Medicaid Provider Number
|
40
|
+
attr_accessor :medicaid_provider_number
|
41
|
+
|
42
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=1C Medicare Provider Number
|
43
|
+
attr_accessor :medicare_provider_number
|
44
|
+
|
45
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=HPI Centers for Medicare and Medicaid Services National Provider Identifier
|
46
|
+
attr_accessor :national_provider_identifier
|
47
|
+
|
48
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=Q4 Prior Identifier Number
|
49
|
+
attr_accessor :prior_identifier_number
|
50
|
+
|
51
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=N5 Provider Plan Network Identification Number
|
52
|
+
attr_accessor :provider_plan_network_id_number
|
53
|
+
|
54
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=SY Social Security Number
|
55
|
+
attr_accessor :social_security_number
|
56
|
+
|
57
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=0B State License Number
|
58
|
+
attr_accessor :state_licence_number
|
59
|
+
|
60
|
+
# Loop: 2100B, Segment: REF, Element: REF02, Notes: REF01=EO Submitter Identification Number
|
61
|
+
attr_accessor :submitter_id_number
|
62
|
+
|
63
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
64
|
+
def self.attribute_map
|
65
|
+
{
|
66
|
+
'address': :address,
|
67
|
+
'contact_number': :contactNumber,
|
68
|
+
'device_pin_number': :devicePinNumber,
|
69
|
+
'facility_id_number': :facilityIdNumber,
|
70
|
+
'facility_network_id_number': :facilityNetworkIdNumber,
|
71
|
+
'federal_taxpayer_identification_number': :federalTaxpayerIdentificationNumber,
|
72
|
+
'information_receiver_additional_identifier_state': :informationReceiverAdditionalIdentifierState,
|
73
|
+
'medicaid_provider_number': :medicaidProviderNumber,
|
74
|
+
'medicare_provider_number': :medicareProviderNumber,
|
75
|
+
'national_provider_identifier': :nationalProviderIdentifier,
|
76
|
+
'prior_identifier_number': :priorIdentifierNumber,
|
77
|
+
'provider_plan_network_id_number': :providerPlanNetworkIdNumber,
|
78
|
+
'social_security_number': :socialSecurityNumber,
|
79
|
+
'state_licence_number': :stateLicenceNumber,
|
80
|
+
'submitter_id_number': :submitterIdNumber
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# Attribute type mapping.
|
85
|
+
def self.swagger_types
|
86
|
+
{
|
87
|
+
'address': :Address,
|
88
|
+
'contact_number': :String,
|
89
|
+
'device_pin_number': :String,
|
90
|
+
'facility_id_number': :String,
|
91
|
+
'facility_network_id_number': :String,
|
92
|
+
'federal_taxpayer_identification_number': :String,
|
93
|
+
'information_receiver_additional_identifier_state': :String,
|
94
|
+
'medicaid_provider_number': :String,
|
95
|
+
'medicare_provider_number': :String,
|
96
|
+
'national_provider_identifier': :String,
|
97
|
+
'prior_identifier_number': :String,
|
98
|
+
'provider_plan_network_id_number': :String,
|
99
|
+
'social_security_number': :String,
|
100
|
+
'state_licence_number': :String,
|
101
|
+
'submitter_id_number': :String
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
# Initializes the object
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
def initialize(attributes = {})
|
108
|
+
return unless attributes.is_a?(Hash)
|
109
|
+
|
110
|
+
# convert string to symbol for hash key
|
111
|
+
attributes = attributes.transform_keys(&:to_sym)
|
112
|
+
|
113
|
+
self.address = attributes[:address] if attributes.key?(:address)
|
114
|
+
|
115
|
+
self.contact_number = attributes[:contactNumber] if attributes.key?(:contactNumber)
|
116
|
+
|
117
|
+
self.device_pin_number = attributes[:devicePinNumber] if attributes.key?(:devicePinNumber)
|
118
|
+
|
119
|
+
self.facility_id_number = attributes[:facilityIdNumber] if attributes.key?(:facilityIdNumber)
|
120
|
+
|
121
|
+
self.facility_network_id_number = attributes[:facilityNetworkIdNumber] if attributes.key?(:facilityNetworkIdNumber)
|
122
|
+
|
123
|
+
if attributes.key?(:federalTaxpayerIdentificationNumber)
|
124
|
+
self.federal_taxpayer_identification_number = attributes[:federalTaxpayerIdentificationNumber]
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:informationReceiverAdditionalIdentifierState)
|
128
|
+
self.information_receiver_additional_identifier_state = attributes[:informationReceiverAdditionalIdentifierState]
|
129
|
+
end
|
130
|
+
|
131
|
+
self.medicaid_provider_number = attributes[:medicaidProviderNumber] if attributes.key?(:medicaidProviderNumber)
|
132
|
+
|
133
|
+
self.medicare_provider_number = attributes[:medicareProviderNumber] if attributes.key?(:medicareProviderNumber)
|
134
|
+
|
135
|
+
self.national_provider_identifier = attributes[:nationalProviderIdentifier] if attributes.key?(:nationalProviderIdentifier)
|
136
|
+
|
137
|
+
self.prior_identifier_number = attributes[:priorIdentifierNumber] if attributes.key?(:priorIdentifierNumber)
|
138
|
+
|
139
|
+
self.provider_plan_network_id_number = attributes[:providerPlanNetworkIdNumber] if attributes.key?(:providerPlanNetworkIdNumber)
|
140
|
+
|
141
|
+
self.social_security_number = attributes[:socialSecurityNumber] if attributes.key?(:socialSecurityNumber)
|
142
|
+
|
143
|
+
self.state_licence_number = attributes[:stateLicenceNumber] if attributes.key?(:stateLicenceNumber)
|
144
|
+
|
145
|
+
self.submitter_id_number = attributes[:submitterIdNumber] if attributes.key?(:submitterIdNumber)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
149
|
+
# @return Array for valid properties with the reasons
|
150
|
+
def list_invalid_properties
|
151
|
+
[]
|
152
|
+
end
|
153
|
+
|
154
|
+
# Check to see if the all the properties in the model are valid
|
155
|
+
# @return true if the model is valid
|
156
|
+
def valid?
|
157
|
+
true
|
158
|
+
end
|
159
|
+
|
160
|
+
# Checks equality by comparing each attribute.
|
161
|
+
# @param [Object] Object to be compared
|
162
|
+
def ==(o)
|
163
|
+
return true if equal?(o)
|
164
|
+
|
165
|
+
self.class == o.class &&
|
166
|
+
address == o.address &&
|
167
|
+
contact_number == o.contact_number &&
|
168
|
+
device_pin_number == o.device_pin_number &&
|
169
|
+
facility_id_number == o.facility_id_number &&
|
170
|
+
facility_network_id_number == o.facility_network_id_number &&
|
171
|
+
federal_taxpayer_identification_number == o.federal_taxpayer_identification_number &&
|
172
|
+
information_receiver_additional_identifier_state == o.information_receiver_additional_identifier_state &&
|
173
|
+
medicaid_provider_number == o.medicaid_provider_number &&
|
174
|
+
medicare_provider_number == o.medicare_provider_number &&
|
175
|
+
national_provider_identifier == o.national_provider_identifier &&
|
176
|
+
prior_identifier_number == o.prior_identifier_number &&
|
177
|
+
provider_plan_network_id_number == o.provider_plan_network_id_number &&
|
178
|
+
social_security_number == o.social_security_number &&
|
179
|
+
state_licence_number == o.state_licence_number &&
|
180
|
+
submitter_id_number == o.submitter_id_number
|
181
|
+
end
|
182
|
+
|
183
|
+
# @see the `==` method
|
184
|
+
# @param [Object] Object to be compared
|
185
|
+
def eql?(o)
|
186
|
+
self == o
|
187
|
+
end
|
188
|
+
|
189
|
+
# Calculates hash code according to all attributes.
|
190
|
+
# @return [Fixnum] Hash code
|
191
|
+
def hash
|
192
|
+
[address, contact_number, device_pin_number, facility_id_number, facility_network_id_number, federal_taxpayer_identification_number, information_receiver_additional_identifier_state, medicaid_provider_number, medicare_provider_number, national_provider_identifier, prior_identifier_number, provider_plan_network_id_number, social_security_number, state_licence_number, submitter_id_number].hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Builds the object from hash
|
196
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
197
|
+
# @return [Object] Returns the model itself
|
198
|
+
def build_from_hash(attributes)
|
199
|
+
return nil unless attributes.is_a?(Hash)
|
200
|
+
|
201
|
+
self.class.swagger_types.each_pair do |key, type|
|
202
|
+
if type =~ /\AArray<(.*)>/i
|
203
|
+
# check to ensure the input is an array given that the attribute
|
204
|
+
# is documented as an array but the input is not
|
205
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
206
|
+
send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
|
207
|
+
end
|
208
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
209
|
+
send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
210
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
211
|
+
end
|
212
|
+
|
213
|
+
self
|
214
|
+
end
|
215
|
+
|
216
|
+
# Deserializes the data based on type
|
217
|
+
# @param string type Data type
|
218
|
+
# @param string value Value to be deserialized
|
219
|
+
# @return [Object] Deserialized data
|
220
|
+
def _deserialize(type, value)
|
221
|
+
case type.to_sym
|
222
|
+
when :DateTime
|
223
|
+
DateTime.parse(value)
|
224
|
+
when :Date
|
225
|
+
Date.parse(value)
|
226
|
+
when :String
|
227
|
+
value.to_s
|
228
|
+
when :Integer
|
229
|
+
value.to_i
|
230
|
+
when :Float
|
231
|
+
value.to_f
|
232
|
+
when :BOOLEAN
|
233
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
234
|
+
true
|
235
|
+
else
|
236
|
+
false
|
237
|
+
end
|
238
|
+
when :Object
|
239
|
+
# generic object (usually a Hash), return directly
|
240
|
+
value
|
241
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
242
|
+
inner_type = Regexp.last_match[:inner_type]
|
243
|
+
value.map { |v| _deserialize(inner_type, v) }
|
244
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
245
|
+
k_type = Regexp.last_match[:k_type]
|
246
|
+
v_type = Regexp.last_match[:v_type]
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each do |k, v|
|
249
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
else # model
|
253
|
+
temp_model = SwaggerClient.const_get(type).new
|
254
|
+
temp_model.build_from_hash(value)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
# Returns the string representation of the object
|
259
|
+
# @return [String] String presentation of the object
|
260
|
+
def to_s
|
261
|
+
to_hash.to_s
|
262
|
+
end
|
263
|
+
|
264
|
+
# to_body is an alias to to_hash (backward compatibility)
|
265
|
+
# @return [Hash] Returns the object in the form of hash
|
266
|
+
def to_body
|
267
|
+
to_hash
|
268
|
+
end
|
269
|
+
|
270
|
+
# Returns the object in the form of hash
|
271
|
+
# @return [Hash] Returns the object in the form of hash
|
272
|
+
def to_hash
|
273
|
+
hash = {}
|
274
|
+
self.class.attribute_map.each_pair do |attr, param|
|
275
|
+
value = send(attr)
|
276
|
+
next if value.nil?
|
277
|
+
|
278
|
+
hash[param] = _to_hash(value)
|
279
|
+
end
|
280
|
+
hash
|
281
|
+
end
|
282
|
+
|
283
|
+
# Outputs non-array value in the form of hash
|
284
|
+
# For object, use to_hash. Otherwise, just return the value
|
285
|
+
# @param [Object] value Any valid value
|
286
|
+
# @return [Hash] Returns the value in the form of hash
|
287
|
+
def _to_hash(value)
|
288
|
+
if value.is_a?(Array)
|
289
|
+
value.compact.map { |v| _to_hash(v) }
|
290
|
+
elsif value.is_a?(Hash)
|
291
|
+
{}.tap do |hash|
|
292
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
293
|
+
end
|
294
|
+
elsif value.respond_to? :to_hash
|
295
|
+
value.to_hash
|
296
|
+
else
|
297
|
+
value
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|