Sha256: f2706b5083fa69b3561150aa0e5a3b4ec941fbfdbdb2bd6c88e4685944ce85be

Contents?: true

Size: 844 Bytes

Versions: 4

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

module Afterpay
  module HTTPService
    class Response
      extend Forwardable
      # @attribute status
      # @return [Integer] HTTP response status
      attr_reader :status

      # @attribute body
      # @return [Hash] HTTP response body
      attr_reader :body

      # @attribute headers
      # @return [Hash] HTTP response headers
      attr_reader :headers

      def_delegators :body, :message
      # Creates Afterpay::HTTPService::Response instance
      # @param  [Hash] params hash of parameters
      # @return [Afterpay::HTTPService::Response] Response instance
      def initialize(params = {})
        @status  = params[:status]
        @body    = params[:body]
        @headers = params[:headers]
      end

      def ok?
        (200..204).cover?(status.to_i)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
afterpay-0.6.0 lib/afterpay/http_service/response.rb
afterpay-0.5.0 lib/afterpay/http_service/response.rb
afterpay-0.4.0 lib/afterpay/http_service/response.rb
afterpay-0.3.0 lib/afterpay/http_service/response.rb