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