Sha256: 6e73596cf8f26487b62d782c342304f7eb7d453cf7c40db7b0b0c138a32b3432

Contents?: true

Size: 552 Bytes

Versions: 6

Compression:

Stored size: 552 Bytes

Contents

module Workarea
  module Sezzle
    class Response
      def initialize(response)
        @response = response
      end

      def success?
        @response.present? && (@response.status == 201 || @response.status == 200)
      end

      def body
        return {} unless @response.body.present? && @response.body != 'null'

        response_body = JSON.parse(@response.body)

        return response_body.first if response_body.kind_of?(Array)

        response_body
      end

      def status
        @response.status
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-sezzle-1.0.5 lib/workarea/sezzle/response.rb
workarea-sezzle-1.0.4 lib/workarea/sezzle/response.rb
workarea-sezzle-1.0.3 lib/workarea/sezzle/response.rb
workarea-sezzle-1.0.2 lib/workarea/sezzle/response.rb
workarea-sezzle-1.0.1 lib/workarea/sezzle/response.rb
workarea-sezzle-1.0.0 lib/workarea/sezzle/response.rb