Sha256: 6fc121fbb60e952279557d6b76ef3d8c72fb27a0be7474ab8ad64224d3f362d8

Contents?: true

Size: 978 Bytes

Versions: 8

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

module Fawry
  class FawryResponse
    include Utils

    attr_reader :fawry_api_response

    def initialize(fawry_api_response)
      @fawry_api_response = fawry_api_response

      build_response
    end

    def success?
      status_code == 200
    end

    def failure?
      !success?
    end

    def fawry_api_response_body
      fawry_api_response
    end

    private

    # Adds keys from fawry API response as methods
    # on FawryResponse instance that return the value
    # of each key
    #
    # type => type
    # referenceNumber => reference_number
    # merchantRefNumber => merchant_ref_number
    # expirationTime => expiration_time
    # statusCode => status_code
    # statusDescription => status_description
    #
    # fawry_res = FawryResponse.new(response)
    # fawry_res.status_code => 200
    # fawry_res.reference_number => 1234567
    def build_response
      enrich_object(fawry_api_response)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fawry-1.4.1 lib/fawry/fawry_response.rb
fawry-1.4.0 lib/fawry/fawry_response.rb
fawry-1.3.1 lib/fawry/fawry_response.rb
fawry-1.3.0 lib/fawry/fawry_response.rb
fawry-1.2.1 lib/fawry/fawry_response.rb
fawry-1.1.1 lib/fawry/fawry_response.rb
fawry-1.0.0 lib/fawry/fawry_response.rb
fawry-0.3.0 lib/fawry/fawry_response.rb