Class: DataScope::Session
- Inherits:
-
Object
- Object
- DataScope::Session
- Includes:
- HTTParty
- Defined in:
- lib/data_scope_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
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/data_scope_api.rb', line 23 def initialize @logger = ::Logger.new(STDOUT) @logger.level = Config::LOG_LEVEL login_path = "/RestApi/v1/Authentication/RequestToken" = { headers: { "Prefer" => "respond-async", "Content-Type" => "application/json; odata=minimalmetadata" }, body: { "Credentials" =>{ "Username" => Config::DATA_SCOPE_USERNAME, "Password" => Config::DATA_SCOPE_PASSWORD } }.to_json } if configured? resp = self.class.post login_path, @token = resp["value"] @context = resp["@odata.context"] @logger.debug resp else not_configured_error end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
13 14 15 |
# File 'lib/data_scope_api.rb', line 13 def context @context end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/data_scope_api.rb', line 13 def logger @logger end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
13 14 15 |
# File 'lib/data_scope_api.rb', line 13 def token @token end |
Instance Method Details
#configured? ⇒ Boolean
15 16 17 |
# File 'lib/data_scope_api.rb', line 15 def configured? !Config::DATA_SCOPE_USERNAME.nil? and !Config::DATA_SCOPE_PASSWORD.nil? end |
#not_configured_error ⇒ Object
19 20 21 |
# File 'lib/data_scope_api.rb', line 19 def not_configured_error @logger.error "dss_reuters gem not configured. you will not be able to fetch data from data scope API" end |