finnhub_ruby 1.1.17 → 1.1.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/docs/BondTickData.md +40 -0
  4. data/docs/BondYieldCurve.md +20 -0
  5. data/docs/BondYieldCurveInfo.md +20 -0
  6. data/docs/CompanyProfile.md +5 -1
  7. data/docs/CongressionalTrading.md +20 -0
  8. data/docs/CongressionalTransaction.md +36 -0
  9. data/docs/DefaultApi.md +849 -93
  10. data/docs/Dividends.md +3 -1
  11. data/docs/DocumentResponse.md +28 -0
  12. data/docs/ETFHoldingsData.md +3 -1
  13. data/docs/ETFProfileData.md +8 -2
  14. data/docs/EarningResult.md +5 -1
  15. data/docs/ExcerptResponse.md +24 -0
  16. data/docs/FilingResponse.md +42 -0
  17. data/docs/InFilingResponse.md +44 -0
  18. data/docs/InFilingSearchBody.md +20 -0
  19. data/docs/InstitutionalOwnership.md +22 -0
  20. data/docs/InstitutionalOwnershipGroup.md +20 -0
  21. data/docs/InstitutionalOwnershipInfo.md +36 -0
  22. data/docs/InstitutionalPortfolio.md +22 -0
  23. data/docs/InstitutionalPortfolioGroup.md +22 -0
  24. data/docs/InstitutionalPortfolioInfo.md +38 -0
  25. data/docs/InstitutionalProfile.md +20 -0
  26. data/docs/InstitutionalProfileInfo.md +28 -0
  27. data/docs/IsinChange.md +22 -0
  28. data/docs/IsinChangeInfo.md +22 -0
  29. data/docs/MutualFundEet.md +20 -0
  30. data/docs/MutualFundEetPai.md +20 -0
  31. data/docs/MutualFundHoldingsData.md +3 -1
  32. data/docs/PriceMetrics.md +22 -0
  33. data/docs/SearchBody.md +60 -0
  34. data/docs/SearchFilter.md +20 -0
  35. data/docs/SearchResponse.md +24 -0
  36. data/docs/SymbolChange.md +22 -0
  37. data/docs/SymbolChangeInfo.md +22 -0
  38. data/finnhub_ruby-1.1.17.gem +0 -0
  39. data/finnhub_ruby-1.1.18.gem +0 -0
  40. data/lib/finnhub_ruby/api/default_api.rb +835 -95
  41. data/lib/finnhub_ruby/models/bond_tick_data.rb +347 -0
  42. data/lib/finnhub_ruby/models/bond_yield_curve.rb +231 -0
  43. data/lib/finnhub_ruby/models/bond_yield_curve_info.rb +229 -0
  44. data/lib/finnhub_ruby/models/company_profile.rb +22 -2
  45. data/lib/finnhub_ruby/models/congressional_trading.rb +231 -0
  46. data/lib/finnhub_ruby/models/congressional_transaction.rb +309 -0
  47. data/lib/finnhub_ruby/models/dividends.rb +14 -4
  48. data/lib/finnhub_ruby/models/document_response.rb +271 -0
  49. data/lib/finnhub_ruby/models/earning_result.rb +24 -4
  50. data/lib/finnhub_ruby/models/etf_holdings_data.rb +14 -4
  51. data/lib/finnhub_ruby/models/etf_profile_data.rb +35 -5
  52. data/lib/finnhub_ruby/models/excerpt_response.rb +249 -0
  53. data/lib/finnhub_ruby/models/filing_response.rb +339 -0
  54. data/lib/finnhub_ruby/models/in_filing_response.rb +351 -0
  55. data/lib/finnhub_ruby/models/in_filing_search_body.rb +239 -0
  56. data/lib/finnhub_ruby/models/institutional_ownership.rb +241 -0
  57. data/lib/finnhub_ruby/models/institutional_ownership_group.rb +231 -0
  58. data/lib/finnhub_ruby/models/institutional_ownership_info.rb +309 -0
  59. data/lib/finnhub_ruby/models/institutional_portfolio.rb +241 -0
  60. data/lib/finnhub_ruby/models/institutional_portfolio_group.rb +241 -0
  61. data/lib/finnhub_ruby/models/institutional_portfolio_info.rb +319 -0
  62. data/lib/finnhub_ruby/models/institutional_profile.rb +231 -0
  63. data/lib/finnhub_ruby/models/institutional_profile_info.rb +269 -0
  64. data/lib/finnhub_ruby/models/isin_change.rb +241 -0
  65. data/lib/finnhub_ruby/models/isin_change_info.rb +239 -0
  66. data/lib/finnhub_ruby/models/mutual_fund_eet.rb +228 -0
  67. data/lib/finnhub_ruby/models/mutual_fund_eet_pai.rb +228 -0
  68. data/lib/finnhub_ruby/models/mutual_fund_holdings_data.rb +14 -4
  69. data/lib/finnhub_ruby/models/price_metrics.rb +238 -0
  70. data/lib/finnhub_ruby/models/search_body.rb +434 -0
  71. data/lib/finnhub_ruby/models/search_filter.rb +229 -0
  72. data/lib/finnhub_ruby/models/search_response.rb +251 -0
  73. data/lib/finnhub_ruby/models/symbol_change.rb +241 -0
  74. data/lib/finnhub_ruby/models/symbol_change_info.rb +239 -0
  75. data/lib/finnhub_ruby/version.rb +1 -1
  76. data/lib/finnhub_ruby.rb +28 -0
  77. data/spec/models/bond_tick_data_spec.rb +82 -0
  78. data/spec/models/bond_yield_curve_info_spec.rb +40 -0
  79. data/spec/models/bond_yield_curve_spec.rb +40 -0
  80. data/spec/models/congressional_trading_spec.rb +40 -0
  81. data/spec/models/congressional_transaction_spec.rb +88 -0
  82. data/spec/models/document_response_spec.rb +64 -0
  83. data/spec/models/excerpt_response_spec.rb +52 -0
  84. data/spec/models/filing_response_spec.rb +106 -0
  85. data/spec/models/in_filing_response_spec.rb +112 -0
  86. data/spec/models/in_filing_search_body_spec.rb +40 -0
  87. data/spec/models/institutional_ownership_group_spec.rb +40 -0
  88. data/spec/models/institutional_ownership_info_spec.rb +88 -0
  89. data/spec/models/institutional_ownership_spec.rb +46 -0
  90. data/spec/models/institutional_portfolio_group_spec.rb +46 -0
  91. data/spec/models/institutional_portfolio_info_spec.rb +94 -0
  92. data/spec/models/institutional_portfolio_spec.rb +46 -0
  93. data/spec/models/institutional_profile_info_spec.rb +64 -0
  94. data/spec/models/institutional_profile_spec.rb +40 -0
  95. data/spec/models/isin_change_info_spec.rb +46 -0
  96. data/spec/models/isin_change_spec.rb +46 -0
  97. data/spec/models/mutual_fund_eet_pai_spec.rb +40 -0
  98. data/spec/models/mutual_fund_eet_spec.rb +40 -0
  99. data/spec/models/price_metrics_spec.rb +40 -0
  100. data/spec/models/search_body_spec.rb +160 -0
  101. data/spec/models/search_filter_spec.rb +40 -0
  102. data/spec/models/search_response_spec.rb +52 -0
  103. data/spec/models/symbol_change_info_spec.rb +46 -0
  104. data/spec/models/symbol_change_spec.rb +46 -0
  105. metadata +117 -3
@@ -0,0 +1,309 @@
1
+ =begin
2
+ #Finnhub API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FinnhubRuby
17
+ class InstitutionalOwnershipInfo
18
+ # Investor's company CIK.
19
+ attr_accessor :cik
20
+
21
+ # Firm's name.
22
+ attr_accessor :name
23
+
24
+ # <code>put</code> or <code>call</code> for options.
25
+ attr_accessor :put_call
26
+
27
+ # Number of shares change.
28
+ attr_accessor :change
29
+
30
+ # Number of shares with no voting rights.
31
+ attr_accessor :no_voting
32
+
33
+ # Percentage of portfolio.
34
+ attr_accessor :percentage
35
+
36
+ # News score.
37
+ attr_accessor :share
38
+
39
+ # Number of shares with shared voting rights.
40
+ attr_accessor :shared_voting
41
+
42
+ # Number of shares with sole voting rights.
43
+ attr_accessor :sole_voting
44
+
45
+ # Position value.
46
+ attr_accessor :value
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'cik' => :'cik',
52
+ :'name' => :'name',
53
+ :'put_call' => :'putCall',
54
+ :'change' => :'change',
55
+ :'no_voting' => :'noVoting',
56
+ :'percentage' => :'percentage',
57
+ :'share' => :'share',
58
+ :'shared_voting' => :'sharedVoting',
59
+ :'sole_voting' => :'soleVoting',
60
+ :'value' => :'value'
61
+ }
62
+ end
63
+
64
+ # Returns all the JSON keys this model knows about
65
+ def self.acceptable_attributes
66
+ attribute_map.values
67
+ end
68
+
69
+ # Attribute type mapping.
70
+ def self.openapi_types
71
+ {
72
+ :'cik' => :'String',
73
+ :'name' => :'String',
74
+ :'put_call' => :'String',
75
+ :'change' => :'Float',
76
+ :'no_voting' => :'Float',
77
+ :'percentage' => :'Float',
78
+ :'share' => :'Float',
79
+ :'shared_voting' => :'Float',
80
+ :'sole_voting' => :'Float',
81
+ :'value' => :'Float'
82
+ }
83
+ end
84
+
85
+ # List of attributes with nullable: true
86
+ def self.openapi_nullable
87
+ Set.new([
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::InstitutionalOwnershipInfo` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::InstitutionalOwnershipInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'cik')
107
+ self.cik = attributes[:'cik']
108
+ end
109
+
110
+ if attributes.key?(:'name')
111
+ self.name = attributes[:'name']
112
+ end
113
+
114
+ if attributes.key?(:'put_call')
115
+ self.put_call = attributes[:'put_call']
116
+ end
117
+
118
+ if attributes.key?(:'change')
119
+ self.change = attributes[:'change']
120
+ end
121
+
122
+ if attributes.key?(:'no_voting')
123
+ self.no_voting = attributes[:'no_voting']
124
+ end
125
+
126
+ if attributes.key?(:'percentage')
127
+ self.percentage = attributes[:'percentage']
128
+ end
129
+
130
+ if attributes.key?(:'share')
131
+ self.share = attributes[:'share']
132
+ end
133
+
134
+ if attributes.key?(:'shared_voting')
135
+ self.shared_voting = attributes[:'shared_voting']
136
+ end
137
+
138
+ if attributes.key?(:'sole_voting')
139
+ self.sole_voting = attributes[:'sole_voting']
140
+ end
141
+
142
+ if attributes.key?(:'value')
143
+ self.value = attributes[:'value']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ invalid_properties
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 self.equal?(o)
164
+ self.class == o.class &&
165
+ cik == o.cik &&
166
+ name == o.name &&
167
+ put_call == o.put_call &&
168
+ change == o.change &&
169
+ no_voting == o.no_voting &&
170
+ percentage == o.percentage &&
171
+ share == o.share &&
172
+ shared_voting == o.shared_voting &&
173
+ sole_voting == o.sole_voting &&
174
+ value == o.value
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Integer] Hash code
185
+ def hash
186
+ [cik, name, put_call, change, no_voting, percentage, share, shared_voting, sole_voting, value].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def self.build_from_hash(attributes)
193
+ new.build_from_hash(attributes)
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
+ self.class.openapi_types.each_pair do |key, type|
202
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
203
+ self.send("#{key}=", nil)
204
+ elsif type =~ /\AArray<(.*)>/i
205
+ # check to ensure the input is an array given that the attribute
206
+ # is documented as an array but the input is not
207
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
208
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
209
+ end
210
+ elsif !attributes[self.class.attribute_map[key]].nil?
211
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
212
+ end
213
+ end
214
+
215
+ self
216
+ end
217
+
218
+ # Deserializes the data based on type
219
+ # @param string type Data type
220
+ # @param string value Value to be deserialized
221
+ # @return [Object] Deserialized data
222
+ def _deserialize(type, value)
223
+ case type.to_sym
224
+ when :Time
225
+ Time.parse(value)
226
+ when :Date
227
+ Date.parse(value)
228
+ when :String
229
+ value.to_s
230
+ when :Integer
231
+ value.to_i
232
+ when :Float
233
+ value.to_f
234
+ when :Boolean
235
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
236
+ true
237
+ else
238
+ false
239
+ end
240
+ when :Object
241
+ # generic object (usually a Hash), return directly
242
+ value
243
+ when /\AArray<(?<inner_type>.+)>\z/
244
+ inner_type = Regexp.last_match[:inner_type]
245
+ value.map { |v| _deserialize(inner_type, v) }
246
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
247
+ k_type = Regexp.last_match[:k_type]
248
+ v_type = Regexp.last_match[:v_type]
249
+ {}.tap do |hash|
250
+ value.each do |k, v|
251
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
252
+ end
253
+ end
254
+ else # model
255
+ # models (e.g. Pet) or oneOf
256
+ klass = FinnhubRuby.const_get(type)
257
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
258
+ end
259
+ end
260
+
261
+ # Returns the string representation of the object
262
+ # @return [String] String presentation of the object
263
+ def to_s
264
+ to_hash.to_s
265
+ end
266
+
267
+ # to_body is an alias to to_hash (backward compatibility)
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_body
270
+ to_hash
271
+ end
272
+
273
+ # Returns the object in the form of hash
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_hash
276
+ hash = {}
277
+ self.class.attribute_map.each_pair do |attr, param|
278
+ value = self.send(attr)
279
+ if value.nil?
280
+ is_nullable = self.class.openapi_nullable.include?(attr)
281
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
282
+ end
283
+
284
+ hash[param] = _to_hash(value)
285
+ end
286
+ hash
287
+ end
288
+
289
+ # Outputs non-array value in the form of hash
290
+ # For object, use to_hash. Otherwise, just return the value
291
+ # @param [Object] value Any valid value
292
+ # @return [Hash] Returns the value in the form of hash
293
+ def _to_hash(value)
294
+ if value.is_a?(Array)
295
+ value.compact.map { |v| _to_hash(v) }
296
+ elsif value.is_a?(Hash)
297
+ {}.tap do |hash|
298
+ value.each { |k, v| hash[k] = _to_hash(v) }
299
+ end
300
+ elsif value.respond_to? :to_hash
301
+ value.to_hash
302
+ else
303
+ value
304
+ end
305
+ end
306
+
307
+ end
308
+
309
+ end
@@ -0,0 +1,241 @@
1
+ =begin
2
+ #Finnhub API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module FinnhubRuby
17
+ class InstitutionalPortfolio
18
+ # Investor's name.
19
+ attr_accessor :name
20
+
21
+ # CIK.
22
+ attr_accessor :cik
23
+
24
+ # Array of positions.
25
+ attr_accessor :data
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'name' => :'name',
31
+ :'cik' => :'cik',
32
+ :'data' => :'data'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'name' => :'String',
45
+ :'cik' => :'String',
46
+ :'data' => :'Array<InstitutionalPortfolioGroup>'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::InstitutionalPortfolio` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::InstitutionalPortfolio`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'name')
72
+ self.name = attributes[:'name']
73
+ end
74
+
75
+ if attributes.key?(:'cik')
76
+ self.cik = attributes[:'cik']
77
+ end
78
+
79
+ if attributes.key?(:'data')
80
+ if (value = attributes[:'data']).is_a?(Array)
81
+ self.data = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ name == o.name &&
105
+ cik == o.cik &&
106
+ data == o.data
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [name, cik, data].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ new.build_from_hash(attributes)
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ self.class.openapi_types.each_pair do |key, type|
134
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
135
+ self.send("#{key}=", nil)
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :Time
157
+ Time.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :Boolean
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ # models (e.g. Pet) or oneOf
188
+ klass = FinnhubRuby.const_get(type)
189
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ if value.nil?
212
+ is_nullable = self.class.openapi_nullable.include?(attr)
213
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
214
+ end
215
+
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+
239
+ end
240
+
241
+ end