psi_eligibility 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/README.md +123 -0
- data/Rakefile +8 -0
- data/docs/AdditionalAttributeModel.md +9 -0
- data/docs/CandidateModel.md +24 -0
- data/docs/DefaultApi.md +411 -0
- data/docs/EligibilityModel.md +13 -0
- data/docs/EligibilityResponseModel.md +8 -0
- data/docs/ErrorModel.md +9 -0
- data/docs/ExistingEligibilityModel.md +18 -0
- data/docs/TestLaunchInfoModel.md +8 -0
- data/git_push.sh +55 -0
- data/lib/psi_eligibility.rb +47 -0
- data/lib/psi_eligibility/api/default_api.rb +454 -0
- data/lib/psi_eligibility/api_client.rb +389 -0
- data/lib/psi_eligibility/api_error.rb +38 -0
- data/lib/psi_eligibility/configuration.rb +216 -0
- data/lib/psi_eligibility/models/additional_attribute_model.rb +195 -0
- data/lib/psi_eligibility/models/candidate_model.rb +350 -0
- data/lib/psi_eligibility/models/eligibility_model.rb +246 -0
- data/lib/psi_eligibility/models/eligibility_response_model.rb +184 -0
- data/lib/psi_eligibility/models/error_model.rb +194 -0
- data/lib/psi_eligibility/models/existing_eligibility_model.rb +320 -0
- data/lib/psi_eligibility/models/test_launch_info_model.rb +183 -0
- data/lib/psi_eligibility/version.rb +15 -0
- data/psi_eligibility-1.0.0.gem +0 -0
- data/psi_eligibility.gemspec +45 -0
- data/spec/api/default_api_spec.rb +130 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/additional_attribute_model_spec.rb +47 -0
- data/spec/models/candidate_model_spec.rb +137 -0
- data/spec/models/eligibility_model_spec.rb +71 -0
- data/spec/models/eligibility_response_model_spec.rb +41 -0
- data/spec/models/error_model_spec.rb +47 -0
- data/spec/models/existing_eligibility_model_spec.rb +105 -0
- data/spec/models/test_launch_info_model_spec.rb +41 -0
- data/spec/spec_helper.rb +111 -0
- metadata +272 -0
@@ -0,0 +1,195 @@
|
|
1
|
+
=begin
|
2
|
+
#PSI Candidate Rest Eligibility Service
|
3
|
+
|
4
|
+
#PSIs REST based service to modify candidate test eligibilities.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.10
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PsiEligibility
|
16
|
+
# An additional attribute can be any piece of candidate specific data not covered by the standard parameters. These must be agreed upon prior to the first eligiblity added by PSI.
|
17
|
+
class AdditionalAttributeModel
|
18
|
+
# The vlaue of the additional attribute.
|
19
|
+
attr_accessor :value
|
20
|
+
|
21
|
+
# The key agreed upon by PSI and the client in advanced to store a custom candidate attribute.
|
22
|
+
attr_accessor :key
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'value' => :'value',
|
28
|
+
:'key' => :'key'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.swagger_types
|
34
|
+
{
|
35
|
+
:'value' => :'String',
|
36
|
+
:'key' => :'String'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Initializes the object
|
41
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
+
def initialize(attributes = {})
|
43
|
+
return unless attributes.is_a?(Hash)
|
44
|
+
|
45
|
+
# convert string to symbol for hash key
|
46
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
47
|
+
|
48
|
+
if attributes.has_key?(:'value')
|
49
|
+
self.value = attributes[:'value']
|
50
|
+
end
|
51
|
+
|
52
|
+
if attributes.has_key?(:'key')
|
53
|
+
self.key = attributes[:'key']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
58
|
+
# @return Array for valid properties with the reasons
|
59
|
+
def list_invalid_properties
|
60
|
+
invalid_properties = Array.new
|
61
|
+
invalid_properties
|
62
|
+
end
|
63
|
+
|
64
|
+
# Check to see if the all the properties in the model are valid
|
65
|
+
# @return true if the model is valid
|
66
|
+
def valid?
|
67
|
+
true
|
68
|
+
end
|
69
|
+
|
70
|
+
# Checks equality by comparing each attribute.
|
71
|
+
# @param [Object] Object to be compared
|
72
|
+
def ==(o)
|
73
|
+
return true if self.equal?(o)
|
74
|
+
self.class == o.class &&
|
75
|
+
value == o.value &&
|
76
|
+
key == o.key
|
77
|
+
end
|
78
|
+
|
79
|
+
# @see the `==` method
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def eql?(o)
|
82
|
+
self == o
|
83
|
+
end
|
84
|
+
|
85
|
+
# Calculates hash code according to all attributes.
|
86
|
+
# @return [Fixnum] Hash code
|
87
|
+
def hash
|
88
|
+
[value, key].hash
|
89
|
+
end
|
90
|
+
|
91
|
+
# Builds the object from hash
|
92
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
93
|
+
# @return [Object] Returns the model itself
|
94
|
+
def build_from_hash(attributes)
|
95
|
+
return nil unless attributes.is_a?(Hash)
|
96
|
+
self.class.swagger_types.each_pair do |key, type|
|
97
|
+
if type =~ /\AArray<(.*)>/i
|
98
|
+
# check to ensure the input is an array given that the the attribute
|
99
|
+
# is documented as an array but the input is not
|
100
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
101
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
102
|
+
end
|
103
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
104
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
105
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
106
|
+
end
|
107
|
+
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
# Deserializes the data based on type
|
112
|
+
# @param string type Data type
|
113
|
+
# @param string value Value to be deserialized
|
114
|
+
# @return [Object] Deserialized data
|
115
|
+
def _deserialize(type, value)
|
116
|
+
case type.to_sym
|
117
|
+
when :DateTime
|
118
|
+
DateTime.parse(value)
|
119
|
+
when :Date
|
120
|
+
Date.parse(value)
|
121
|
+
when :String
|
122
|
+
value.to_s
|
123
|
+
when :Integer
|
124
|
+
value.to_i
|
125
|
+
when :Float
|
126
|
+
value.to_f
|
127
|
+
when :BOOLEAN
|
128
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
129
|
+
true
|
130
|
+
else
|
131
|
+
false
|
132
|
+
end
|
133
|
+
when :Object
|
134
|
+
# generic object (usually a Hash), return directly
|
135
|
+
value
|
136
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
137
|
+
inner_type = Regexp.last_match[:inner_type]
|
138
|
+
value.map { |v| _deserialize(inner_type, v) }
|
139
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
140
|
+
k_type = Regexp.last_match[:k_type]
|
141
|
+
v_type = Regexp.last_match[:v_type]
|
142
|
+
{}.tap do |hash|
|
143
|
+
value.each do |k, v|
|
144
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else # model
|
148
|
+
temp_model = PsiEligibility.const_get(type).new
|
149
|
+
temp_model.build_from_hash(value)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Returns the string representation of the object
|
154
|
+
# @return [String] String presentation of the object
|
155
|
+
def to_s
|
156
|
+
to_hash.to_s
|
157
|
+
end
|
158
|
+
|
159
|
+
# to_body is an alias to to_hash (backward compatibility)
|
160
|
+
# @return [Hash] Returns the object in the form of hash
|
161
|
+
def to_body
|
162
|
+
to_hash
|
163
|
+
end
|
164
|
+
|
165
|
+
# Returns the object in the form of hash
|
166
|
+
# @return [Hash] Returns the object in the form of hash
|
167
|
+
def to_hash
|
168
|
+
hash = {}
|
169
|
+
self.class.attribute_map.each_pair do |attr, param|
|
170
|
+
value = self.send(attr)
|
171
|
+
next if value.nil?
|
172
|
+
hash[param] = _to_hash(value)
|
173
|
+
end
|
174
|
+
hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# Outputs non-array value in the form of hash
|
178
|
+
# For object, use to_hash. Otherwise, just return the value
|
179
|
+
# @param [Object] value Any valid value
|
180
|
+
# @return [Hash] Returns the value in the form of hash
|
181
|
+
def _to_hash(value)
|
182
|
+
if value.is_a?(Array)
|
183
|
+
value.compact.map { |v| _to_hash(v) }
|
184
|
+
elsif value.is_a?(Hash)
|
185
|
+
{}.tap do |hash|
|
186
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
187
|
+
end
|
188
|
+
elsif value.respond_to? :to_hash
|
189
|
+
value.to_hash
|
190
|
+
else
|
191
|
+
value
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,350 @@
|
|
1
|
+
=begin
|
2
|
+
#PSI Candidate Rest Eligibility Service
|
3
|
+
|
4
|
+
#PSIs REST based service to modify candidate test eligibilities.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.10
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PsiEligibility
|
16
|
+
class CandidateModel
|
17
|
+
attr_accessor :country
|
18
|
+
|
19
|
+
attr_accessor :home_phone
|
20
|
+
|
21
|
+
# If supplied, the list of school codes must be added to PSI's system in advance of the import.
|
22
|
+
attr_accessor :school_code
|
23
|
+
|
24
|
+
attr_accessor :address2
|
25
|
+
|
26
|
+
attr_accessor :city
|
27
|
+
|
28
|
+
attr_accessor :address1
|
29
|
+
|
30
|
+
# The canidates province, state or equivilent.
|
31
|
+
attr_accessor :province_state
|
32
|
+
|
33
|
+
attr_accessor :last_name
|
34
|
+
|
35
|
+
attr_accessor :suffix
|
36
|
+
|
37
|
+
attr_accessor :middle_name
|
38
|
+
|
39
|
+
attr_accessor :special_accommodations
|
40
|
+
|
41
|
+
# The supplied candidates unique id.
|
42
|
+
attr_accessor :candidate_id
|
43
|
+
|
44
|
+
attr_accessor :office_phone
|
45
|
+
|
46
|
+
# Candidates zip code, postal code or equivilent.
|
47
|
+
attr_accessor :postal_code
|
48
|
+
|
49
|
+
attr_accessor :first_name
|
50
|
+
|
51
|
+
attr_accessor :email
|
52
|
+
|
53
|
+
attr_accessor :additional_attributes
|
54
|
+
|
55
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
56
|
+
def self.attribute_map
|
57
|
+
{
|
58
|
+
:'country' => :'country',
|
59
|
+
:'home_phone' => :'home_phone',
|
60
|
+
:'school_code' => :'school_code',
|
61
|
+
:'address2' => :'address2',
|
62
|
+
:'city' => :'city',
|
63
|
+
:'address1' => :'address1',
|
64
|
+
:'province_state' => :'province_state',
|
65
|
+
:'last_name' => :'last_name',
|
66
|
+
:'suffix' => :'suffix',
|
67
|
+
:'middle_name' => :'middle_name',
|
68
|
+
:'special_accommodations' => :'special_accommodations',
|
69
|
+
:'candidate_id' => :'candidate_id',
|
70
|
+
:'office_phone' => :'office_phone',
|
71
|
+
:'postal_code' => :'postal_code',
|
72
|
+
:'first_name' => :'first_name',
|
73
|
+
:'email' => :'email',
|
74
|
+
:'additional_attributes' => :'additional_attributes'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# Attribute type mapping.
|
79
|
+
def self.swagger_types
|
80
|
+
{
|
81
|
+
:'country' => :'String',
|
82
|
+
:'home_phone' => :'String',
|
83
|
+
:'school_code' => :'String',
|
84
|
+
:'address2' => :'String',
|
85
|
+
:'city' => :'String',
|
86
|
+
:'address1' => :'String',
|
87
|
+
:'province_state' => :'String',
|
88
|
+
:'last_name' => :'String',
|
89
|
+
:'suffix' => :'String',
|
90
|
+
:'middle_name' => :'String',
|
91
|
+
:'special_accommodations' => :'Array<String>',
|
92
|
+
:'candidate_id' => :'String',
|
93
|
+
:'office_phone' => :'String',
|
94
|
+
:'postal_code' => :'String',
|
95
|
+
:'first_name' => :'String',
|
96
|
+
:'email' => :'String',
|
97
|
+
:'additional_attributes' => :'Array<AdditionalAttributeModel>'
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Initializes the object
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
def initialize(attributes = {})
|
104
|
+
return unless attributes.is_a?(Hash)
|
105
|
+
|
106
|
+
# convert string to symbol for hash key
|
107
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
108
|
+
|
109
|
+
if attributes.has_key?(:'country')
|
110
|
+
self.country = attributes[:'country']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.has_key?(:'home_phone')
|
114
|
+
self.home_phone = attributes[:'home_phone']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'school_code')
|
118
|
+
self.school_code = attributes[:'school_code']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'address2')
|
122
|
+
self.address2 = attributes[:'address2']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'city')
|
126
|
+
self.city = attributes[:'city']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'address1')
|
130
|
+
self.address1 = attributes[:'address1']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'province_state')
|
134
|
+
self.province_state = attributes[:'province_state']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.has_key?(:'last_name')
|
138
|
+
self.last_name = attributes[:'last_name']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.has_key?(:'suffix')
|
142
|
+
self.suffix = attributes[:'suffix']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.has_key?(:'middle_name')
|
146
|
+
self.middle_name = attributes[:'middle_name']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.has_key?(:'special_accommodations')
|
150
|
+
if (value = attributes[:'special_accommodations']).is_a?(Array)
|
151
|
+
self.special_accommodations = value
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.has_key?(:'candidate_id')
|
156
|
+
self.candidate_id = attributes[:'candidate_id']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.has_key?(:'office_phone')
|
160
|
+
self.office_phone = attributes[:'office_phone']
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.has_key?(:'postal_code')
|
164
|
+
self.postal_code = attributes[:'postal_code']
|
165
|
+
end
|
166
|
+
|
167
|
+
if attributes.has_key?(:'first_name')
|
168
|
+
self.first_name = attributes[:'first_name']
|
169
|
+
end
|
170
|
+
|
171
|
+
if attributes.has_key?(:'email')
|
172
|
+
self.email = attributes[:'email']
|
173
|
+
end
|
174
|
+
|
175
|
+
if attributes.has_key?(:'additional_attributes')
|
176
|
+
if (value = attributes[:'additional_attributes']).is_a?(Array)
|
177
|
+
self.additional_attributes = value
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
183
|
+
# @return Array for valid properties with the reasons
|
184
|
+
def list_invalid_properties
|
185
|
+
invalid_properties = Array.new
|
186
|
+
if @last_name.nil?
|
187
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
188
|
+
end
|
189
|
+
|
190
|
+
if @candidate_id.nil?
|
191
|
+
invalid_properties.push('invalid value for "candidate_id", candidate_id cannot be nil.')
|
192
|
+
end
|
193
|
+
|
194
|
+
if @first_name.nil?
|
195
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
196
|
+
end
|
197
|
+
|
198
|
+
invalid_properties
|
199
|
+
end
|
200
|
+
|
201
|
+
# Check to see if the all the properties in the model are valid
|
202
|
+
# @return true if the model is valid
|
203
|
+
def valid?
|
204
|
+
return false if @last_name.nil?
|
205
|
+
return false if @candidate_id.nil?
|
206
|
+
return false if @first_name.nil?
|
207
|
+
true
|
208
|
+
end
|
209
|
+
|
210
|
+
# Checks equality by comparing each attribute.
|
211
|
+
# @param [Object] Object to be compared
|
212
|
+
def ==(o)
|
213
|
+
return true if self.equal?(o)
|
214
|
+
self.class == o.class &&
|
215
|
+
country == o.country &&
|
216
|
+
home_phone == o.home_phone &&
|
217
|
+
school_code == o.school_code &&
|
218
|
+
address2 == o.address2 &&
|
219
|
+
city == o.city &&
|
220
|
+
address1 == o.address1 &&
|
221
|
+
province_state == o.province_state &&
|
222
|
+
last_name == o.last_name &&
|
223
|
+
suffix == o.suffix &&
|
224
|
+
middle_name == o.middle_name &&
|
225
|
+
special_accommodations == o.special_accommodations &&
|
226
|
+
candidate_id == o.candidate_id &&
|
227
|
+
office_phone == o.office_phone &&
|
228
|
+
postal_code == o.postal_code &&
|
229
|
+
first_name == o.first_name &&
|
230
|
+
email == o.email &&
|
231
|
+
additional_attributes == o.additional_attributes
|
232
|
+
end
|
233
|
+
|
234
|
+
# @see the `==` method
|
235
|
+
# @param [Object] Object to be compared
|
236
|
+
def eql?(o)
|
237
|
+
self == o
|
238
|
+
end
|
239
|
+
|
240
|
+
# Calculates hash code according to all attributes.
|
241
|
+
# @return [Fixnum] Hash code
|
242
|
+
def hash
|
243
|
+
[country, home_phone, school_code, address2, city, address1, province_state, last_name, suffix, middle_name, special_accommodations, candidate_id, office_phone, postal_code, first_name, email, additional_attributes].hash
|
244
|
+
end
|
245
|
+
|
246
|
+
# Builds the object from hash
|
247
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
248
|
+
# @return [Object] Returns the model itself
|
249
|
+
def build_from_hash(attributes)
|
250
|
+
return nil unless attributes.is_a?(Hash)
|
251
|
+
self.class.swagger_types.each_pair do |key, type|
|
252
|
+
if type =~ /\AArray<(.*)>/i
|
253
|
+
# check to ensure the input is an array given that the the attribute
|
254
|
+
# is documented as an array but the input is not
|
255
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
256
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
257
|
+
end
|
258
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
259
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
260
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
261
|
+
end
|
262
|
+
|
263
|
+
self
|
264
|
+
end
|
265
|
+
|
266
|
+
# Deserializes the data based on type
|
267
|
+
# @param string type Data type
|
268
|
+
# @param string value Value to be deserialized
|
269
|
+
# @return [Object] Deserialized data
|
270
|
+
def _deserialize(type, value)
|
271
|
+
case type.to_sym
|
272
|
+
when :DateTime
|
273
|
+
DateTime.parse(value)
|
274
|
+
when :Date
|
275
|
+
Date.parse(value)
|
276
|
+
when :String
|
277
|
+
value.to_s
|
278
|
+
when :Integer
|
279
|
+
value.to_i
|
280
|
+
when :Float
|
281
|
+
value.to_f
|
282
|
+
when :BOOLEAN
|
283
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
284
|
+
true
|
285
|
+
else
|
286
|
+
false
|
287
|
+
end
|
288
|
+
when :Object
|
289
|
+
# generic object (usually a Hash), return directly
|
290
|
+
value
|
291
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
292
|
+
inner_type = Regexp.last_match[:inner_type]
|
293
|
+
value.map { |v| _deserialize(inner_type, v) }
|
294
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
295
|
+
k_type = Regexp.last_match[:k_type]
|
296
|
+
v_type = Regexp.last_match[:v_type]
|
297
|
+
{}.tap do |hash|
|
298
|
+
value.each do |k, v|
|
299
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
else # model
|
303
|
+
temp_model = PsiEligibility.const_get(type).new
|
304
|
+
temp_model.build_from_hash(value)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
# Returns the string representation of the object
|
309
|
+
# @return [String] String presentation of the object
|
310
|
+
def to_s
|
311
|
+
to_hash.to_s
|
312
|
+
end
|
313
|
+
|
314
|
+
# to_body is an alias to to_hash (backward compatibility)
|
315
|
+
# @return [Hash] Returns the object in the form of hash
|
316
|
+
def to_body
|
317
|
+
to_hash
|
318
|
+
end
|
319
|
+
|
320
|
+
# Returns the object in the form of hash
|
321
|
+
# @return [Hash] Returns the object in the form of hash
|
322
|
+
def to_hash
|
323
|
+
hash = {}
|
324
|
+
self.class.attribute_map.each_pair do |attr, param|
|
325
|
+
value = self.send(attr)
|
326
|
+
next if value.nil?
|
327
|
+
hash[param] = _to_hash(value)
|
328
|
+
end
|
329
|
+
hash
|
330
|
+
end
|
331
|
+
|
332
|
+
# Outputs non-array value in the form of hash
|
333
|
+
# For object, use to_hash. Otherwise, just return the value
|
334
|
+
# @param [Object] value Any valid value
|
335
|
+
# @return [Hash] Returns the value in the form of hash
|
336
|
+
def _to_hash(value)
|
337
|
+
if value.is_a?(Array)
|
338
|
+
value.compact.map { |v| _to_hash(v) }
|
339
|
+
elsif value.is_a?(Hash)
|
340
|
+
{}.tap do |hash|
|
341
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
342
|
+
end
|
343
|
+
elsif value.respond_to? :to_hash
|
344
|
+
value.to_hash
|
345
|
+
else
|
346
|
+
value
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|