Sha256: facba75c21480cee604f7135f895f6f17aa5fb5c6b4cb83494adefa67574ea71

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

# frozen_string_literal: true

module Payture::Cheques
  module Responses
    class Status < Base
      ERROR_STATES = {
        'Unauthorized' => 'CANNOT_AUTHORIZE_TERMINAL',
        'NotFound' => 'NOT_FOUND',
        'Timeout' => 'TIMEOUT',
        'Unknown' => 'UNKNOWN',
      }.freeze

      def cheques
        @cheques ||= body['Cheques'].map { |c| ChequeStatus.new(c) }
      end

      def success?
        body['Success'] == true
      end

      def error_code
        body['ErrCode'] || ERROR_STATES[body['Status']]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
payture-cheques-0.1.0 lib/payture/cheques/responses/status.rb