Module: WOTC::Client::Utils
- Included in:
- WOTC::Client
- Defined in:
- lib/wotc/client/utils.rb
Overview
Defines methods related to utils
Instance Method Summary collapse
-
#token_state ⇒ Object
Ask wotc.com whether our access token is still accepted.
-
#token_valid? ⇒ Boolean
Kept for compatibility.
-
#wotc_calculator(options = {}) ⇒ Object
Pre-qualify an application of WOTC status.
Instance Method Details
#token_state ⇒ Object
Ask wotc.com whether our access token is still accepted.
Returns :valid, :revoked or :unknown.
Only a 401 means revoked. A 403, a 5xx, a timeout or a body we cannot read means we could not tell, and callers must not treat that as revocation.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wotc/client/utils.rb', line 13 def token_state body = get('user').body return :valid if body.is_a?(Hash) && !body['id'].nil? :unknown rescue WOTC::Unauthorized :revoked rescue StandardError :unknown end |
#token_valid? ⇒ Boolean
Kept for compatibility. Prefer #token_state: this collapses "revoked" and "could not tell" into the same false.
26 27 28 |
# File 'lib/wotc/client/utils.rb', line 26 def token_valid? token_state == :valid end |
#wotc_calculator(options = {}) ⇒ Object
Pre-qualify an application of WOTC status
31 32 33 34 |
# File 'lib/wotc/client/utils.rb', line 31 def wotc_calculator(={}) result = post('wotc/calculator', ) result.body == true end |