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,287 @@
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 News
17
+ # News category.
18
+ attr_accessor :category
19
+
20
+ # Published time in UNIX timestamp.
21
+ attr_accessor :datetime
22
+
23
+ # News headline.
24
+ attr_accessor :headline
25
+
26
+ # News ID. This value can be used for <code>minId</code> params to get the latest news only.
27
+ attr_accessor :id
28
+
29
+ # Thumbnail image URL.
30
+ attr_accessor :image
31
+
32
+ # Related stocks and companies mentioned in the article.
33
+ attr_accessor :related
34
+
35
+ # News source.
36
+ attr_accessor :source
37
+
38
+ # News summary.
39
+ attr_accessor :summary
40
+
41
+ # URL of the original article.
42
+ attr_accessor :url
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'category' => :'category',
48
+ :'datetime' => :'datetime',
49
+ :'headline' => :'headline',
50
+ :'id' => :'id',
51
+ :'image' => :'image',
52
+ :'related' => :'related',
53
+ :'source' => :'source',
54
+ :'summary' => :'summary',
55
+ :'url' => :'url'
56
+ }
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'category' => :'String',
63
+ :'datetime' => :'Integer',
64
+ :'headline' => :'String',
65
+ :'id' => :'Integer',
66
+ :'image' => :'String',
67
+ :'related' => :'String',
68
+ :'source' => :'String',
69
+ :'summary' => :'String',
70
+ :'url' => :'String'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::News` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::News`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'category')
96
+ self.category = attributes[:'category']
97
+ end
98
+
99
+ if attributes.key?(:'datetime')
100
+ self.datetime = attributes[:'datetime']
101
+ end
102
+
103
+ if attributes.key?(:'headline')
104
+ self.headline = attributes[:'headline']
105
+ end
106
+
107
+ if attributes.key?(:'id')
108
+ self.id = attributes[:'id']
109
+ end
110
+
111
+ if attributes.key?(:'image')
112
+ self.image = attributes[:'image']
113
+ end
114
+
115
+ if attributes.key?(:'related')
116
+ self.related = attributes[:'related']
117
+ end
118
+
119
+ if attributes.key?(:'source')
120
+ self.source = attributes[:'source']
121
+ end
122
+
123
+ if attributes.key?(:'summary')
124
+ self.summary = attributes[:'summary']
125
+ end
126
+
127
+ if attributes.key?(:'url')
128
+ self.url = attributes[:'url']
129
+ end
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properties with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ true
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ category == o.category &&
151
+ datetime == o.datetime &&
152
+ headline == o.headline &&
153
+ id == o.id &&
154
+ image == o.image &&
155
+ related == o.related &&
156
+ source == o.source &&
157
+ summary == o.summary &&
158
+ url == o.url
159
+ end
160
+
161
+ # @see the `==` method
162
+ # @param [Object] Object to be compared
163
+ def eql?(o)
164
+ self == o
165
+ end
166
+
167
+ # Calculates hash code according to all attributes.
168
+ # @return [Integer] Hash code
169
+ def hash
170
+ [category, datetime, headline, id, image, related, source, summary, url].hash
171
+ end
172
+
173
+ # Builds the object from hash
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ # @return [Object] Returns the model itself
176
+ def self.build_from_hash(attributes)
177
+ new.build_from_hash(attributes)
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ self.class.openapi_types.each_pair do |key, type|
186
+ if type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
195
+ end
196
+
197
+ self
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def _deserialize(type, value)
205
+ case type.to_sym
206
+ when :DateTime
207
+ DateTime.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :Boolean
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ FinnhubRuby.const_get(type).build_from_hash(value)
238
+ end
239
+ end
240
+
241
+ # Returns the string representation of the object
242
+ # @return [String] String presentation of the object
243
+ def to_s
244
+ to_hash.to_s
245
+ end
246
+
247
+ # to_body is an alias to to_hash (backward compatibility)
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_body
250
+ to_hash
251
+ end
252
+
253
+ # Returns the object in the form of hash
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_hash
256
+ hash = {}
257
+ self.class.attribute_map.each_pair do |attr, param|
258
+ value = self.send(attr)
259
+ if value.nil?
260
+ is_nullable = self.class.openapi_nullable.include?(attr)
261
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
262
+ end
263
+
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map { |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,255 @@
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 NewsSentiment
17
+ attr_accessor :buzz
18
+
19
+ # News score.
20
+ attr_accessor :company_news_score
21
+
22
+ # Sector average bullish percent.
23
+ attr_accessor :sector_average_bullish_percent
24
+
25
+ # Sectore average score.
26
+ attr_accessor :sector_average_news_score
27
+
28
+ attr_accessor :sentiment
29
+
30
+ # Requested symbol.
31
+ attr_accessor :symbol
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'buzz' => :'buzz',
37
+ :'company_news_score' => :'companyNewsScore',
38
+ :'sector_average_bullish_percent' => :'sectorAverageBullishPercent',
39
+ :'sector_average_news_score' => :'sectorAverageNewsScore',
40
+ :'sentiment' => :'sentiment',
41
+ :'symbol' => :'symbol'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'buzz' => :'CompanyNewsStatistics',
49
+ :'company_news_score' => :'Float',
50
+ :'sector_average_bullish_percent' => :'Float',
51
+ :'sector_average_news_score' => :'Float',
52
+ :'sentiment' => :'Sentiment',
53
+ :'symbol' => :'String'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `FinnhubRuby::NewsSentiment` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `FinnhubRuby::NewsSentiment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'buzz')
79
+ self.buzz = attributes[:'buzz']
80
+ end
81
+
82
+ if attributes.key?(:'company_news_score')
83
+ self.company_news_score = attributes[:'company_news_score']
84
+ end
85
+
86
+ if attributes.key?(:'sector_average_bullish_percent')
87
+ self.sector_average_bullish_percent = attributes[:'sector_average_bullish_percent']
88
+ end
89
+
90
+ if attributes.key?(:'sector_average_news_score')
91
+ self.sector_average_news_score = attributes[:'sector_average_news_score']
92
+ end
93
+
94
+ if attributes.key?(:'sentiment')
95
+ self.sentiment = attributes[:'sentiment']
96
+ end
97
+
98
+ if attributes.key?(:'symbol')
99
+ self.symbol = attributes[:'symbol']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ true
114
+ end
115
+
116
+ # Checks equality by comparing each attribute.
117
+ # @param [Object] Object to be compared
118
+ def ==(o)
119
+ return true if self.equal?(o)
120
+ self.class == o.class &&
121
+ buzz == o.buzz &&
122
+ company_news_score == o.company_news_score &&
123
+ sector_average_bullish_percent == o.sector_average_bullish_percent &&
124
+ sector_average_news_score == o.sector_average_news_score &&
125
+ sentiment == o.sentiment &&
126
+ symbol == o.symbol
127
+ end
128
+
129
+ # @see the `==` method
130
+ # @param [Object] Object to be compared
131
+ def eql?(o)
132
+ self == o
133
+ end
134
+
135
+ # Calculates hash code according to all attributes.
136
+ # @return [Integer] Hash code
137
+ def hash
138
+ [buzz, company_news_score, sector_average_bullish_percent, sector_average_news_score, sentiment, symbol].hash
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def self.build_from_hash(attributes)
145
+ new.build_from_hash(attributes)
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ self.class.openapi_types.each_pair do |key, type|
154
+ if type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :DateTime
175
+ DateTime.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ FinnhubRuby.const_get(type).build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+ end
255
+ end