Sha256: 3e219d37901fcfc904fea40ff0e2c7099c0cfd5a4b40d44c2789dabb87130fbd

Contents?: true

Size: 754 Bytes

Versions: 10

Compression:

Stored size: 754 Bytes

Contents

module Unimatrix::Authorization

  class Response < Unimatrix::Response

    attr_reader :code
    attr_reader :body
    attr_reader :resources

    def initialize( http_response )
      @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 ) 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

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
unimatrix-2.6.1 lib/unimatrix/authorization/response.rb
unimatrix-2.6.0 lib/unimatrix/authorization/response.rb
unimatrix-2.5.5 lib/unimatrix/authorization/response.rb
unimatrix-2.5.4 lib/unimatrix/authorization/response.rb
unimatrix-2.5.3 lib/unimatrix/authorization/response.rb
unimatrix-2.5.2 lib/unimatrix/authorization/response.rb
unimatrix-2.5.1 lib/unimatrix/authorization/response.rb
unimatrix-2.5.0 lib/unimatrix/authorization/response.rb
unimatrix-2.4.2 lib/unimatrix/authorization/response.rb
unimatrix-2.3.1 lib/unimatrix/authorization/response.rb