class Alpharb::Client
Constants
- API_ENDPOINT
Attributes
token[R]
Public Class Methods
new(token = nil)
click to toggle source
# File lib/alpharb/client.rb, line 7 def initialize(token = nil) @token = token end
Public Instance Methods
quote(symbol)
click to toggle source
# File lib/alpharb/client.rb, line 15 def quote(symbol) request params: { function: 'GLOBAL_QUOTE', symbol: symbol } end
search(keywords)
click to toggle source
# File lib/alpharb/client.rb, line 11 def search(keywords) request params: { function: 'SYMBOL_SEARCH', keywords: keywords } end
Private Instance Methods
client()
click to toggle source
# File lib/alpharb/client.rb, line 21 def client @_client ||= Faraday.new(API_ENDPOINT) do |client| client.request :url_encoded client.adapter Faraday.default_adapter end end
request(http_method: :get, endpoint: "query", params: {})
click to toggle source
# File lib/alpharb/client.rb, line 28 def request(http_method: :get, endpoint: "query", params: {}) response = client.public_send(http_method, endpoint, params.merge(apikey: @token)) Oj.load(response.body, { symbol_keys: true }) end