Class: EODData::Client
- Inherits:
-
Object
- Object
- EODData::Client
- Defined in:
- lib/eod_data/client.rb
Overview
:nodoc:
Defined Under Namespace
Classes: BushelPrice, CentsPerPoundPrice, LoginResponse, LoginResult, OriginalPrice, Quote, QuoteGetResponse, QuoteGetResult, QuoteList2Response, QuoteList2Result, QuoteListByDateResponse, QuoteListByDateResult, Response, Result, SavonRequest
Class Attribute Summary collapse
-
.base_url ⇒ Object
Returns the value of attribute base_url.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.password ⇒ Object
Returns the value of attribute password.
-
.price_conversion_class_names ⇒ Object
Returns the value of attribute price_conversion_class_names.
-
.proxy_url ⇒ Object
Returns the value of attribute proxy_url.
-
.request_type ⇒ Object
Returns the value of attribute request_type.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
“‘ruby EODData::Client.configure do |config| config.base_url = ’localhost:3000’ config.logger = Logger.new(STDOUT) config.password = ‘password’ config.price_conversion_class_names = { ZC: ‘OriginalPrice’ ZM: ‘TonPrice’ } config.username = ‘username’ end “‘ elsewhere.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
- #quote(exchange, symbol) ⇒ Object
- #quotes(exchange, symbols) ⇒ Object
- #quotes_by_date(exchange, quote_date) ⇒ Object
-
#token ⇒ String
Login Token.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/eod_data/client.rb', line 39 def initialize( = {}) = .merge() @base_url = [:base_url] @logger = .compact.fetch(:logger, Logger.new(STDOUT)) @proxy_url = [:proxy_url] @password = [:password] @username = [:username] @request = SavonRequest.new(@base_url, @logger, @proxy_url) end |
Class Attribute Details
.base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def base_url @base_url end |
.logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def logger @logger end |
.password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def password @password end |
.price_conversion_class_names ⇒ Object
Returns the value of attribute price_conversion_class_names.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def price_conversion_class_names @price_conversion_class_names end |
.proxy_url ⇒ Object
Returns the value of attribute proxy_url.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def proxy_url @proxy_url end |
.request_type ⇒ Object
Returns the value of attribute request_type.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def request_type @request_type end |
.username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/eod_data/client.rb', line 8 def username @username end |
Class Method Details
.configure {|_self| ... } ⇒ Object
“‘ruby EODData::Client.configure do |config|
config.base_url = 'http://localhost:3000'
config.logger = Logger.new(STDOUT)
config.password = 'password'
config.price_conversion_class_names = {
ZC: 'OriginalPrice'
ZM: 'TonPrice'
}
config.username = 'username'
end “‘ elsewhere
“‘ruby client = EODData::Client.new “`
33 34 35 36 |
# File 'lib/eod_data/client.rb', line 33 def configure yield self true end |
Instance Method Details
#login ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/eod_data/client.rb', line 50 def login = { Username: @username, Password: @password } response = @request.perform_request(:login, message: ) LoginResponse.new(response).result end |
#quote(exchange, symbol) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/eod_data/client.rb', line 58 def quote(exchange, symbol) = { Exchange: exchange, Symbol: symbol, Token: token } response = @request.perform_request(:quote_get, message: ) QuoteGetResponse.new(response).result end |
#quotes(exchange, symbols) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/eod_data/client.rb', line 66 def quotes(exchange, symbols) = { Exchange: exchange, Symbols: symbols.join(','), Token: token } response = @request.perform_request(:quote_list2, message: ) QuoteList2Response.new(response).result end |
#quotes_by_date(exchange, quote_date) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/eod_data/client.rb', line 74 def quotes_by_date(exchange, quote_date) = { Exchange: exchange, QuoteDate: quote_date.strftime('%Y%m%d'), Token: token } response = @request.perform_request(:quote_list_by_date, message: ) QuoteListByDateResponse.new(response).result end |
#token ⇒ String
Returns Login Token.
90 91 92 93 94 |
# File 'lib/eod_data/client.rb', line 90 def token return @token if @token @token = login.token end |