Sha256: 101b6d311234b893d1220e83e8f3d89204be2411e186f7f33f281558f4fe8d14

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 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 && cheques.all?(&:success?)
      end

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

      def status
        body['Status']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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