class DataStream::Session

Attributes

context[R]
logger[R]
token[R]

Public Class Methods

new() click to toggle source
# File lib/data_stream_api.rb, line 24
def initialize
  @logger = ::Logger.new(STDOUT)
  @logger.level = Config::LOG_LEVEL
  login_path = "/DSWSClient/V1/DSService.svc/rest/Token"
  options = {
    query: {
      "UserName" => Config::DATA_STREAM_USERNAME,
      "Password" => Config::DATA_STREAM_PASSWORD
    }
  }
  if configured?
    resp = self.class.get login_path, options
    @token = resp["TokenValue"]
    @expiry = parseDate(resp["TokenExpiry"])
    @logger.debug resp
  else
    not_configured_error
  end
end

Public Instance Methods

configured?() click to toggle source
# File lib/data_stream_api.rb, line 16
def configured?
  !Config::DATA_STREAM_USERNAME.nil? and !Config::DATA_STREAM_PASSWORD.nil?
end
not_configured_error() click to toggle source
# File lib/data_stream_api.rb, line 20
def not_configured_error
  @logger.error "dss_reuters gem not configured. you will not be able to fetch data from data stream API"
end