iex-ruby-client 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 33ce07c1e77d24814273ff8a013c4056af821b5735b7f61698fa2ff05ecf3dd3
4
- data.tar.gz: 8a07a6f4e1c7a692288dec04a4082e8ccefb8d743788594dddc224ab08f62616
2
+ SHA1:
3
+ metadata.gz: 122b8435449269a11df3e45d0c9742f2cc23090d
4
+ data.tar.gz: d7581662b889893a85d771d79c3bcbbd657b7273
5
5
  SHA512:
6
- metadata.gz: 8b514b9635c5cc32591e9a4e8eed2de8acbd359598dbb6acb72986b650513c4a4fa2d29f240810c677aaf437c7bcf8b34e5ef9346512546045b329a8c74531d2
7
- data.tar.gz: 3957f334882a1445ae576af63f3770318543a80af0a32ec91c3d76a8daa729f0bf85043ead3dd1a825c5b822e5d9e7bb58b10a933f92c681f8a7626f0a6435e7
6
+ metadata.gz: 66c2cf2f5e2df6f46aea535436961d0aac6adf86259d135411f7879ab41db1e750e47275255a27db4b4c37ab187d579e1a69d72dc4d86e19c2ef26b721b5d6ae
7
+ data.tar.gz: 73611d7582829ef959585c72114d4f1bc135a4afad69b0765b308a00f02fa58516dfc680d4b9e416909ff416d6b31e338b508b302fbc54d6fd7e054b1bbfb138
@@ -5,4 +5,8 @@ AllCops:
5
5
  Naming/MethodName:
6
6
  Enabled: false
7
7
 
8
+ Naming/FileName:
9
+ Exclude:
10
+ - 'lib/iex-ruby-client.rb'
11
+
8
12
  inherit_from: .rubocop_todo.yml
@@ -1,35 +1,28 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-05-23 18:14:22 -0400 using RuboCop version 0.51.0.
3
+ # on 2018-07-27 05:38:15 -0400 using RuboCop version 0.58.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 4
9
+ # Offense count: 1
10
+ Metrics/AbcSize:
11
+ Max: 16
12
+
13
+ # Offense count: 5
10
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
11
16
  Metrics/BlockLength:
12
- Max: 71
13
-
14
- # Offense count: 41
15
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
16
- # URISchemes: http, https
17
- Metrics/LineLength:
18
- Max: 221
17
+ Max: 79
19
18
 
20
19
  # Offense count: 1
21
20
  # Configuration parameters: CountComments.
22
21
  Metrics/MethodLength:
23
- Max: 15
24
-
25
- # Offense count: 1
26
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
27
- # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
28
- Naming/FileName:
29
- Exclude:
30
- - 'lib/iex-ruby-client.rb'
22
+ Max: 17
31
23
 
32
24
  # Offense count: 1
25
+ # Configuration parameters: AllowedChars.
33
26
  Style/AsciiComments:
34
27
  Exclude:
35
28
  - 'lib/iex/resources/quote.rb'
@@ -40,6 +33,12 @@ Style/DateTime:
40
33
  - 'lib/iex/resources/news.rb'
41
34
  - 'spec/iex/resources/news_spec.rb'
42
35
 
43
- # Offense count: 16
36
+ # Offense count: 23
44
37
  Style/Documentation:
45
38
  Enabled: false
39
+
40
+ # Offense count: 43
41
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
42
+ # URISchemes: http, https
43
+ Metrics/LineLength:
44
+ Max: 221
@@ -1,3 +1,8 @@
1
+ ### 0.4.0 (2018/07/29)
2
+
3
+ * [#9](https://github.com/dblock/iex-ruby-client/pull/9): Added `IEX::Errors::ClientError` - [@rodolfobandeira](https://github.com/rodolfobandeira).
4
+ * [#10](https://github.com/dblock/iex-ruby-client/pull/10): Added `IEX::Resources::Logo#get` - [@rodolfobandeira](https://github.com/rodolfobandeira).
5
+
1
6
  ### 0.3.3 (2018/07/06)
2
7
 
3
8
  * [#5](https://github.com/dblock/iex-ruby-client/pull/5): Added `IEX::Resources::OHLC#get` - [@jromanovs](https://github.com/jromanovs).
data/README.md CHANGED
@@ -83,6 +83,18 @@ company.company_name # 'Microsoft Corporation'
83
83
 
84
84
  See [#company](https://iextrading.com/developer/docs/#company) for detailed documentation or [company.rb](lib/iex/resources/company.rb) for returned fields.
85
85
 
86
+ ### Get Company Logo
87
+
88
+ Fetches company logo for a symbol.
89
+
90
+ ```ruby
91
+ logo = IEX::Resources::Logo.get('MSFT')
92
+
93
+ logo.url # 'https://storage.googleapis.com/iex/api/logos/MSFT.png'
94
+ ```
95
+
96
+ See [#logo](https://iextrading.com/developer/docs/#logo) for detailed documentation or [logo.rb](lib/iex/resources/logo.rb) for returned fields.
97
+
86
98
  ### Get Recent News
87
99
 
88
100
  Fetches news for a symbol.
@@ -146,6 +158,10 @@ See [#chart](https://iextrading.com/developer/docs/#chart) for detailed document
146
158
 
147
159
  If a symbol cannot be found an [IEX::Errors::SymbolNotFound](lib/iex/errors/symbol_not_found_error.rb) exception is raised.
148
160
 
161
+ ### ClientError
162
+
163
+ All errors that return HTTP codes 400-600 result in a [IEX::Errors::ClientError](lib/iex/errors/client_error.rb) exception.
164
+
149
165
  ## Contributing
150
166
 
151
167
  See [CONTRIBUTING](CONTRIBUTING.md).
@@ -0,0 +1,26 @@
1
+ Upgrading iex-ruby-client
2
+ ===========================
3
+
4
+ ### Upgrading to >= 0.4.0
5
+
6
+ #### All errors that return HTTP codes 400-600 result in a IEX::Errors::ClientError exception
7
+
8
+ On previous versions, calling `IEX::Resources::Chart.get` with an invalid option results on a
9
+ `Faraday::ClientError`. On versions >= 0.4.0, it will return an `IEX::Errors::ClientError`.
10
+
11
+ Before:
12
+
13
+ ```ruby
14
+ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, invalid_option: 'foo')
15
+ > Faraday::ClientError: the server responded with status 400
16
+ ```
17
+
18
+ After:
19
+
20
+ ```ruby
21
+ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, invalid_option: 'foo')
22
+ > IEX::Errors::ClientError: "invalidOption" is not allowed
23
+ ```
24
+
25
+ See [#9](https://github.com/dblock/iex-ruby-client/pull/9) for more information.
26
+
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
1
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
2
2
  require 'iex/version'
3
3
 
4
4
  Gem::Specification.new do |s|
@@ -17,9 +17,10 @@ module IEX
17
17
  end
18
18
  end
19
19
 
20
- require_relative 'api/quote'
20
+ require_relative 'api/chart'
21
21
  require_relative 'api/company'
22
- require_relative 'api/price'
22
+ require_relative 'api/logo'
23
23
  require_relative 'api/news'
24
- require_relative 'api/chart'
25
24
  require_relative 'api/ohlc'
25
+ require_relative 'api/price'
26
+ require_relative 'api/quote'
@@ -0,0 +1,13 @@
1
+ module IEX
2
+ module Api
3
+ module Logo
4
+ def self.get(symbol)
5
+ connection(symbol).get
6
+ end
7
+
8
+ def self.connection(symbol)
9
+ IEX::Api.default_connection "#{symbol.downcase}/logo"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1 +1,2 @@
1
1
  require_relative 'errors/symbol_not_found_error'
2
+ require_relative 'errors/client_error'
@@ -0,0 +1,12 @@
1
+ module IEX
2
+ module Errors
3
+ class ClientError < StandardError
4
+ attr_reader :response
5
+
6
+ def initialize(response)
7
+ @response = response
8
+ super JSON.parse(response[:body])['error']
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,3 +5,4 @@ require_relative 'resources/price'
5
5
  require_relative 'resources/news'
6
6
  require_relative 'resources/chart'
7
7
  require_relative 'resources/ohlc'
8
+ require_relative 'resources/logo'
@@ -0,0 +1,13 @@
1
+ module IEX
2
+ module Resources
3
+ module Base
4
+ def self.symbol(symbol, &_block)
5
+ yield
6
+ rescue Faraday::ResourceNotFound => e
7
+ raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
8
+ rescue Faraday::ClientError => e
9
+ raise IEX::Errors::ClientError, e.response
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,4 @@
1
+ require_relative 'base'
1
2
  require_relative 'chart/base'
2
3
  require_relative 'chart/one_day'
3
4
  require_relative 'chart/default'
@@ -5,22 +6,22 @@ require_relative 'chart/default'
5
6
  module IEX
6
7
  module Resources
7
8
  module Chart
8
- def self.get(symbol, range = nil, options = {})
9
- response = IEX::Api::Chart.get(symbol, range, options)
10
- if range && range.to_s == 'dynamic'
11
- range = response['range']
12
- response = response['data']
13
- end
14
- response.map do |data|
15
- case range
16
- when '1d', Date, DateTime
17
- Chart::OneDay.new data
18
- else
19
- Chart::Default.new data
9
+ def self.get(stock_symbol, range = nil, options = {})
10
+ IEX::Resources::Base.symbol(stock_symbol) do
11
+ response = IEX::Api::Chart.get(stock_symbol, range, options)
12
+ if range && range.to_s == 'dynamic'
13
+ range = response['range']
14
+ response = response['data']
15
+ end
16
+ response.map do |data|
17
+ case range
18
+ when '1d', Date, DateTime
19
+ Chart::OneDay.new data
20
+ else
21
+ Chart::Default.new data
22
+ end
20
23
  end
21
24
  end
22
- rescue Faraday::ResourceNotFound => e
23
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
24
25
  end
25
26
  end
26
27
  end
@@ -1,3 +1,5 @@
1
+ require_relative 'base'
2
+
1
3
  module IEX
2
4
  module Resources
3
5
  class Company < Resource
@@ -11,10 +13,10 @@ module IEX
11
13
  property 'issue_type', from: 'issueType' # common issue type of the stock
12
14
  property 'sector'
13
15
 
14
- def self.get(symbol)
15
- new IEX::Api::Company.get(symbol)
16
- rescue Faraday::ResourceNotFound => e
17
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
16
+ def self.get(stock_symbol)
17
+ Base.symbol(stock_symbol) do
18
+ new IEX::Api::Company.get(stock_symbol)
19
+ end
18
20
  end
19
21
  end
20
22
  end
@@ -0,0 +1,15 @@
1
+ require_relative 'base'
2
+
3
+ module IEX
4
+ module Resources
5
+ class Logo < Resource
6
+ property 'url'
7
+
8
+ def self.get(stock_symbol)
9
+ Base.symbol(stock_symbol) do
10
+ new IEX::Api::Logo.get(stock_symbol).body
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'base'
2
+
1
3
  module IEX
2
4
  module Resources
3
5
  class News < Resource
@@ -8,12 +10,12 @@ module IEX
8
10
  property 'summary'
9
11
  property 'related', transform_with: ->(v) { v.split(',') if v.is_a?(String) }
10
12
 
11
- def self.get(symbol, range = nil)
12
- IEX::Api::News.get(symbol, range).map do |data|
13
- new data
13
+ def self.get(stock_symbol, range = nil)
14
+ Base.symbol(stock_symbol) do
15
+ IEX::Api::News.get(stock_symbol, range).map do |data|
16
+ new data
17
+ end
14
18
  end
15
- rescue Faraday::ResourceNotFound => e
16
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
17
19
  end
18
20
  end
19
21
  end
@@ -1,21 +1,22 @@
1
+ require_relative 'base'
1
2
  require_relative 'ohlc/base'
2
3
 
3
4
  module IEX
4
5
  module Resources
5
6
  module OHLC
6
- def self.get(symbol)
7
- resource = IEX::Api::OHLC.get(symbol)
8
- OHLC::Base.new resource
9
- rescue Faraday::ResourceNotFound => e
10
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
7
+ def self.get(stock_symbol)
8
+ IEX::Resources::Base.symbol(stock_symbol) do
9
+ resource = IEX::Api::OHLC.get(stock_symbol)
10
+ OHLC::Base.new resource
11
+ end
11
12
  end
12
13
 
13
14
  def self.market
14
- Hash[IEX::Api::OHLC.market.map do |k, v|
15
- [k, OHLC::Base.new(v)]
16
- end]
17
- rescue Faraday::ResourceNotFound => e
18
- raise IEX::Errors::SymbolNotFoundError.new('market', e.response[:body])
15
+ IEX::Resources::Base.symbol(nil) do
16
+ Hash[IEX::Api::OHLC.market.map do |k, v|
17
+ [k, OHLC::Base.new(v)]
18
+ end]
19
+ end
19
20
  end
20
21
  end
21
22
  end
@@ -1,10 +1,12 @@
1
+ require_relative 'base'
2
+
1
3
  module IEX
2
4
  module Resources
3
5
  module Price
4
- def self.get(symbol)
5
- IEX::Api::Price.get(symbol)
6
- rescue Faraday::ResourceNotFound => e
7
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
6
+ def self.get(stock_symbol)
7
+ Base.symbol(stock_symbol) do
8
+ IEX::Api::Price.get(stock_symbol)
9
+ end
8
10
  end
9
11
  end
10
12
  end
@@ -1,3 +1,5 @@
1
+ require_relative 'base'
2
+
1
3
  module IEX
2
4
  module Resources
3
5
  class Quote < Resource
@@ -51,10 +53,10 @@ module IEX
51
53
  property 'week_52_low', from: 'week52Low' # adjusted 52 week low
52
54
  property 'ytd_change', from: 'ytdChange' # price change percentage from start of year to previous close
53
55
 
54
- def self.get(symbol)
55
- new IEX::Api::Quote.get(symbol)
56
- rescue Faraday::ResourceNotFound => e
57
- raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
56
+ def self.get(stock_symbol)
57
+ Base.symbol(stock_symbol) do
58
+ new IEX::Api::Quote.get(stock_symbol)
59
+ end
58
60
  end
59
61
  end
60
62
  end
@@ -1,3 +1,3 @@
1
1
  module IEX
2
- VERSION = '0.3.3'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.iextrading.com/1.0/stock/MSFT/chart/1d?badOption=option&chartInterval=10
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 400
19
+ message: Bad Request
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 27 Jul 2018 00:59:53 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - '40'
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=cd9863332b4546a4a6b8f0a9550e7030; Domain=.iextrading.com; Path=/; Expires=Fri,
33
+ 27 Jul 2018 12:59:53 GMT; Secure
34
+ Content-Security-Policy:
35
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
36
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
37
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
38
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
39
+ 'self' 'unsafe-inline' 'unsafe-eval';
40
+ X-Content-Security-Policy:
41
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
42
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
43
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
44
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
45
+ 'self' 'unsafe-inline' 'unsafe-eval';
46
+ Frame-Options:
47
+ - SAMEORIGIN
48
+ X-Frame-Options:
49
+ - SAMEORIGIN
50
+ Strict-Transport-Security:
51
+ - max-age=15768000
52
+ Access-Control-Allow-Origin:
53
+ - "*"
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ Access-Control-Allow-Methods:
57
+ - GET, OPTIONS
58
+ Access-Control-Allow-Headers:
59
+ - Origin, X-Requested-With, Content-Type, Accept
60
+ body:
61
+ encoding: UTF-8
62
+ string: '{"error":"\"badOption\" is not allowed"}'
63
+ http_version:
64
+ recorded_at: Fri, 27 Jul 2018 00:59:53 GMT
65
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.iextrading.com/1.0/stock/msft/logo
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Thu, 26 Jul 2018 02:21:28 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - '63'
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=4dae8f73e709423697c3c7af35f4a156; Domain=.iextrading.com; Path=/; Expires=Thu,
33
+ 26 Jul 2018 14:21:28 GMT; Secure
34
+ Content-Security-Policy:
35
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
36
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
37
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
38
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
39
+ 'self' 'unsafe-inline' 'unsafe-eval';
40
+ X-Content-Security-Policy:
41
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
42
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
43
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
44
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
45
+ 'self' 'unsafe-inline' 'unsafe-eval';
46
+ Frame-Options:
47
+ - SAMEORIGIN
48
+ X-Frame-Options:
49
+ - SAMEORIGIN
50
+ X-Content-Type-Options:
51
+ - nosniff
52
+ Strict-Transport-Security:
53
+ - max-age=15768000
54
+ Access-Control-Allow-Origin:
55
+ - "*"
56
+ Access-Control-Allow-Credentials:
57
+ - 'true'
58
+ Access-Control-Allow-Methods:
59
+ - GET, OPTIONS
60
+ Access-Control-Allow-Headers:
61
+ - Origin, X-Requested-With, Content-Type, Accept
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{"url":"https://storage.googleapis.com/iex/api/logos/MSFT.png"}'
65
+ http_version:
66
+ recorded_at: Thu, 26 Jul 2018 02:21:28 GMT
67
+ recorded_with: VCR 4.0.0
@@ -17,6 +17,7 @@ describe IEX::Resources::Chart do
17
17
  expect(last.label).to eq 'Mar 26'
18
18
  end
19
19
  end
20
+
20
21
  context '1d', vcr: { cassette_name: 'chart/1d' } do
21
22
  subject do
22
23
  IEX::Resources::Chart.get('MSFT', '1d')
@@ -32,6 +33,7 @@ describe IEX::Resources::Chart do
32
33
  expect(first.minute).to eq '09:30'
33
34
  end
34
35
  end
36
+
35
37
  context 'with options', vcr: { cassette_name: 'chart/chartInterval' } do
36
38
  subject do
37
39
  IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10)
@@ -42,6 +44,7 @@ describe IEX::Resources::Chart do
42
44
  expect(first).to be_a IEX::Resources::Chart::OneDay
43
45
  end
44
46
  end
47
+
45
48
  context 'date', vcr: { cassette_name: 'chart/20180227' } do
46
49
  subject do
47
50
  IEX::Resources::Chart.get('MSFT', Date.new(2018, 2, 27))
@@ -53,6 +56,7 @@ describe IEX::Resources::Chart do
53
56
  expect(first.date).to eq Date.new(2018, 2, 27)
54
57
  end
55
58
  end
59
+
56
60
  context 'dynamic 1m', vcr: { cassette_name: 'chart/dynamic/1m' } do
57
61
  subject do
58
62
  IEX::Resources::Chart.get('MSFT', :dynamic)
@@ -64,6 +68,7 @@ describe IEX::Resources::Chart do
64
68
  expect(first.date).to eq Date.new(2018, 2, 26)
65
69
  end
66
70
  end
71
+
67
72
  context 'invalid symbol', vcr: { cassette_name: 'chart/invalid' } do
68
73
  subject do
69
74
  IEX::Resources::Chart.get('INVALID')
@@ -72,4 +77,14 @@ describe IEX::Resources::Chart do
72
77
  expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
73
78
  end
74
79
  end
80
+
81
+ context 'with client error', vcr: { cassette_name: 'chart/bad_option' } do
82
+ subject do
83
+ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, bad_option: 'option')
84
+ end
85
+
86
+ it 'fails with ClientError' do
87
+ expect { subject }.to raise_error IEX::Errors::ClientError, '"badOption" is not allowed'
88
+ end
89
+ end
75
90
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Resources::Logo do
4
+ context "retrieves company's logo", vcr: { cassette_name: 'logo/msft' } do
5
+ subject do
6
+ IEX::Resources::Logo.get('MSFT')
7
+ end
8
+
9
+ it 'retrieves a logo' do
10
+ expect(subject.url).to eq 'https://storage.googleapis.com/iex/api/logos/MSFT.png'
11
+ end
12
+ end
13
+ end
@@ -24,6 +24,7 @@ describe IEX::Resources::OHLC do
24
24
  expect(subject.open.time.to_f).to eq 1_528_723_800.272
25
25
  end
26
26
  end
27
+
27
28
  context 'market', vcr: { cassette_name: 'ohlc/market' } do
28
29
  subject do
29
30
  IEX::Resources::OHLC.market
@@ -9,6 +9,7 @@ describe IEX::Resources::Price do
9
9
  expect(subject).to eq 93.78
10
10
  end
11
11
  end
12
+
12
13
  context 'invalid symbol', vcr: { cassette_name: 'price/invalid' } do
13
14
  subject do
14
15
  IEX::Resources::Price.get('INVALID')
@@ -26,6 +26,7 @@ describe IEX::Resources::Quote do
26
26
  expect(subject.iex_last_updated_t).to be nil
27
27
  end
28
28
  end
29
+
29
30
  context 'invalid symbol', vcr: { cassette_name: 'quote/invalid' } do
30
31
  subject do
31
32
  IEX::Resources::Quote.get('INVALID')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iex-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -140,23 +140,28 @@ files:
140
140
  - README.md
141
141
  - RELEASING.md
142
142
  - Rakefile
143
+ - UPGRADING.md
143
144
  - iex-ruby-client.gemspec
144
145
  - lib/iex-ruby-client.rb
145
146
  - lib/iex/api.rb
146
147
  - lib/iex/api/chart.rb
147
148
  - lib/iex/api/company.rb
149
+ - lib/iex/api/logo.rb
148
150
  - lib/iex/api/news.rb
149
151
  - lib/iex/api/ohlc.rb
150
152
  - lib/iex/api/price.rb
151
153
  - lib/iex/api/quote.rb
152
154
  - lib/iex/errors.rb
155
+ - lib/iex/errors/client_error.rb
153
156
  - lib/iex/errors/symbol_not_found_error.rb
154
157
  - lib/iex/resources.rb
158
+ - lib/iex/resources/base.rb
155
159
  - lib/iex/resources/chart.rb
156
160
  - lib/iex/resources/chart/base.rb
157
161
  - lib/iex/resources/chart/default.rb
158
162
  - lib/iex/resources/chart/one_day.rb
159
163
  - lib/iex/resources/company.rb
164
+ - lib/iex/resources/logo.rb
160
165
  - lib/iex/resources/news.rb
161
166
  - lib/iex/resources/ohlc.rb
162
167
  - lib/iex/resources/ohlc/base.rb
@@ -167,12 +172,14 @@ files:
167
172
  - lib/iex/version.rb
168
173
  - spec/fixtures/iex/chart/1d.yml
169
174
  - spec/fixtures/iex/chart/20180227.yml
175
+ - spec/fixtures/iex/chart/bad_option.yml
170
176
  - spec/fixtures/iex/chart/chartInterval.yml
171
177
  - spec/fixtures/iex/chart/dynamic/1m.yml
172
178
  - spec/fixtures/iex/chart/invalid.yml
173
179
  - spec/fixtures/iex/chart/msft.yml
174
180
  - spec/fixtures/iex/company/invalid.yml
175
181
  - spec/fixtures/iex/company/msft.yml
182
+ - spec/fixtures/iex/logo/msft.yml
176
183
  - spec/fixtures/iex/news/invalid.yml
177
184
  - spec/fixtures/iex/news/market.yml
178
185
  - spec/fixtures/iex/news/msft.yml
@@ -185,6 +192,7 @@ files:
185
192
  - spec/fixtures/iex/quote/msft.yml
186
193
  - spec/iex/resources/chart_spec.rb
187
194
  - spec/iex/resources/company_spec.rb
195
+ - spec/iex/resources/logo_spec.rb
188
196
  - spec/iex/resources/news_spec.rb
189
197
  - spec/iex/resources/ohlc_spec.rb
190
198
  - spec/iex/resources/price_spec.rb
@@ -212,19 +220,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
220
  version: 1.3.6
213
221
  requirements: []
214
222
  rubyforge_project:
215
- rubygems_version: 2.7.7
223
+ rubygems_version: 2.5.2
216
224
  signing_key:
217
225
  specification_version: 4
218
226
  summary: IEX Finance API Ruby client with support for retrieving stock quotes.
219
227
  test_files:
220
228
  - spec/fixtures/iex/chart/1d.yml
221
229
  - spec/fixtures/iex/chart/20180227.yml
230
+ - spec/fixtures/iex/chart/bad_option.yml
222
231
  - spec/fixtures/iex/chart/chartInterval.yml
223
232
  - spec/fixtures/iex/chart/dynamic/1m.yml
224
233
  - spec/fixtures/iex/chart/invalid.yml
225
234
  - spec/fixtures/iex/chart/msft.yml
226
235
  - spec/fixtures/iex/company/invalid.yml
227
236
  - spec/fixtures/iex/company/msft.yml
237
+ - spec/fixtures/iex/logo/msft.yml
228
238
  - spec/fixtures/iex/news/invalid.yml
229
239
  - spec/fixtures/iex/news/market.yml
230
240
  - spec/fixtures/iex/news/msft.yml
@@ -237,6 +247,7 @@ test_files:
237
247
  - spec/fixtures/iex/quote/msft.yml
238
248
  - spec/iex/resources/chart_spec.rb
239
249
  - spec/iex/resources/company_spec.rb
250
+ - spec/iex/resources/logo_spec.rb
240
251
  - spec/iex/resources/news_spec.rb
241
252
  - spec/iex/resources/ohlc_spec.rb
242
253
  - spec/iex/resources/price_spec.rb