Class: Reuters::Client::Token
Overview
A retrieved token is stored as a static variable, attached to this class. It will only be retrieved once, and then again up expiry.
Retrieves a new Token from the Reuter’s API using the credentials that have been globally configured.
Instance Attribute Summary collapse
-
#app_id ⇒ String, Nil
readonly
The application id that will be used to authenticate with the Reuter’s api.
-
#expiration ⇒ Integer, Nil
readonly
The timestamp at which the associated token will expire.
-
#password ⇒ String, Nil
readonly
The password that will be used to authenticate with the Reuter’s api.
-
#token ⇒ String, Nil
readonly
The token that has been retrieved from the Reuter’s API.
-
#username ⇒ String, Nil
readonly
The username that will be used to authenticate with the Reuter’s api.
Instance Method Summary collapse
-
#authenticate ⇒ Token
Authenticates with Reuters and automatically attempts to retieve a new token from the Reuter’s API.
- #header ⇒ Object
-
#initialize ⇒ Token
constructor
Override Base constructor and avoid setting a token as it will crash the client.
-
#message ⇒ Hash
Build the authentication message that will be sent to Reuters.
Methods inherited from Base
#after_request, #before_request, #client, #method_missing, #request
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Reuters::Client::Base
Instance Attribute Details
#app_id ⇒ String, Nil (readonly)
The application id that will be used to authenticate with the Reuter’s api.
46 |
# File 'lib/reuters/client/token.rb', line 46 delegate :token, :expiration, to: :current_response |
#expiration ⇒ Integer, Nil (readonly)
The timestamp at which the associated token will expire.
|
# File 'lib/reuters/client/token.rb', line 23
|
#password ⇒ String, Nil (readonly)
The password that will be used to authenticate with the Reuter’s api.
|
# File 'lib/reuters/client/token.rb', line 34
|
#token ⇒ String, Nil (readonly)
The token that has been retrieved from the Reuter’s API.
|
# File 'lib/reuters/client/token.rb', line 19
|
#username ⇒ String, Nil (readonly)
The username that will be used to authenticate with the Reuter’s api.
|
# File 'lib/reuters/client/token.rb', line 28
|
Instance Method Details
#authenticate ⇒ Token
Authenticates with Reuters and automatically attempts to retieve a new token from the Reuter’s API.
73 74 75 |
# File 'lib/reuters/client/token.rb', line 73 def authenticate @@response = create_service_token_1(, {}, false) end |
#header ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/reuters/client/token.rb', line 77 def header response = current_response Reuters::Builder.new do |body| body..application_id = app_id body..token = response.token body.({ 'xmlns' => common.endpoint }, false) end end |
#message ⇒ Hash
Build the authentication message that will be sent to Reuters.
60 61 62 63 64 65 66 67 |
# File 'lib/reuters/client/token.rb', line 60 def Reuters::Builder.new do |body| body.application_id = app_id body.username = username body.password = password body.application_id({ xmlns: common.endpoint }, false) end end |