Class: ADAL::TokenResponse
- Inherits:
-
Object
- Object
- ADAL::TokenResponse
- Extended by:
- Logging
- Defined in:
- lib/adal/token_response.rb
Overview
The return type of all of the instance methods that return tokens.
Direct Known Subclasses
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::DEFAULT_LOG_OUTPUT
Class Method Summary collapse
-
.parse(raw_response) ⇒ Object
Constructs a TokenResponse from a raw hash.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Shorthand for checking if a token response is successful or failed.
Methods included from Logging
Class Method Details
.parse(raw_response) ⇒ Object
Constructs a TokenResponse from a raw hash. It will return either a SuccessResponse or an ErrorResponse depending on the fields of the hash.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/adal/token_response.rb', line 42 def self.parse(raw_response) logger.verbose('Attempting to create a TokenResponse from raw response.') if raw_response.nil? ErrorResponse.new elsif raw_response['error'] ErrorResponse.new(JSON.parse(raw_response)) else SuccessResponse.new(JSON.parse(raw_response)) end end |
Instance Method Details
#error? ⇒ Boolean
Shorthand for checking if a token response is successful or failed.
59 60 61 |
# File 'lib/adal/token_response.rb', line 59 def error? self.respond_to? :error end |