class Unimatrix::Authorization::Response

Attributes

body[R]
code[R]
resources[R]

Public Class Methods

new( http_response, path = "" ) click to toggle source
# File lib/unimatrix/authorization/response.rb, line 9
def initialize( http_response, path = "" )
  @request_path   = path
  @success        = http_response.is_a?( Net::HTTPOK )
  @code           = http_response.code
  @resources      = []
  @body           = decode_response_body( http_response )

  if ( @body && @body.respond_to?( :keys ) )
    Parser.new( @body, @request_path ) do | parser |
      @resources = parser.resources
      @success   = !( parser.type_name == 'error' )
    end
  else
    @success  = false
    @resources << Unimatrix::Error.new(
      message: "#{ @code }: #{ http_response.message }."
    )
  end
end