Sha256: 17034d7e788e5d95522af93e1d84f0f685eec4db68c2cc85f7f07e34feb7e796

Contents?: true

Size: 542 Bytes

Versions: 1

Compression:

Stored size: 542 Bytes

Contents

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

      def success?
        @response.present? && [200, 201, 204].include?(@response.status)
      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

1 entries across 1 versions & 1 rubygems

Version Path
workarea-sezzle-1.0.6 lib/workarea/sezzle/response.rb