Skip to content

Commit

Permalink
Market list endpoint was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
bguban committed Mar 4, 2020
1 parent 0ccfe9d commit c5cb445
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 1.1.2 (Next)

* Your contribution here.
* [#65](https://github.com/dblock/iex-ruby-client/pull/65): Market list endpoint was added - [@bguban](https://github.com/bguban).

### 1.1.1 (2020/03/02)

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
- [Get Sector Performance](#get-sector-performance)
- [Get Largest Trades](#get-largest-trades)
- [Get a Quote for Crypto Currencies](#get-a-quote-for-crypto-currencies)
- [Get List](#get-list)
- [Other Requests](#other-requests)
- [Configuration](#configuration)
- [Errors](#errors)
Expand Down Expand Up @@ -372,6 +373,16 @@ crypto.high_dollar #'$3,590'

See [#crypto](https://iexcloud.io/docs/api/#crypto) for detailed documentation or [crypto.rb](lib/iex/resources/crypto.rb) for returned fields.

### Get List

Returns an array of quotes for the top 10 symbols in a specified list.

```ruby
client.list(:mostactive) # [{symbol: 'AAPL', ...}, {...}]
```

See [#list](https://iexcloud.io/docs/api/#list) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.

### Other Requests

Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
Expand Down
1 change: 1 addition & 0 deletions lib/iex/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require_relative 'endpoints/quote'
require_relative 'endpoints/sectors'
require_relative 'endpoints/crypto'
require_relative 'endpoints/list'

require_relative 'api/config'
require_relative 'api/client'
1 change: 1 addition & 0 deletions lib/iex/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Client
include Endpoints::Price
include Endpoints::Quote
include Endpoints::Sectors
include Endpoints::List

include Cloud::Connection
include Cloud::Request
Expand Down
11 changes: 11 additions & 0 deletions lib/iex/endpoints/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module IEX
module Endpoints
module List
def list(list_type, options = {})
get("stock/market/list/#{list_type}", { token: publishable_token }.merge(options)).map do |data|
IEX::Resources::Quote.new(data)
end
end
end
end
end
76 changes: 76 additions & 0 deletions spec/fixtures/iex/list/mostactive.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions spec/iex/endpoints/list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

describe IEX::Endpoints::List do
include_context 'client'

describe '#list', vcr: { cassette_name: 'list/mostactive' } do
subject { client.list(:mostactive) }

it 'retrieves a list of quotes' do
expect(subject).to all(be_a(IEX::Resources::Quote))
expect(subject.map(&:symbol)).to match_array(%w[AAPL AMD BAC F GE INO INTC MSFT T XOM])
end
end
end

0 comments on commit c5cb445

Please sign in to comment.