class ADAL::TokenResponse

The return type of all of the instance methods that return tokens.

Public Class Methods

parse(raw_response) click to toggle source

Constructs a TokenResponse from a raw hash. It will return either a SuccessResponse or an ErrorResponse depending on the fields of the hash.

@param Hash raw_response

The body of the HTTP response expressed as a raw hash.

@return TokenResponse

# 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

Public Instance Methods

error?() click to toggle source

Shorthand for checking if a token response is successful or failed.

@return Boolean

# File lib/adal/token_response.rb, line 59
def error?
  self.respond_to? :error
end