finnhub_ruby 1.1.16 → 1.1.18

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/docs/BondTickData.md +34 -0
  4. data/docs/Company.md +1 -1
  5. data/docs/DefaultApi.md +617 -9
  6. data/docs/ETFProfileData.md +8 -2
  7. data/docs/InstitutionalOwnership.md +22 -0
  8. data/docs/InstitutionalOwnershipGroup.md +20 -0
  9. data/docs/InstitutionalOwnershipInfo.md +36 -0
  10. data/docs/InstitutionalPortfolio.md +22 -0
  11. data/docs/InstitutionalPortfolioGroup.md +22 -0
  12. data/docs/InstitutionalPortfolioInfo.md +38 -0
  13. data/docs/InstitutionalProfile.md +20 -0
  14. data/docs/InstitutionalProfileInfo.md +28 -0
  15. data/docs/IsinChange.md +22 -0
  16. data/docs/IsinChangeInfo.md +22 -0
  17. data/docs/KeyCustomersSuppliers.md +4 -0
  18. data/docs/MutualFundProfileData.md +5 -1
  19. data/docs/PriceMetrics.md +20 -0
  20. data/docs/SectorMetric.md +20 -0
  21. data/docs/SectorMetricData.md +20 -0
  22. data/docs/SymbolChange.md +22 -0
  23. data/docs/SymbolChangeInfo.md +22 -0
  24. data/finnhub_ruby-1.1.16.gem +0 -0
  25. data/finnhub_ruby-1.1.17.gem +0 -0
  26. data/lib/finnhub_ruby/api/default_api.rb +602 -8
  27. data/lib/finnhub_ruby/models/bond_tick_data.rb +311 -0
  28. data/lib/finnhub_ruby/models/company.rb +1 -1
  29. data/lib/finnhub_ruby/models/etf_profile_data.rb +35 -5
  30. data/lib/finnhub_ruby/models/institutional_ownership.rb +241 -0
  31. data/lib/finnhub_ruby/models/institutional_ownership_group.rb +231 -0
  32. data/lib/finnhub_ruby/models/institutional_ownership_info.rb +309 -0
  33. data/lib/finnhub_ruby/models/institutional_portfolio.rb +241 -0
  34. data/lib/finnhub_ruby/models/institutional_portfolio_group.rb +241 -0
  35. data/lib/finnhub_ruby/models/institutional_portfolio_info.rb +319 -0
  36. data/lib/finnhub_ruby/models/institutional_profile.rb +231 -0
  37. data/lib/finnhub_ruby/models/institutional_profile_info.rb +269 -0
  38. data/lib/finnhub_ruby/models/isin_change.rb +241 -0
  39. data/lib/finnhub_ruby/models/isin_change_info.rb +239 -0
  40. data/lib/finnhub_ruby/models/key_customers_suppliers.rb +21 -1
  41. data/lib/finnhub_ruby/models/mutual_fund_profile_data.rb +24 -4
  42. data/lib/finnhub_ruby/models/price_metrics.rb +228 -0
  43. data/lib/finnhub_ruby/models/sector_metric.rb +231 -0
  44. data/lib/finnhub_ruby/models/sector_metric_data.rb +229 -0
  45. data/lib/finnhub_ruby/models/symbol_change.rb +241 -0
  46. data/lib/finnhub_ruby/models/symbol_change_info.rb +239 -0
  47. data/lib/finnhub_ruby/version.rb +1 -1
  48. data/lib/finnhub_ruby.rb +16 -0
  49. data/spec/models/bond_tick_data_spec.rb +82 -0
  50. data/spec/models/institutional_ownership_group_spec.rb +40 -0
  51. data/spec/models/institutional_ownership_info_spec.rb +88 -0
  52. data/spec/models/institutional_ownership_spec.rb +46 -0
  53. data/spec/models/institutional_portfolio_group_spec.rb +46 -0
  54. data/spec/models/institutional_portfolio_info_spec.rb +94 -0
  55. data/spec/models/institutional_portfolio_spec.rb +46 -0
  56. data/spec/models/institutional_profile_info_spec.rb +64 -0
  57. data/spec/models/institutional_profile_spec.rb +40 -0
  58. data/spec/models/isin_change_info_spec.rb +46 -0
  59. data/spec/models/isin_change_spec.rb +46 -0
  60. data/spec/models/price_metrics_spec.rb +40 -0
  61. data/spec/models/sector_metric_data_spec.rb +40 -0
  62. data/spec/models/sector_metric_spec.rb +40 -0
  63. data/spec/models/symbol_change_info_spec.rb +46 -0
  64. data/spec/models/symbol_change_spec.rb +46 -0
  65. metadata +68 -2
@@ -0,0 +1,239 @@
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 IsinChangeInfo
18
+ # Event's date.
19
+ attr_accessor :at_date
20
+
21
+ # Old ISIN.
22
+ attr_accessor :old_isin
23
+
24
+ # New ISIN.
25
+ attr_accessor :new_isin
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'at_date' => :'atDate',
31
+ :'old_isin' => :'oldIsin',
32
+ :'new_isin' => :'newIsin'
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
+ :'at_date' => :'String',
45
+ :'old_isin' => :'String',
46
+ :'new_isin' => :'String'
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::IsinChangeInfo` 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::IsinChangeInfo`. 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?(:'at_date')
72
+ self.at_date = attributes[:'at_date']
73
+ end
74
+
75
+ if attributes.key?(:'old_isin')
76
+ self.old_isin = attributes[:'old_isin']
77
+ end
78
+
79
+ if attributes.key?(:'new_isin')
80
+ self.new_isin = attributes[:'new_isin']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ at_date == o.at_date &&
103
+ old_isin == o.old_isin &&
104
+ new_isin == o.new_isin
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [at_date, old_isin, new_isin].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ new.build_from_hash(attributes)
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
+ self.send("#{key}=", nil)
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = FinnhubRuby.const_get(type)
187
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end
@@ -21,6 +21,12 @@ module FinnhubRuby
21
21
  # Name
22
22
  attr_accessor :name
23
23
 
24
+ # Country
25
+ attr_accessor :country
26
+
27
+ # Industry
28
+ attr_accessor :industry
29
+
24
30
  # Whether the company is a customer.
25
31
  attr_accessor :customer
26
32
 
@@ -50,6 +56,8 @@ module FinnhubRuby
50
56
  {
51
57
  :'symbol' => :'symbol',
52
58
  :'name' => :'name',
59
+ :'country' => :'country',
60
+ :'industry' => :'industry',
53
61
  :'customer' => :'customer',
54
62
  :'supplier' => :'supplier',
55
63
  :'one_month_correlation' => :'oneMonthCorrelation',
@@ -71,6 +79,8 @@ module FinnhubRuby
71
79
  {
72
80
  :'symbol' => :'String',
73
81
  :'name' => :'String',
82
+ :'country' => :'String',
83
+ :'industry' => :'String',
74
84
  :'customer' => :'Boolean',
75
85
  :'supplier' => :'Boolean',
76
86
  :'one_month_correlation' => :'Float',
@@ -111,6 +121,14 @@ module FinnhubRuby
111
121
  self.name = attributes[:'name']
112
122
  end
113
123
 
124
+ if attributes.key?(:'country')
125
+ self.country = attributes[:'country']
126
+ end
127
+
128
+ if attributes.key?(:'industry')
129
+ self.industry = attributes[:'industry']
130
+ end
131
+
114
132
  if attributes.key?(:'customer')
115
133
  self.customer = attributes[:'customer']
116
134
  end
@@ -164,6 +182,8 @@ module FinnhubRuby
164
182
  self.class == o.class &&
165
183
  symbol == o.symbol &&
166
184
  name == o.name &&
185
+ country == o.country &&
186
+ industry == o.industry &&
167
187
  customer == o.customer &&
168
188
  supplier == o.supplier &&
169
189
  one_month_correlation == o.one_month_correlation &&
@@ -183,7 +203,7 @@ module FinnhubRuby
183
203
  # Calculates hash code according to all attributes.
184
204
  # @return [Integer] Hash code
185
205
  def hash
186
- [symbol, name, customer, supplier, one_month_correlation, one_year_correlation, six_month_correlation, three_month_correlation, two_week_correlation, two_year_correlation].hash
206
+ [symbol, name, country, industry, customer, supplier, one_month_correlation, one_year_correlation, six_month_correlation, three_month_correlation, two_week_correlation, two_year_correlation].hash
187
207
  end
188
208
 
189
209
  # Builds the object from hash
@@ -90,6 +90,12 @@ module FinnhubRuby
90
90
  # Class name.
91
91
  attr_accessor :class_name
92
92
 
93
+ # SFDR classification for EU funds. Under the new classifications, a fund's strategy will labeled under either Article 6, 8 or 9. Article 6 covers funds which do not integrate any kind of sustainability into the investment process. Article 8, also known as ‘environmental and socially promoting’, applies “… where a financial product promotes, among other characteristics, environmental or social characteristics, or a combination of those characteristics, provided that the companies in which the investments are made follow good governance practices.”. Article 9, also known as ‘products targeting sustainable investments’, covers products targeting bespoke sustainable investments and applies “… where a financial product has sustainable investment as its objective and an index has been designated as a reference benchmark.”
94
+ attr_accessor :sfdr_classification
95
+
96
+ # Fund's currency
97
+ attr_accessor :currency
98
+
93
99
  # Attribute mapping from ruby-style variable name to JSON key.
94
100
  def self.attribute_map
95
101
  {
@@ -117,7 +123,9 @@ module FinnhubRuby
117
123
  :'series_id' => :'seriesId',
118
124
  :'series_name' => :'seriesName',
119
125
  :'class_id' => :'classId',
120
- :'class_name' => :'className'
126
+ :'class_name' => :'className',
127
+ :'sfdr_classification' => :'sfdrClassification',
128
+ :'currency' => :'currency'
121
129
  }
122
130
  end
123
131
 
@@ -153,7 +161,9 @@ module FinnhubRuby
153
161
  :'series_id' => :'String',
154
162
  :'series_name' => :'String',
155
163
  :'class_id' => :'String',
156
- :'class_name' => :'String'
164
+ :'class_name' => :'String',
165
+ :'sfdr_classification' => :'String',
166
+ :'currency' => :'String'
157
167
  }
158
168
  end
159
169
 
@@ -277,6 +287,14 @@ module FinnhubRuby
277
287
  if attributes.key?(:'class_name')
278
288
  self.class_name = attributes[:'class_name']
279
289
  end
290
+
291
+ if attributes.key?(:'sfdr_classification')
292
+ self.sfdr_classification = attributes[:'sfdr_classification']
293
+ end
294
+
295
+ if attributes.key?(:'currency')
296
+ self.currency = attributes[:'currency']
297
+ end
280
298
  end
281
299
 
282
300
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -321,7 +339,9 @@ module FinnhubRuby
321
339
  series_id == o.series_id &&
322
340
  series_name == o.series_name &&
323
341
  class_id == o.class_id &&
324
- class_name == o.class_name
342
+ class_name == o.class_name &&
343
+ sfdr_classification == o.sfdr_classification &&
344
+ currency == o.currency
325
345
  end
326
346
 
327
347
  # @see the `==` method
@@ -333,7 +353,7 @@ module FinnhubRuby
333
353
  # Calculates hash code according to all attributes.
334
354
  # @return [Integer] Hash code
335
355
  def hash
336
- [name, category, investment_segment, total_nav, expense_ratio, benchmark, inception_date, description, fund_family, manager, status, beta, deferred_load, fee12b1, front_load, ira_min_investment, isin, cusip, max_redemption_fee, standard_min_investment, turnover, series_id, series_name, class_id, class_name].hash
356
+ [name, category, investment_segment, total_nav, expense_ratio, benchmark, inception_date, description, fund_family, manager, status, beta, deferred_load, fee12b1, front_load, ira_min_investment, isin, cusip, max_redemption_fee, standard_min_investment, turnover, series_id, series_name, class_id, class_name, sfdr_classification, currency].hash
337
357
  end
338
358
 
339
359
  # Builds the object from hash
@@ -0,0 +1,228 @@
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 PriceMetrics
18
+ # Symbol of the company.
19
+ attr_accessor :symbol
20
+
21
+ attr_accessor :data
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'symbol' => :'symbol',
27
+ :'data' => :'data'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'symbol' => :'String',
40
+ :'data' => :'Object'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::PriceMetrics` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::PriceMetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'symbol')
66
+ self.symbol = attributes[:'symbol']
67
+ end
68
+
69
+ if attributes.key?(:'data')
70
+ self.data = attributes[:'data']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ symbol == o.symbol &&
93
+ data == o.data
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Integer] Hash code
104
+ def hash
105
+ [symbol, data].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def self.build_from_hash(attributes)
112
+ new.build_from_hash(attributes)
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.openapi_types.each_pair do |key, type|
121
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
122
+ self.send("#{key}=", nil)
123
+ elsif type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the attribute
125
+ # is documented as an array but the input is not
126
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
127
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
128
+ end
129
+ elsif !attributes[self.class.attribute_map[key]].nil?
130
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
131
+ end
132
+ end
133
+
134
+ self
135
+ end
136
+
137
+ # Deserializes the data based on type
138
+ # @param string type Data type
139
+ # @param string value Value to be deserialized
140
+ # @return [Object] Deserialized data
141
+ def _deserialize(type, value)
142
+ case type.to_sym
143
+ when :Time
144
+ Time.parse(value)
145
+ when :Date
146
+ Date.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :Boolean
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ # models (e.g. Pet) or oneOf
175
+ klass = FinnhubRuby.const_get(type)
176
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ end