Sha256: 1f40871219846b0a22afd24ea67da715f48d2f02a970648dfeb4ecce9ff344c0
Contents?: true
Size: 790 Bytes
Versions: 13
Compression:
Stored size: 790 Bytes
Contents
# frozen_string_literal: true module Cased class Response attr_reader :body attr_reader :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
13 entries across 13 versions & 1 rubygems