Class: XodClient::TokenRefresher
- Inherits:
-
Object
- Object
- XodClient::TokenRefresher
- Includes:
- ParseUtil
- Defined in:
- lib/xod_client/token_refresher.rb
Instance Attribute Summary collapse
-
#xod_conn ⇒ Object
readonly
Returns the value of attribute xod_conn.
Instance Method Summary collapse
-
#initialize(xod_conn) ⇒ TokenRefresher
constructor
A new instance of TokenRefresher.
- #perform ⇒ Object
Methods included from ParseUtil
Constructor Details
#initialize(xod_conn) ⇒ TokenRefresher
Returns a new instance of TokenRefresher.
7 8 9 |
# File 'lib/xod_client/token_refresher.rb', line 7 def initialize(xod_conn) @xod_conn = xod_conn end |
Instance Attribute Details
#xod_conn ⇒ Object (readonly)
Returns the value of attribute xod_conn.
5 6 7 |
# File 'lib/xod_client/token_refresher.rb', line 5 def xod_conn @xod_conn end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/xod_client/token_refresher.rb', line 11 def perform res = xod_conn.faraday.post do |req| req.url xod_conn.config.login_url req.headers['Content-Type'] = 'application/json' req.body = { relyingParty: xod_conn., thirdPartyId: 'XporterOnDemand', estab: xod_conn.estab, password: xod_conn.secret }.to_json end token_json = parse_xod_response(res) token = token_json[:token] token_expires_at = Time.iso8601(token_json[:expires]) [token, token_expires_at] end |