Class: DataStream::Session
- Inherits:
-
Object
- Object
- DataStream::Session
- Includes:
- DssUtilities, HTTParty
- Defined in:
- lib/data_stream_api.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #configured? ⇒ Boolean
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #not_configured_error ⇒ Object
Methods included from DssUtilities
Constructor Details
#initialize ⇒ Session
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 login_path = "/DSWSClient/V1/DSService.svc/rest/Token" = { query: { "UserName" => Config::DATA_STREAM_USERNAME, "Password" => Config::DATA_STREAM_PASSWORD } } if configured? resp = self.class.get login_path, @token = resp["TokenValue"] @expiry = parseDate(resp["TokenExpiry"]) @logger.debug resp else not_configured_error end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/data_stream_api.rb', line 14 def context @context end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/data_stream_api.rb', line 14 def logger @logger end |
#token ⇒ Object (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
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_error ⇒ Object
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 |