finnhub_ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +201 -0
  4. data/README.md +164 -0
  5. data/Rakefile +10 -0
  6. data/docs/AggregateIndicators.md +19 -0
  7. data/docs/BasicFinancials.md +21 -0
  8. data/docs/Company.md +29 -0
  9. data/docs/CompanyExecutive.md +19 -0
  10. data/docs/CompanyNewsStatistics.md +21 -0
  11. data/docs/CompanyProfile.md +71 -0
  12. data/docs/CompanyProfile2.md +39 -0
  13. data/docs/CountryMetadata.md +27 -0
  14. data/docs/CovidInfo.md +23 -0
  15. data/docs/CryptoCandles.md +29 -0
  16. data/docs/CryptoSymbol.md +21 -0
  17. data/docs/DefaultApi.md +2662 -0
  18. data/docs/Development.md +23 -0
  19. data/docs/Dividends.md +31 -0
  20. data/docs/EarningEstimate.md +25 -0
  21. data/docs/EarningRelease.md +33 -0
  22. data/docs/EarningResult.md +23 -0
  23. data/docs/EarningsCalendar.md +17 -0
  24. data/docs/EarningsCallTranscripts.md +33 -0
  25. data/docs/EarningsCallTranscriptsList.md +19 -0
  26. data/docs/EarningsEstimates.md +21 -0
  27. data/docs/EconomicCalendar.md +17 -0
  28. data/docs/EconomicCode.md +23 -0
  29. data/docs/EconomicData.md +19 -0
  30. data/docs/EconomicEvent.md +31 -0
  31. data/docs/Estimate.md +25 -0
  32. data/docs/Filing.md +31 -0
  33. data/docs/FinancialStatements.md +19 -0
  34. data/docs/FinancialsAsReported.md +21 -0
  35. data/docs/ForexCandles.md +29 -0
  36. data/docs/ForexSymbol.md +21 -0
  37. data/docs/Forexrates.md +19 -0
  38. data/docs/FundOwnership.md +19 -0
  39. data/docs/IPOCalendar.md +17 -0
  40. data/docs/IPOEvent.md +31 -0
  41. data/docs/Indicator.md +21 -0
  42. data/docs/Investor.md +23 -0
  43. data/docs/InvestorsOwnership.md +19 -0
  44. data/docs/LastBidAsk.md +25 -0
  45. data/docs/MajorDevelopments.md +19 -0
  46. data/docs/News.md +33 -0
  47. data/docs/NewsSentiment.md +27 -0
  48. data/docs/PatternRecognition.md +17 -0
  49. data/docs/PriceTarget.md +27 -0
  50. data/docs/Quote.md +25 -0
  51. data/docs/RecommendationTrend.md +29 -0
  52. data/docs/Report.md +37 -0
  53. data/docs/RevenueEstimates.md +21 -0
  54. data/docs/Sentiment.md +19 -0
  55. data/docs/Split.md +23 -0
  56. data/docs/Stock.md +21 -0
  57. data/docs/StockCandles.md +29 -0
  58. data/docs/StockTranscripts.md +25 -0
  59. data/docs/SupportResistance.md +17 -0
  60. data/docs/TechnicalAnalysis.md +19 -0
  61. data/docs/TickData.md +31 -0
  62. data/docs/TranscriptContent.md +19 -0
  63. data/docs/TranscriptParticipant.md +19 -0
  64. data/docs/Trend.md +17 -0
  65. data/docs/UpgradeDowngrade.md +27 -0
  66. data/finnhub_ruby-0.0.1.gem +0 -0
  67. data/finnhub_ruby-0.0.2.gem +0 -0
  68. data/finnhub_ruby.gemspec +39 -0
  69. data/git_push.sh +58 -0
  70. data/lib/finnhub_ruby.rb +99 -0
  71. data/lib/finnhub_ruby/api/default_api.rb +3142 -0
  72. data/lib/finnhub_ruby/api_client.rb +389 -0
  73. data/lib/finnhub_ruby/api_error.rb +57 -0
  74. data/lib/finnhub_ruby/configuration.rb +248 -0
  75. data/lib/finnhub_ruby/models/aggregate_indicators.rb +215 -0
  76. data/lib/finnhub_ruby/models/basic_financials.rb +226 -0
  77. data/lib/finnhub_ruby/models/company.rb +267 -0
  78. data/lib/finnhub_ruby/models/company_executive.rb +219 -0
  79. data/lib/finnhub_ruby/models/company_news_statistics.rb +227 -0
  80. data/lib/finnhub_ruby/models/company_profile.rb +477 -0
  81. data/lib/finnhub_ruby/models/company_profile2.rb +317 -0
  82. data/lib/finnhub_ruby/models/country_metadata.rb +257 -0
  83. data/lib/finnhub_ruby/models/covid_info.rb +237 -0
  84. data/lib/finnhub_ruby/models/crypto_candles.rb +279 -0
  85. data/lib/finnhub_ruby/models/crypto_symbol.rb +227 -0
  86. data/lib/finnhub_ruby/models/development.rb +237 -0
  87. data/lib/finnhub_ruby/models/dividends.rb +277 -0
  88. data/lib/finnhub_ruby/models/earning_estimate.rb +247 -0
  89. data/lib/finnhub_ruby/models/earning_release.rb +287 -0
  90. data/lib/finnhub_ruby/models/earning_result.rb +237 -0
  91. data/lib/finnhub_ruby/models/earnings_calendar.rb +209 -0
  92. data/lib/finnhub_ruby/models/earnings_call_transcripts.rb +291 -0
  93. data/lib/finnhub_ruby/models/earnings_call_transcripts_list.rb +219 -0
  94. data/lib/finnhub_ruby/models/earnings_estimates.rb +229 -0
  95. data/lib/finnhub_ruby/models/economic_calendar.rb +209 -0
  96. data/lib/finnhub_ruby/models/economic_code.rb +237 -0
  97. data/lib/finnhub_ruby/models/economic_data.rb +219 -0
  98. data/lib/finnhub_ruby/models/economic_event.rb +277 -0
  99. data/lib/finnhub_ruby/models/estimate.rb +247 -0
  100. data/lib/finnhub_ruby/models/filing.rb +277 -0
  101. data/lib/finnhub_ruby/models/financial_statements.rb +219 -0
  102. data/lib/finnhub_ruby/models/financials_as_reported.rb +229 -0
  103. data/lib/finnhub_ruby/models/forex_candles.rb +279 -0
  104. data/lib/finnhub_ruby/models/forex_symbol.rb +227 -0
  105. data/lib/finnhub_ruby/models/forexrates.rb +216 -0
  106. data/lib/finnhub_ruby/models/fund_ownership.rb +219 -0
  107. data/lib/finnhub_ruby/models/indicator.rb +227 -0
  108. data/lib/finnhub_ruby/models/investor.rb +237 -0
  109. data/lib/finnhub_ruby/models/investors_ownership.rb +219 -0
  110. data/lib/finnhub_ruby/models/ipo_calendar.rb +209 -0
  111. data/lib/finnhub_ruby/models/ipo_event.rb +277 -0
  112. data/lib/finnhub_ruby/models/last_bid_ask.rb +247 -0
  113. data/lib/finnhub_ruby/models/major_developments.rb +219 -0
  114. data/lib/finnhub_ruby/models/news.rb +287 -0
  115. data/lib/finnhub_ruby/models/news_sentiment.rb +255 -0
  116. data/lib/finnhub_ruby/models/pattern_recognition.rb +209 -0
  117. data/lib/finnhub_ruby/models/price_target.rb +257 -0
  118. data/lib/finnhub_ruby/models/quote.rb +247 -0
  119. data/lib/finnhub_ruby/models/recommendation_trend.rb +267 -0
  120. data/lib/finnhub_ruby/models/report.rb +306 -0
  121. data/lib/finnhub_ruby/models/revenue_estimates.rb +229 -0
  122. data/lib/finnhub_ruby/models/sentiment.rb +217 -0
  123. data/lib/finnhub_ruby/models/split.rb +237 -0
  124. data/lib/finnhub_ruby/models/stock.rb +227 -0
  125. data/lib/finnhub_ruby/models/stock_candles.rb +279 -0
  126. data/lib/finnhub_ruby/models/stock_transcripts.rb +247 -0
  127. data/lib/finnhub_ruby/models/support_resistance.rb +209 -0
  128. data/lib/finnhub_ruby/models/technical_analysis.rb +216 -0
  129. data/lib/finnhub_ruby/models/tick_data.rb +285 -0
  130. data/lib/finnhub_ruby/models/transcript_content.rb +219 -0
  131. data/lib/finnhub_ruby/models/transcript_participant.rb +217 -0
  132. data/lib/finnhub_ruby/models/trend.rb +207 -0
  133. data/lib/finnhub_ruby/models/upgrade_downgrade.rb +257 -0
  134. data/lib/finnhub_ruby/version.rb +15 -0
  135. data/release.sh +2 -0
  136. data/spec/api/default_api_spec.rb +638 -0
  137. data/spec/api_client_spec.rb +226 -0
  138. data/spec/configuration_spec.rb +42 -0
  139. data/spec/models/aggregate_indicators_spec.rb +47 -0
  140. data/spec/models/basic_financials_spec.rb +53 -0
  141. data/spec/models/company_executive_spec.rb +47 -0
  142. data/spec/models/company_news_statistics_spec.rb +53 -0
  143. data/spec/models/company_profile2_spec.rb +107 -0
  144. data/spec/models/company_profile_spec.rb +203 -0
  145. data/spec/models/company_spec.rb +77 -0
  146. data/spec/models/country_metadata_spec.rb +71 -0
  147. data/spec/models/covid_info_spec.rb +59 -0
  148. data/spec/models/crypto_candles_spec.rb +77 -0
  149. data/spec/models/crypto_symbol_spec.rb +53 -0
  150. data/spec/models/development_spec.rb +59 -0
  151. data/spec/models/dividends_spec.rb +83 -0
  152. data/spec/models/earning_estimate_spec.rb +65 -0
  153. data/spec/models/earning_release_spec.rb +89 -0
  154. data/spec/models/earning_result_spec.rb +59 -0
  155. data/spec/models/earnings_calendar_spec.rb +41 -0
  156. data/spec/models/earnings_call_transcripts_list_spec.rb +47 -0
  157. data/spec/models/earnings_call_transcripts_spec.rb +89 -0
  158. data/spec/models/earnings_estimates_spec.rb +53 -0
  159. data/spec/models/economic_calendar_spec.rb +41 -0
  160. data/spec/models/economic_code_spec.rb +59 -0
  161. data/spec/models/economic_data_spec.rb +47 -0
  162. data/spec/models/economic_event_spec.rb +83 -0
  163. data/spec/models/estimate_spec.rb +65 -0
  164. data/spec/models/filing_spec.rb +83 -0
  165. data/spec/models/financial_statements_spec.rb +47 -0
  166. data/spec/models/financials_as_reported_spec.rb +53 -0
  167. data/spec/models/forex_candles_spec.rb +77 -0
  168. data/spec/models/forex_symbol_spec.rb +53 -0
  169. data/spec/models/forexrates_spec.rb +47 -0
  170. data/spec/models/fund_ownership_spec.rb +47 -0
  171. data/spec/models/indicator_spec.rb +53 -0
  172. data/spec/models/investor_spec.rb +59 -0
  173. data/spec/models/investors_ownership_spec.rb +47 -0
  174. data/spec/models/ipo_calendar_spec.rb +41 -0
  175. data/spec/models/ipo_event_spec.rb +83 -0
  176. data/spec/models/last_bid_ask_spec.rb +65 -0
  177. data/spec/models/major_developments_spec.rb +47 -0
  178. data/spec/models/news_sentiment_spec.rb +71 -0
  179. data/spec/models/news_spec.rb +89 -0
  180. data/spec/models/pattern_recognition_spec.rb +41 -0
  181. data/spec/models/price_target_spec.rb +71 -0
  182. data/spec/models/quote_spec.rb +65 -0
  183. data/spec/models/recommendation_trend_spec.rb +77 -0
  184. data/spec/models/report_spec.rb +101 -0
  185. data/spec/models/revenue_estimates_spec.rb +53 -0
  186. data/spec/models/sentiment_spec.rb +47 -0
  187. data/spec/models/split_spec.rb +59 -0
  188. data/spec/models/stock_candles_spec.rb +77 -0
  189. data/spec/models/stock_spec.rb +53 -0
  190. data/spec/models/stock_transcripts_spec.rb +65 -0
  191. data/spec/models/support_resistance_spec.rb +41 -0
  192. data/spec/models/technical_analysis_spec.rb +47 -0
  193. data/spec/models/tick_data_spec.rb +83 -0
  194. data/spec/models/transcript_content_spec.rb +47 -0
  195. data/spec/models/transcript_participant_spec.rb +47 -0
  196. data/spec/models/trend_spec.rb +41 -0
  197. data/spec/models/upgrade_downgrade_spec.rb +71 -0
  198. data/spec/spec_helper.rb +111 -0
  199. data/test.rb +139 -0
  200. metadata +364 -0
@@ -0,0 +1,217 @@
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: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module FinnhubRuby
16
+ class Sentiment
17
+ #
18
+ attr_accessor :bearish_percent
19
+
20
+ #
21
+ attr_accessor :bullish_percent
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'bearish_percent' => :'bearishPercent',
27
+ :'bullish_percent' => :'bullishPercent'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'bearish_percent' => :'Integer',
35
+ :'bullish_percent' => :'Integer'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::Sentiment` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::Sentiment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'bearish_percent')
61
+ self.bearish_percent = attributes[:'bearish_percent']
62
+ end
63
+
64
+ if attributes.key?(:'bullish_percent')
65
+ self.bullish_percent = attributes[:'bullish_percent']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ bearish_percent == o.bearish_percent &&
88
+ bullish_percent == o.bullish_percent
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [bearish_percent, bullish_percent].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ FinnhubRuby.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,237 @@
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: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module FinnhubRuby
16
+ class Split
17
+ # Symbol.
18
+ attr_accessor :symbol
19
+
20
+ # Split date.
21
+ attr_accessor :date
22
+
23
+ # From factor.
24
+ attr_accessor :from_factor
25
+
26
+ # To factor.
27
+ attr_accessor :to_factor
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'symbol' => :'symbol',
33
+ :'date' => :'date',
34
+ :'from_factor' => :'fromFactor',
35
+ :'to_factor' => :'toFactor'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'symbol' => :'String',
43
+ :'date' => :'Date',
44
+ :'from_factor' => :'Float',
45
+ :'to_factor' => :'Float'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::Split` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::Split`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'symbol')
71
+ self.symbol = attributes[:'symbol']
72
+ end
73
+
74
+ if attributes.key?(:'date')
75
+ self.date = attributes[:'date']
76
+ end
77
+
78
+ if attributes.key?(:'from_factor')
79
+ self.from_factor = attributes[:'from_factor']
80
+ end
81
+
82
+ if attributes.key?(:'to_factor')
83
+ self.to_factor = attributes[:'to_factor']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ symbol == o.symbol &&
106
+ date == o.date &&
107
+ from_factor == o.from_factor &&
108
+ to_factor == o.to_factor
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [symbol, date, from_factor, to_factor].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if 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 # or else data not found in attributes(hash), not an issue as the data can be optional
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 :DateTime
157
+ DateTime.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
+ FinnhubRuby.const_get(type).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
+ end
237
+ end