Class: DataStream::Session

Inherits:
Object
  • Object
show all
Includes:
DssUtilities, HTTParty
Defined in:
lib/data_stream_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DssUtilities

#parseDate

Constructor Details

#initializeSession

Returns a new instance of Session.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/data_stream_api.rb', line 24

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



14
15
16
# File 'lib/data_stream_api.rb', line 14

def context
  @context
end

#loggerObject (readonly)

Returns the value of attribute logger.



14
15
16
# File 'lib/data_stream_api.rb', line 14

def logger
  @logger
end

#tokenObject (readonly)

Returns the value of attribute token.



14
15
16
# File 'lib/data_stream_api.rb', line 14

def token
  @token
end

Instance Method Details

#configured?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/data_stream_api.rb', line 16

def configured?
  !Config::DATA_STREAM_USERNAME.nil? and !Config::DATA_STREAM_PASSWORD.nil?
end

#not_configured_errorObject



20
21
22
# 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