finnhub_ruby 1.1.18 → 1.1.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/docs/BondTickData.md +6 -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 +312 -92
  10. data/docs/Dividends.md +3 -1
  11. data/docs/DocumentResponse.md +28 -0
  12. data/docs/ETFHoldingsData.md +3 -1
  13. data/docs/EarningResult.md +5 -1
  14. data/docs/ExcerptResponse.md +24 -0
  15. data/docs/FilingResponse.md +42 -0
  16. data/docs/InFilingResponse.md +44 -0
  17. data/docs/InFilingSearchBody.md +20 -0
  18. data/docs/MutualFundEet.md +20 -0
  19. data/docs/MutualFundEetPai.md +20 -0
  20. data/docs/MutualFundHoldingsData.md +3 -1
  21. data/docs/PriceMetrics.md +2 -0
  22. data/docs/SearchBody.md +60 -0
  23. data/docs/SearchFilter.md +20 -0
  24. data/docs/SearchResponse.md +24 -0
  25. data/finnhub_ruby-1.1.18.gem +0 -0
  26. data/lib/finnhub_ruby/api/default_api.rb +296 -86
  27. data/lib/finnhub_ruby/models/bond_tick_data.rb +37 -1
  28. data/lib/finnhub_ruby/models/bond_yield_curve.rb +231 -0
  29. data/lib/finnhub_ruby/models/bond_yield_curve_info.rb +229 -0
  30. data/lib/finnhub_ruby/models/company_profile.rb +22 -2
  31. data/lib/finnhub_ruby/models/congressional_trading.rb +231 -0
  32. data/lib/finnhub_ruby/models/congressional_transaction.rb +309 -0
  33. data/lib/finnhub_ruby/models/dividends.rb +14 -4
  34. data/lib/finnhub_ruby/models/document_response.rb +271 -0
  35. data/lib/finnhub_ruby/models/earning_result.rb +24 -4
  36. data/lib/finnhub_ruby/models/etf_holdings_data.rb +14 -4
  37. data/lib/finnhub_ruby/models/excerpt_response.rb +249 -0
  38. data/lib/finnhub_ruby/models/filing_response.rb +339 -0
  39. data/lib/finnhub_ruby/models/in_filing_response.rb +351 -0
  40. data/lib/finnhub_ruby/models/in_filing_search_body.rb +239 -0
  41. data/lib/finnhub_ruby/models/mutual_fund_eet.rb +228 -0
  42. data/lib/finnhub_ruby/models/mutual_fund_eet_pai.rb +228 -0
  43. data/lib/finnhub_ruby/models/mutual_fund_holdings_data.rb +14 -4
  44. data/lib/finnhub_ruby/models/price_metrics.rb +11 -1
  45. data/lib/finnhub_ruby/models/search_body.rb +434 -0
  46. data/lib/finnhub_ruby/models/search_filter.rb +229 -0
  47. data/lib/finnhub_ruby/models/search_response.rb +251 -0
  48. data/lib/finnhub_ruby/version.rb +1 -1
  49. data/lib/finnhub_ruby.rb +14 -0
  50. data/spec/models/bond_yield_curve_info_spec.rb +40 -0
  51. data/spec/models/bond_yield_curve_spec.rb +40 -0
  52. data/spec/models/congressional_trading_spec.rb +40 -0
  53. data/spec/models/congressional_transaction_spec.rb +88 -0
  54. data/spec/models/document_response_spec.rb +64 -0
  55. data/spec/models/excerpt_response_spec.rb +52 -0
  56. data/spec/models/filing_response_spec.rb +106 -0
  57. data/spec/models/in_filing_response_spec.rb +112 -0
  58. data/spec/models/in_filing_search_body_spec.rb +40 -0
  59. data/spec/models/mutual_fund_eet_pai_spec.rb +40 -0
  60. data/spec/models/mutual_fund_eet_spec.rb +40 -0
  61. data/spec/models/search_body_spec.rb +160 -0
  62. data/spec/models/search_filter_spec.rb +40 -0
  63. data/spec/models/search_response_spec.rb +52 -0
  64. metadata +60 -3
@@ -0,0 +1,271 @@
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 DocumentResponse
18
+ # AlphaResearch internal document id.
19
+ attr_accessor :document_id
20
+
21
+ # Title for this document.
22
+ attr_accessor :title
23
+
24
+ # Number of hit in this document
25
+ attr_accessor :hits
26
+
27
+ # Link to render this document
28
+ attr_accessor :url
29
+
30
+ # Format of this document (can be html or pdf)
31
+ attr_accessor :format
32
+
33
+ # Highlighted excerpts for this document
34
+ attr_accessor :excerpts
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'document_id' => :'documentId',
40
+ :'title' => :'title',
41
+ :'hits' => :'hits',
42
+ :'url' => :'url',
43
+ :'format' => :'format',
44
+ :'excerpts' => :'excerpts'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'document_id' => :'String',
57
+ :'title' => :'String',
58
+ :'hits' => :'String',
59
+ :'url' => :'String',
60
+ :'format' => :'String',
61
+ :'excerpts' => :'Array<ExcerptResponse>'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::DocumentResponse` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::DocumentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'document_id')
87
+ self.document_id = attributes[:'document_id']
88
+ end
89
+
90
+ if attributes.key?(:'title')
91
+ self.title = attributes[:'title']
92
+ end
93
+
94
+ if attributes.key?(:'hits')
95
+ self.hits = attributes[:'hits']
96
+ end
97
+
98
+ if attributes.key?(:'url')
99
+ self.url = attributes[:'url']
100
+ end
101
+
102
+ if attributes.key?(:'format')
103
+ self.format = attributes[:'format']
104
+ end
105
+
106
+ if attributes.key?(:'excerpts')
107
+ if (value = attributes[:'excerpts']).is_a?(Array)
108
+ self.excerpts = value
109
+ end
110
+ end
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ invalid_properties = Array.new
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ true
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ document_id == o.document_id &&
132
+ title == o.title &&
133
+ hits == o.hits &&
134
+ url == o.url &&
135
+ format == o.format &&
136
+ excerpts == o.excerpts
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [document_id, title, hits, url, format, excerpts].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ new.build_from_hash(attributes)
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ self.class.openapi_types.each_pair do |key, type|
164
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
165
+ self.send("#{key}=", nil)
166
+ elsif type =~ /\AArray<(.*)>/i
167
+ # check to ensure the input is an array given that the attribute
168
+ # is documented as an array but the input is not
169
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
170
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
171
+ end
172
+ elsif !attributes[self.class.attribute_map[key]].nil?
173
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
174
+ end
175
+ end
176
+
177
+ self
178
+ end
179
+
180
+ # Deserializes the data based on type
181
+ # @param string type Data type
182
+ # @param string value Value to be deserialized
183
+ # @return [Object] Deserialized data
184
+ def _deserialize(type, value)
185
+ case type.to_sym
186
+ when :Time
187
+ Time.parse(value)
188
+ when :Date
189
+ Date.parse(value)
190
+ when :String
191
+ value.to_s
192
+ when :Integer
193
+ value.to_i
194
+ when :Float
195
+ value.to_f
196
+ when :Boolean
197
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
198
+ true
199
+ else
200
+ false
201
+ end
202
+ when :Object
203
+ # generic object (usually a Hash), return directly
204
+ value
205
+ when /\AArray<(?<inner_type>.+)>\z/
206
+ inner_type = Regexp.last_match[:inner_type]
207
+ value.map { |v| _deserialize(inner_type, v) }
208
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
209
+ k_type = Regexp.last_match[:k_type]
210
+ v_type = Regexp.last_match[:v_type]
211
+ {}.tap do |hash|
212
+ value.each do |k, v|
213
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
214
+ end
215
+ end
216
+ else # model
217
+ # models (e.g. Pet) or oneOf
218
+ klass = FinnhubRuby.const_get(type)
219
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
220
+ end
221
+ end
222
+
223
+ # Returns the string representation of the object
224
+ # @return [String] String presentation of the object
225
+ def to_s
226
+ to_hash.to_s
227
+ end
228
+
229
+ # to_body is an alias to to_hash (backward compatibility)
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_body
232
+ to_hash
233
+ end
234
+
235
+ # Returns the object in the form of hash
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_hash
238
+ hash = {}
239
+ self.class.attribute_map.each_pair do |attr, param|
240
+ value = self.send(attr)
241
+ if value.nil?
242
+ is_nullable = self.class.openapi_nullable.include?(attr)
243
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
244
+ end
245
+
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+
269
+ end
270
+
271
+ end
@@ -33,6 +33,12 @@ module FinnhubRuby
33
33
  # Company symbol.
34
34
  attr_accessor :symbol
35
35
 
36
+ # Earnings year.
37
+ attr_accessor :year
38
+
39
+ # Earnings quarter.
40
+ attr_accessor :quarter
41
+
36
42
  # Attribute mapping from ruby-style variable name to JSON key.
37
43
  def self.attribute_map
38
44
  {
@@ -41,7 +47,9 @@ module FinnhubRuby
41
47
  :'surprise' => :'surprise',
42
48
  :'surprise_percent' => :'surprisePercent',
43
49
  :'period' => :'period',
44
- :'symbol' => :'symbol'
50
+ :'symbol' => :'symbol',
51
+ :'year' => :'year',
52
+ :'quarter' => :'quarter'
45
53
  }
46
54
  end
47
55
 
@@ -58,7 +66,9 @@ module FinnhubRuby
58
66
  :'surprise' => :'Float',
59
67
  :'surprise_percent' => :'Float',
60
68
  :'period' => :'Date',
61
- :'symbol' => :'String'
69
+ :'symbol' => :'String',
70
+ :'year' => :'Integer',
71
+ :'quarter' => :'Integer'
62
72
  }
63
73
  end
64
74
 
@@ -106,6 +116,14 @@ module FinnhubRuby
106
116
  if attributes.key?(:'symbol')
107
117
  self.symbol = attributes[:'symbol']
108
118
  end
119
+
120
+ if attributes.key?(:'year')
121
+ self.year = attributes[:'year']
122
+ end
123
+
124
+ if attributes.key?(:'quarter')
125
+ self.quarter = attributes[:'quarter']
126
+ end
109
127
  end
110
128
 
111
129
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -131,7 +149,9 @@ module FinnhubRuby
131
149
  surprise == o.surprise &&
132
150
  surprise_percent == o.surprise_percent &&
133
151
  period == o.period &&
134
- symbol == o.symbol
152
+ symbol == o.symbol &&
153
+ year == o.year &&
154
+ quarter == o.quarter
135
155
  end
136
156
 
137
157
  # @see the `==` method
@@ -143,7 +163,7 @@ module FinnhubRuby
143
163
  # Calculates hash code according to all attributes.
144
164
  # @return [Integer] Hash code
145
165
  def hash
146
- [actual, estimate, surprise, surprise_percent, period, symbol].hash
166
+ [actual, estimate, surprise, surprise_percent, period, symbol, year, quarter].hash
147
167
  end
148
168
 
149
169
  # Builds the object from hash
@@ -36,6 +36,9 @@ module FinnhubRuby
36
36
  # Market value
37
37
  attr_accessor :value
38
38
 
39
+ # Asset type. Can be 1 of the following values: <code>Equity</code>, <code>ETP</code>, <code>Fund</code>, <code>Bond</code>, <code>Other</code> or empty.
40
+ attr_accessor :asset_type
41
+
39
42
  # Attribute mapping from ruby-style variable name to JSON key.
40
43
  def self.attribute_map
41
44
  {
@@ -45,7 +48,8 @@ module FinnhubRuby
45
48
  :'cusip' => :'cusip',
46
49
  :'share' => :'share',
47
50
  :'percent' => :'percent',
48
- :'value' => :'value'
51
+ :'value' => :'value',
52
+ :'asset_type' => :'assetType'
49
53
  }
50
54
  end
51
55
 
@@ -63,7 +67,8 @@ module FinnhubRuby
63
67
  :'cusip' => :'String',
64
68
  :'share' => :'Float',
65
69
  :'percent' => :'Float',
66
- :'value' => :'Float'
70
+ :'value' => :'Float',
71
+ :'asset_type' => :'String'
67
72
  }
68
73
  end
69
74
 
@@ -115,6 +120,10 @@ module FinnhubRuby
115
120
  if attributes.key?(:'value')
116
121
  self.value = attributes[:'value']
117
122
  end
123
+
124
+ if attributes.key?(:'asset_type')
125
+ self.asset_type = attributes[:'asset_type']
126
+ end
118
127
  end
119
128
 
120
129
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -141,7 +150,8 @@ module FinnhubRuby
141
150
  cusip == o.cusip &&
142
151
  share == o.share &&
143
152
  percent == o.percent &&
144
- value == o.value
153
+ value == o.value &&
154
+ asset_type == o.asset_type
145
155
  end
146
156
 
147
157
  # @see the `==` method
@@ -153,7 +163,7 @@ module FinnhubRuby
153
163
  # Calculates hash code according to all attributes.
154
164
  # @return [Integer] Hash code
155
165
  def hash
156
- [symbol, name, isin, cusip, share, percent, value].hash
166
+ [symbol, name, isin, cusip, share, percent, value, asset_type].hash
157
167
  end
158
168
 
159
169
  # Builds the object from hash
@@ -0,0 +1,249 @@
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 ExcerptResponse
18
+ # Highlighted content
19
+ attr_accessor :content
20
+
21
+ # Location of the content in the rendered document
22
+ attr_accessor :snippet_id
23
+
24
+ # Start offset of highlighted content
25
+ attr_accessor :start_offset
26
+
27
+ # End offset of highlighted content
28
+ attr_accessor :end_offset
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'content' => :'content',
34
+ :'snippet_id' => :'snippetId',
35
+ :'start_offset' => :'startOffset',
36
+ :'end_offset' => :'endOffset'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'content' => :'String',
49
+ :'snippet_id' => :'String',
50
+ :'start_offset' => :'String',
51
+ :'end_offset' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::ExcerptResponse` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::ExcerptResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'content')
77
+ self.content = attributes[:'content']
78
+ end
79
+
80
+ if attributes.key?(:'snippet_id')
81
+ self.snippet_id = attributes[:'snippet_id']
82
+ end
83
+
84
+ if attributes.key?(:'start_offset')
85
+ self.start_offset = attributes[:'start_offset']
86
+ end
87
+
88
+ if attributes.key?(:'end_offset')
89
+ self.end_offset = attributes[:'end_offset']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ content == o.content &&
112
+ snippet_id == o.snippet_id &&
113
+ start_offset == o.start_offset &&
114
+ end_offset == o.end_offset
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [content, snippet_id, start_offset, end_offset].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.openapi_types.each_pair do |key, type|
142
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
143
+ self.send("#{key}=", nil)
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = FinnhubRuby.const_get(type)
197
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end