iex-ruby-client 1.0.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/.env.sample +2 -0
  3. data/.github/FUNDING.yml +1 -0
  4. data/.rubocop.yml +4 -1
  5. data/.rubocop_todo.yml +0 -8
  6. data/CHANGELOG.md +43 -9
  7. data/Dangerfile +2 -2
  8. data/Gemfile +3 -2
  9. data/README.md +134 -10
  10. data/iex-ruby-client.gemspec +3 -2
  11. data/lib/iex/api.rb +6 -1
  12. data/lib/iex/api/client.rb +13 -2
  13. data/lib/iex/api/config/client.rb +52 -0
  14. data/lib/iex/api/config/logger.rb +35 -0
  15. data/lib/iex/cloud/connection.rb +22 -19
  16. data/lib/iex/cloud/request.rb +1 -1
  17. data/lib/iex/cloud/response.rb +1 -1
  18. data/lib/iex/endpoints/advanced_stats.rb +11 -0
  19. data/lib/iex/endpoints/chart.rb +5 -6
  20. data/lib/iex/endpoints/company.rb +1 -1
  21. data/lib/iex/endpoints/crypto.rb +1 -1
  22. data/lib/iex/endpoints/dividends.rb +1 -1
  23. data/lib/iex/endpoints/earnings.rb +1 -1
  24. data/lib/iex/endpoints/income.rb +13 -0
  25. data/lib/iex/endpoints/key_stats.rb +1 -1
  26. data/lib/iex/endpoints/largest_trades.rb +1 -1
  27. data/lib/iex/endpoints/logo.rb +1 -1
  28. data/lib/iex/endpoints/news.rb +1 -1
  29. data/lib/iex/endpoints/ohlc.rb +2 -2
  30. data/lib/iex/endpoints/price.rb +1 -1
  31. data/lib/iex/endpoints/quote.rb +1 -1
  32. data/lib/iex/endpoints/ref_data.rb +22 -0
  33. data/lib/iex/endpoints/sectors.rb +1 -1
  34. data/lib/iex/endpoints/stock_market.rb +11 -0
  35. data/lib/iex/resources.rb +4 -0
  36. data/lib/iex/resources/advanced_stats.rb +42 -0
  37. data/lib/iex/resources/chart.rb +9 -14
  38. data/lib/iex/resources/company.rb +1 -0
  39. data/lib/iex/resources/income.rb +36 -0
  40. data/lib/iex/resources/key_stats.rb +2 -2
  41. data/lib/iex/resources/quote.rb +15 -5
  42. data/lib/iex/resources/resource.rb +1 -1
  43. data/lib/iex/resources/symbol.rb +10 -0
  44. data/lib/iex/resources/symbols.rb +19 -0
  45. data/lib/iex/version.rb +1 -1
  46. data/spec/fixtures/iex/advanced_stats/invalid.yml +50 -0
  47. data/spec/fixtures/iex/advanced_stats/msft.yml +57 -0
  48. data/spec/fixtures/iex/chart/1d.yml +440 -473
  49. data/spec/fixtures/iex/chart/20190306.yml +440 -473
  50. data/spec/fixtures/iex/chart/bad_option.yml +47 -81
  51. data/spec/fixtures/iex/chart/chartInterval.yml +89 -122
  52. data/spec/fixtures/iex/chart/dynamic/1m.yml +73 -107
  53. data/spec/fixtures/iex/chart/invalid.yml +47 -81
  54. data/spec/fixtures/iex/chart/msft.yml +74 -107
  55. data/spec/fixtures/iex/income/invalid.yml +49 -0
  56. data/spec/fixtures/iex/income/msft.yml +53 -0
  57. data/spec/fixtures/iex/income/nsrgy.yml +55 -0
  58. data/spec/fixtures/iex/ref-data/isin.yml +57 -0
  59. data/spec/fixtures/iex/ref-data/isin_mapped.yml +57 -0
  60. data/spec/fixtures/iex/ref-data/symbols.yml +9002 -0
  61. data/spec/fixtures/iex/ref-data/wrong_isin_mapped.yml +57 -0
  62. data/spec/fixtures/iex/stock_market/list_mostactive.yml +76 -0
  63. data/spec/iex/client_spec.rb +97 -14
  64. data/spec/iex/config/client_spec.rb +49 -0
  65. data/spec/iex/config/logger_spec.rb +46 -0
  66. data/spec/iex/endpoints/advanced_stats_spec.rb +54 -0
  67. data/spec/iex/endpoints/chart_spec.rb +7 -7
  68. data/spec/iex/endpoints/company_spec.rb +1 -0
  69. data/spec/iex/endpoints/income_spec.rb +68 -0
  70. data/spec/iex/endpoints/key_stats_spec.rb +2 -1
  71. data/spec/iex/endpoints/quote_spec.rb +2 -0
  72. data/spec/iex/endpoints/ref_data_spec.rb +76 -0
  73. data/spec/iex/endpoints/stock_market_spec.rb +14 -0
  74. data/spec/spec_helper.rb +3 -2
  75. data/spec/support/vcr.rb +3 -0
  76. metadata +56 -16
  77. data/lib/iex/api/config.rb +0 -45
  78. data/spec/iex/config_spec.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cc54c99b44f20089d95fa121c4bdf07c799bcf85
4
- data.tar.gz: c8ffcde3452f7141c61342f510d2700f6c0a0bbf
2
+ SHA256:
3
+ metadata.gz: b8a4a5e3e694cd4af9310002178f918ed6b6802711860e29780e2bde8f494805
4
+ data.tar.gz: 415aa05993daba620a4aea9a32aa52d73a8e0b3bdc39fd96296fb655703b2921
5
5
  SHA512:
6
- metadata.gz: cc798095fd893860bcf460bd836c6c0c8922f4a5831df83184842a2a5be537008220f51e42a5bdfab29a791b0ef7d9f28fd50b9781e59d8fc7d0a4b9238de331
7
- data.tar.gz: cbad4c6f007f914c7548a92cdc5c9b0a77ea60c7b9f4dfd73a38c96930d8ccfca0f0ae0f436e6709e207c4afa91951b73f80c906361d86577b9757fe57ae8a62
6
+ metadata.gz: 43680c128f3354b4f64f485c51ddfed0f94c9a3f25b6be1c16f93a7a3a97534a0e1fa990a85394d92c1aca220410ceea1a9e9f0d061abce8c7e697ef91a022e3
7
+ data.tar.gz: 3f497b0bdcc8b295b1f370d3185e6768fea91cbafdde5acdf637d8a16b918d0e5fc229eb5bb702eca8d5848388b5803e797cf8c21feb156c895f3c8e1d5d2dd8
@@ -0,0 +1,2 @@
1
+ IEX_API_PUBLISHABLE_TOKEN=test-iex-api-publishable-token
2
+ IEX_API_SECRET_TOKEN=test-iex-api-secret-token
@@ -0,0 +1 @@
1
+ github: [dblock]
@@ -2,12 +2,15 @@ AllCops:
2
2
  Exclude:
3
3
  - vendor/**/*
4
4
 
5
+ Style/FrozenStringLiteralComment:
6
+ Enabled: false
7
+
5
8
  Naming/MethodName:
6
9
  Enabled: false
7
10
 
8
11
  Naming/FileName:
9
12
  Exclude:
10
- - 'lib/iex-ruby-client.rb'
13
+ - "lib/iex-ruby-client.rb"
11
14
 
12
15
  Style/Documentation:
13
16
  Enabled: false
@@ -11,11 +11,3 @@
11
11
  Style/AsciiComments:
12
12
  Exclude:
13
13
  - 'lib/iex/resources/quote.rb'
14
-
15
- # Offense count: 1
16
- # Cop supports --auto-correct.
17
- # Configuration parameters: EnforcedStyle, Autocorrect.
18
- # SupportedStyles: module_function, extend_self
19
- Style/ModuleFunction:
20
- Exclude:
21
- - 'lib/iex/api/config.rb'
@@ -1,7 +1,41 @@
1
+ ### 1.3.0 (2020/10/31)
2
+
3
+ * [#82](https://github.com/dblock/iex-ruby-client/pull/82): Added `config.referer` to set HTTP `Referer` header. This enables IEX's "Manage domains" domain locking for tokens - [@agrberg](https://github.com/agrberg).
4
+ * [#70](https://github.com/dblock/iex-ruby-client/pull/70): Added support for `ref_data_isin` taking a single `String` parameter - [@rodolfobandeira](https://github.com/rodolfobandeira).
5
+ * [#84](https://github.com/dblock/iex-ruby-client/pull/84): Added support for Advanced Stats API - [@FanaHOVA](https://github.com/fanahova).
6
+ * [#86](https://github.com/dblock/iex-ruby-client/issues/86): Added advanced logger configuration to `config.logger`. Now a hash with keys `:instance, :options, and :proc` can be passed and used directly with Faraday - [@agrberg](https://github.com/agrberg).
7
+ * [#88](https://github.com/dblock/iex-ruby-client/pull/88): Updated logger configuration to work like `Config` class and allow attribute and block based configuration - [@agrberg](https://github.com/agrberg).
8
+ * [#89](https://github.com/dblock/iex-ruby-client/pull/89): Backfill breaking `Config#logger` setting change from [#88](https://github.com/dblock/iex-ruby-client/pull/88) - [@agrberg](https://github.com/agrberg).
9
+
10
+ ### 1.2.0 (2020/09/01)
11
+
12
+ * [#78](https://github.com/dblock/iex-ruby-client/pull/78): Added `Quote#extended_change_percent` and `Quote#extended_change_percent_s` properties to Quote - [@reddavis](https://github.com/reddavis).
13
+ * [#71](https://github.com/dblock/iex-ruby-client/pull/71): Added `symbols` resource - [@ryosuke-endo](https://github.com/ryosuke-endo).
14
+ * [#69](https://github.com/dblock/iex-ruby-client/pull/69): Fixed `ref_data_isin` request - [@bguban](https://github.com/bguban).
15
+ * [#72](https://github.com/dblock/iex-ruby-client/pull/72): Cache `Faraday::Connection` for persistent adapters - [@dblock](https://github.com/dblock).
16
+
17
+ ### 1.1.2 (2020/03/25)
18
+
19
+ * [#68](https://github.com/dblock/iex-ruby-client/pull/68): Fixed `ref_data_isin` request with wrong isin - [@bguban](https://github.com/bguban).
20
+ * [#67](https://github.com/dblock/iex-ruby-client/pull/67): Added required ruby version to gemspec - [@wdperson](https://github.com/wdperson).
21
+ * [#66](https://github.com/dblock/iex-ruby-client/pull/66): Fixed `KeyStats#week_52_change always` returns nil - [@brunjo](https://github.com/brunjo).
22
+ * [#65](https://github.com/dblock/iex-ruby-client/pull/65): Added `stock_market_list` - [@bguban](https://github.com/bguban).
23
+ * [#64](https://github.com/dblock/iex-ruby-client/pull/64): Added `ref_data_isin` - [@bguban](https://github.com/bguban).
24
+
25
+ ### 1.1.1 (2020/03/02)
26
+
27
+ * [#63](https://github.com/dblock/iex-ruby-client/pull/63): Allow direct API calls with support for secret_token - [@bguban](https://github.com/bguban).
28
+ * [#61](https://github.com/dblock/iex-ruby-client/pull/61): Fixed income endpoint if the api returns no result - [@brunjo](https://github.com/brunjo).
29
+ * [#57](https://github.com/dblock/iex-ruby-client/pull/57): Updated properties for chart api endpoint - [@brunjo](https://github.com/brunjo).
30
+
31
+ ### 1.1.0 (2019/07/08)
32
+
33
+ * [#55](https://github.com/dblock/iex-ruby-client/pull/55): Added `income` statement API and add `tags` to the `company` - [@bingxie](https://github.com/bingxie).
34
+
1
35
  ### 1.0.1 (2019/07/08)
2
36
 
3
- * [#50](https://github.com/dblock/iex-ruby-client/pull/50): Add missing properties for key stats API - [@bingxie](https://github.com/bingxie).
4
- * Fix: `uninitialized constant IEX::Endpoints::Chart::Date (NameError)` - [@dblock](https://github.com/dblock).
37
+ * [#50](https://github.com/dblock/iex-ruby-client/pull/50): Added missing properties for key stats API - [@bingxie](https://github.com/bingxie).
38
+ * Fixed `uninitialized constant IEX::Endpoints::Chart::Date (NameError)` - [@dblock](https://github.com/dblock).
5
39
 
6
40
  ### 1.0.0 (2019/04/23)
7
41
 
@@ -11,9 +45,9 @@
11
45
  ### 0.4.4 (2018/12/27)
12
46
 
13
47
  * [#39](https://github.com/dblock/iex-ruby-client/pull/39): Remove default range and use iextrading default range 1m instead in `IEX::Api::Dividends` - [@ildarkayumov](https://github.com/ildarkayumov).
14
- * [#37](https://github.com/dblock/iex-ruby-client/pull/37): Add `IEX::Resource::Crypto` - [@rodolfobandeira](https://github.com/rodolfobandeira).
15
- * [#34](https://github.com/dblock/iex-ruby-client/pull/34): Add `IEX::Resource::LargestTrades` - [@gil27](https://github.com/gil27).
16
- * [#32](https://github.com/dblock/iex-ruby-client/pull/32): Add `IEX::Resource::Sectors` - [@gil27](https://github.com/gil27).
48
+ * [#37](https://github.com/dblock/iex-ruby-client/pull/37): Added `IEX::Resource::Crypto` - [@rodolfobandeira](https://github.com/rodolfobandeira).
49
+ * [#34](https://github.com/dblock/iex-ruby-client/pull/34): Added `IEX::Resource::LargestTrades` - [@gil27](https://github.com/gil27).
50
+ * [#32](https://github.com/dblock/iex-ruby-client/pull/32): Added `IEX::Resource::Sectors` - [@gil27](https://github.com/gil27).
17
51
 
18
52
  ### 0.4.3 (2018/08/18)
19
53
 
@@ -21,7 +55,7 @@
21
55
 
22
56
  ### 0.4.2 (2018/08/14)
23
57
 
24
- * [#24](https://github.com/dblock/iex-ruby-client/pull/24): Add danger-toc and danger-changelog - [@rodolfobandeira](https://github.com/rodolfobandeira).
58
+ * [#24](https://github.com/dblock/iex-ruby-client/pull/24): Added danger-toc and danger-changelog - [@rodolfobandeira](https://github.com/rodolfobandeira).
25
59
  * [#21](https://github.com/dblock/iex-ruby-client/pull/21): Added `IEX::Resources::Dividends` - [@rodolfobandeira](https://github.com/rodolfobandeira).
26
60
 
27
61
  ### 0.4.1 (2018/08/07)
@@ -40,18 +74,18 @@
40
74
 
41
75
  ### 0.3.2 (2018/05/26)
42
76
 
43
- * Fix: undefined method > for nil:NilClass error - [@dblock](https://github.com/dblock).
77
+ * Fixed undefined method > for nil:NilClass error - [@dblock](https://github.com/dblock).
44
78
 
45
79
  ### 0.3.1 (2018/05/23)
46
80
 
47
- * [#3](https://github.com/dblock/iex-ruby-client/issues/3): Fix: do not error on undefined properties - [@dblock](https://github.com/dblock).
81
+ * [#3](https://github.com/dblock/iex-ruby-client/issues/3): Fixed do not error on undefined properties - [@dblock](https://github.com/dblock).
48
82
 
49
83
  ### 0.3.0 (2018/05/22)
50
84
 
51
85
  * Added `IEX::Resources::Chart#get` - [@dblock](https://github.com/dblock).
52
86
  * Added `IEX::Resources::News#get` - [@dblock](https://github.com/dblock).
53
87
  * Added `IEX::Resources::Price#get` - [@dblock](https://github.com/dblock).
54
- * Fix: added `IEX::Resources::Quote#extendedPrice` and `IEX::Resources::Quote#extendedPriceTime` - [@dblock](https://github.com/dblock).
88
+ * Fixed added `IEX::Resources::Quote#extendedPrice` and `IEX::Resources::Quote#extendedPriceTime` - [@dblock](https://github.com/dblock).
55
89
 
56
90
  ### 0.2.0 (2018/03/26)
57
91
 
data/Dangerfile CHANGED
@@ -1,2 +1,2 @@
1
- toc.check
2
- changelog.check
1
+ toc.check!
2
+ changelog.check!
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem 'danger-changelog', '~> 0.3.0'
7
- gem 'danger-toc', '~> 0.1'
6
+ gem 'danger-changelog', '~> 0.6.0'
7
+ gem 'danger-toc', '~> 0.2.0'
8
+ gem 'dotenv'
8
9
  gem 'pry'
9
10
  end
data/README.md CHANGED
@@ -22,10 +22,17 @@ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
22
22
  - [Get Key Stats](#get-key-stats)
23
23
  - [Get Dividends](#get-dividends)
24
24
  - [Get Earnings](#get-earnings)
25
+ - [Get Income Statement](#get-income-statement)
25
26
  - [Get Sector Performance](#get-sector-performance)
26
27
  - [Get Largest Trades](#get-largest-trades)
27
28
  - [Get a Quote for Crypto Currencies](#get-a-quote-for-crypto-currencies)
29
+ - [ISIN Mapping](#isin-mapping)
30
+ - [Get Symbols](#get-symbols)
31
+ - [Get List](#get-list)
32
+ - [Other Requests](#other-requests)
28
33
  - [Configuration](#configuration)
34
+ - [Logging](#logging)
35
+ - [Sandbox Environment](#sandbox-environment)
29
36
  - [Errors](#errors)
30
37
  - [SymbolNotFound](#symbolnotfound)
31
38
  - [PermissionDeniedError](#permissiondeniederror)
@@ -47,14 +54,15 @@ Run `bundle install`.
47
54
 
48
55
  ### Get an API Token
49
56
 
50
- Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console. You should use a sandbox token and endpoint for testing.
57
+ Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console.
51
58
 
52
59
  ### Configure
53
60
 
54
61
  ```ruby
55
62
  IEX::Api.configure do |config|
56
- config.publishable_token = 'token' # defaults to ENV['IEX_API_PUBLISHABLE_TOKEN']
57
- config.endpoint = 'https://sandbox.iexapis.com/v1' # defaults to 'https://cloud.iexapis.com/v1'
63
+ config.publishable_token = 'publishable_token' # defaults to ENV['IEX_API_PUBLISHABLE_TOKEN']
64
+ config.secret_token = 'secret_token' # defaults to ENV['IEX_API_SECRET_TOKEN']
65
+ config.endpoint = 'https://cloud.iexapis.com/v1' # use 'https://sandbox.iexapis.com/v1' for Sandbox
58
66
  end
59
67
  ```
60
68
 
@@ -62,8 +70,9 @@ You can also configure an instance of a client directly.
62
70
 
63
71
  ```ruby
64
72
  client = IEX::Api::Client.new(
65
- publishable_token: 'token',
66
- endpoint: 'https://sandbox.iexapis.com/v1'
73
+ publishable_token: 'publishable_token',
74
+ secret_token: 'secret_token',
75
+ endpoint: 'https://cloud.iexapis.com/v1'
67
76
  )
68
77
  ```
69
78
 
@@ -97,7 +106,7 @@ See [#quote](https://iexcloud.io/docs/api/#quote) for detailed documentation or
97
106
  Fetches a single stock OHLC price. Open and Close prices contain timestamp.
98
107
 
99
108
  ```ruby
100
- ohlc = client.ohlc.get('MSFT')
109
+ ohlc = client.ohlc('MSFT')
101
110
 
102
111
  ohlc.close.price # 90.165
103
112
  ohlc.close.time #
@@ -216,7 +225,7 @@ key_stats.week_52_high_dollar # "$136.04"
216
225
  key_stats.week_52_low # 95.92,
217
226
  key_stats.week_52_low_dollar # "$95.92"
218
227
  key_stats.market_cap # 990869169557
219
- key_stats.market_cap_dollars # "$990,869,169,557"
228
+ key_stats.market_cap_dollar # "$990,869,169,557"
220
229
  key_stats.employees # 133074
221
230
  key_stats.day_200_moving_avg # 112.43
222
231
  key_stats.day_50_moving_avg # 121
@@ -293,6 +302,25 @@ earnings.year_ago_change_percent_s # '+15.31%'
293
302
 
294
303
  See [#earnings](https://iexcloud.io/docs/api/#earnings) for detailed documentation or [earnings.rb](lib/iex/resources/earnings.rb) for returned fields.
295
304
 
305
+ ### Get Income Statement
306
+
307
+ Fetches income statement for a symbol.
308
+
309
+ ```ruby
310
+ income = client.income('MSFT')
311
+
312
+ income.report_date # '2019-03-31'
313
+ income.total_revenue # 30_505_000_000
314
+ income.total_revenue_dollar # '$30,505,000,000'
315
+ income.cost_of_revenue # 10_170_000_000
316
+ income.cost_of_revenue_dollar # '$10,170,000,000'
317
+ income.gross_profit # 20_335_000_000
318
+ income.gross_profit_dollar # '$20,335,000,000'
319
+ ...
320
+ ```
321
+
322
+ See [#income-statement](https://iexcloud.io/docs/api/#income-statement) for detailed documentation or [income.rb](lib/iex/resources/income.rb) for returned fields.
323
+
296
324
  ### Get Sector Performance
297
325
 
298
326
  Fetches latest sector's performance.
@@ -349,12 +377,75 @@ crypto.high_dollar #'$3,590'
349
377
 
350
378
  See [#crypto](https://iexcloud.io/docs/api/#crypto) for detailed documentation or [crypto.rb](lib/iex/resources/crypto.rb) for returned fields.
351
379
 
380
+ ### ISIN Mapping
381
+
382
+ Convert ISIN to IEX Cloud symbols.
383
+
384
+ ```ruby
385
+ symbols = client.ref_data_isin('US0378331005')
386
+
387
+ symbols.first.exchange # NAS
388
+ symbols.first.iex_id # IEX_4D48333344362D52
389
+ symbols.first.region # US
390
+ symbols.first.symbol # AAPL
391
+ ```
392
+
393
+ The API also lets you convert multiple ISINs to IEX Cloud symbols.
394
+
395
+ ```ruby
396
+ symbols = client.ref_data_isin(['US0378331005', 'US0378331006'])
397
+ ```
398
+
399
+
400
+ You can use `mapped: true` option to receive symbols grouped by their ISINs.
401
+
402
+ ```ruby
403
+ client.ref_data_isin(['US0378331005', 'US5949181045'], mapped: true) # {'US0378331005' => [...], 'US5949181045' => [...]}
404
+ ```
405
+
406
+ See [#ISIN Mapping](https://iexcloud.io/docs/api/#isin-mapping) for detailed documentation or [isin_mapping.rb](lib/iex/resources/isin_mapping.rb) for returned fields.
407
+
408
+ ### Get Symbols
409
+
410
+ Returns an array of symbols
411
+
412
+ ```ruby
413
+ symbols = client.ref_data_symbols()
414
+
415
+ symbol = symbols.first
416
+ symbol.exchange # NAS
417
+ symbol.iex_id # IEX_46574843354B2D52
418
+ symbol.region # US
419
+ symbol.symbol # A
420
+ ```
421
+
422
+ See [#symbols](https://iexcloud.io/docs/api/#symbols) for detailed documentation or [symbols.rb](lib/iex/resources/symbols.rb) for returned fields.
423
+
424
+ ### Get List
425
+
426
+ Returns an array of quotes for the top 10 symbols in a specified list.
427
+
428
+ ```ruby
429
+ client.stock_market_list(:mostactive) # [{symbol: 'AAPL', ...}, {...}]
430
+ ```
431
+
432
+ See [#list](https://iexcloud.io/docs/api/#list) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.
433
+
434
+ ### Other Requests
435
+
436
+ Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
437
+ and `client.delete` methods. Pass the required token explicitly:
438
+
439
+ ```ruby
440
+ client.post('ref-data/isin', isin: ['US0378331005'], token: 'secret_token') # [{'exchange' => 'NAS', ..., 'symbol' => 'AAPL'}, {'exchange' => 'ETR', ..., 'symbol' => 'APC-GY']
441
+ ```
442
+
352
443
  ## Configuration
353
444
 
354
445
  You can configure client options globally or directly with a `IEX::Api::Client` instance.
355
446
 
356
447
  ```ruby
357
- IEX::Api::Client.configure do |config|
448
+ IEX::Api.configure do |config|
358
449
  config.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
359
450
  config.endpoint = 'https://sandbox.iexapis.com/v1' # use sandbox environment
360
451
  end
@@ -363,7 +454,7 @@ end
363
454
  ```ruby
364
455
  client = IEX::Api::Client.new(
365
456
  publishable_token: ENV['IEX_API_PUBLISHABLE_TOKEN'],
366
- endpoint: 'https://sandbox.iexapis.com/v1'
457
+ endpoint: 'https://cloud.iexapis.com/v1'
367
458
  )
368
459
  ```
369
460
 
@@ -375,11 +466,44 @@ user_agent | User-agent, defaults to _IEX Ruby Client/version_.
375
466
  proxy | Optional HTTP proxy.
376
467
  ca_path | Optional SSL certificates path.
377
468
  ca_file | Optional SSL certificates file.
378
- logger | Optional `Logger` instance that logs HTTP requests.
469
+ logger | Optional `Logger` instance or logger configuration to log HTTP requests.
379
470
  timeout | Optional open/read timeout in seconds.
380
471
  open_timeout | Optional connection open timeout in seconds.
381
472
  publishable_token | IEX Cloud API publishable token.
382
473
  endpoint | Defaults to `https://cloud.iexapis.com/v1`.
474
+ referer | Optional string for HTTP `Referer` header, enables token domain management.
475
+
476
+ ### Logging
477
+
478
+ Faraday will not log HTTP requests by default. In order to do this you can either provide a `logger` instance or configuration attributes to `IEX::Api::Client`. Configuration allows you to supply the `instance`, `options`, and `proc` to [Faraday](https://lostisland.github.io/faraday/middleware/logger#include-and-exclude-headersbodies).
479
+
480
+ ```ruby
481
+ logger_instance = Logger.new(STDOUT)
482
+
483
+ IEX::Api.configure do |config|
484
+ config.logger.instance = logger_instance
485
+ config.logger.options = { bodies: true }
486
+ config.logger.proc = proc { |logger| logger.filter(/T?[sp]k_\w+/i, '[REMOVED]') }
487
+ end
488
+ # or
489
+ IEX::Api.logger do |logger|
490
+ logger.instance = logger_instance
491
+ logger.options = …
492
+ logger.proc = …
493
+ end
494
+ # or
495
+ IEX::Api.logger = logger_instance
496
+ # or
497
+ IEX::Api::Client.new(logger: logger_instance)
498
+ ```
499
+
500
+ ## Sandbox Environment
501
+
502
+ IEX recommends you use a sandbox token and endpoint for testing.
503
+
504
+ However, please note that data in the IEX sandbox environment is scrambled. Therefore elements such as company and people names, descriptions, tags, and website URLs don't render any coherent data. In addition, results, such as closing market prices and dividend yield, are not accurate and vary on every call.
505
+
506
+ See [IEX sandbox environment](https://intercom.help/iexcloud/en/articles/2915433-testing-with-the-iex-cloud-sandbox) for more information.
383
507
 
384
508
  ## Errors
385
509
 
@@ -9,19 +9,20 @@ Gem::Specification.new do |s|
9
9
  s.email = 'dblock@dblock.org'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.required_rubygems_version = '>= 1.3.6'
12
+ s.required_ruby_version = '>= 2.3.0'
12
13
  s.files = `git ls-files`.split("\n")
13
14
  s.test_files = `git ls-files -- spec/*`.split("\n")
14
15
  s.require_paths = ['lib']
15
16
  s.homepage = 'http://github.com/dblock/iex-ruby-client'
16
17
  s.licenses = ['MIT']
17
18
  s.summary = 'IEX Finance API Ruby client with support for retrieving stock quotes.'
18
- s.add_dependency 'faraday', '>= 0.9'
19
+ s.add_dependency 'faraday', '>= 0.17'
19
20
  s.add_dependency 'faraday_middleware'
20
21
  s.add_dependency 'hashie'
21
22
  s.add_dependency 'money_helper'
22
23
  s.add_development_dependency 'rake', '~> 10'
23
24
  s.add_development_dependency 'rspec'
24
- s.add_development_dependency 'rubocop', '0.67.2'
25
+ s.add_development_dependency 'rubocop', '0.72.0'
25
26
  s.add_development_dependency 'vcr'
26
27
  s.add_development_dependency 'webmock'
27
28
  end
@@ -1,7 +1,9 @@
1
+ require_relative 'endpoints/advanced_stats'
1
2
  require_relative 'endpoints/chart'
2
3
  require_relative 'endpoints/company'
3
4
  require_relative 'endpoints/dividends'
4
5
  require_relative 'endpoints/earnings'
6
+ require_relative 'endpoints/income'
5
7
  require_relative 'endpoints/largest_trades'
6
8
  require_relative 'endpoints/logo'
7
9
  require_relative 'endpoints/key_stats'
@@ -11,6 +13,9 @@ require_relative 'endpoints/price'
11
13
  require_relative 'endpoints/quote'
12
14
  require_relative 'endpoints/sectors'
13
15
  require_relative 'endpoints/crypto'
16
+ require_relative 'endpoints/ref_data'
17
+ require_relative 'endpoints/stock_market'
14
18
 
15
- require_relative 'api/config'
19
+ require_relative 'api/config/logger'
20
+ require_relative 'api/config/client'
16
21
  require_relative 'api/client'
@@ -1,11 +1,16 @@
1
1
  module IEX
2
2
  module Api
3
+ extend Config::Client::Accessor
4
+ extend Config::Logger::Accessor
5
+
3
6
  class Client
7
+ include Endpoints::AdvancedStats
4
8
  include Endpoints::Chart
5
9
  include Endpoints::Company
6
10
  include Endpoints::Crypto
7
11
  include Endpoints::Dividends
8
12
  include Endpoints::Earnings
13
+ include Endpoints::Income
9
14
  include Endpoints::KeyStats
10
15
  include Endpoints::LargestTrades
11
16
  include Endpoints::Logo
@@ -14,16 +19,22 @@ module IEX
14
19
  include Endpoints::Price
15
20
  include Endpoints::Quote
16
21
  include Endpoints::Sectors
22
+ include Endpoints::RefData
23
+ include Endpoints::StockMarket
17
24
 
18
25
  include Cloud::Connection
19
26
  include Cloud::Request
20
27
 
21
- include Config
28
+ attr_accessor(*Config::Client::ATTRIBUTES)
29
+
30
+ attr_reader :logger
22
31
 
23
32
  def initialize(options = {})
24
- Config::ATTRIBUTES.each do |key|
33
+ Config::Client::ATTRIBUTES.each do |key|
25
34
  send("#{key}=", options[key] || IEX::Api.config.send(key))
26
35
  end
36
+ @logger = Config::Logger.dup
37
+ @logger.instance = options[:logger] if options.key?(:logger)
27
38
  end
28
39
  end
29
40
  end