Sha256: 8f7a8c91fb36a0735118fa9610f004c93ebb6fa7786dae8ed1ac70b90e46a63d
Contents?: true
Size: 775 Bytes
Versions: 4
Compression:
Stored size: 775 Bytes
Contents
# frozen_string_literal: true module Cased class Response attr_reader :body, :exception def initialize(response: nil, exception: nil) @response = response @body = response&.body @exception = exception end def error @exception.presence || (body && body['error']).presence end def error? # If there was an exception during the execution of the request. return true if @exception.present? # If the HTTP response was outside of 200-299 return true unless @response.success? # If the HTTP response contained an error key. return true if body && body['error'].present? false end def success? return false if @response.nil? @response.success? end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cased-ruby-0.8.0 | lib/cased/response.rb |
cased-ruby-0.7.1 | lib/cased/response.rb |
cased-ruby-0.7.0 | lib/cased/response.rb |
cased-ruby-0.6.1 | lib/cased/response.rb |