Class: Batches::TypeBatchesTransactionsType

Inherits:
Object
  • Object
show all
Defined in:
lib/batches/models/type_batches_transactions_type.rb

Overview

Describes whether the transaction is a SALE, that moves funds from Payer to Merchant, or a REFUND where funds move from Merchant to Payer. * SALE - indicates the movement, or the attempt to move, funds from payer to a merchant. * REFUND - indicates the movement, or the attempt to move, funds from merchant to the payer.

Constant Summary collapse

TYPE_BATCHES_TRANSACTIONS_TYPE =
[
  # TODO: Write general description for SALE
  SALE = 'SALE'.freeze,

  # TODO: Write general description for REFUND
  REFUND = 'REFUND'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SALE) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/batches/models/type_batches_transactions_type.rb', line 27

def self.from_value(value, default_value = SALE)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'sale' then SALE
  when 'refund' then REFUND
  else
    default_value
  end
end

.validate(value) ⇒ Object



21
22
23
24
25
# File 'lib/batches/models/type_batches_transactions_type.rb', line 21

def self.validate(value)
  return false if value.nil?

  TYPE_BATCHES_TRANSACTIONS_TYPE.include?(value)
end