Class: LoyaltyApIs::TransactionCurrencyType

Inherits:
Object
  • Object
show all
Defined in:
lib/loyalty_ap_is/models/transaction_currency_type.rb

Overview

Type of balance

Constant Summary collapse

TRANSACTION_CURRENCY_TYPE =
[
  # TODO: Write general description for QV
  QV = 'QV'.freeze,

  # TODO: Write general description for POINT
  POINT = 'POINT'.freeze,

  # TODO: Write general description for STAMP
  STAMP = 'STAMP'.freeze,

  # TODO: Write general description for AIRMILES
  AIRMILES = 'AIRMILES'.freeze,

  # TODO: Write general description for MILES
  MILES = 'MILES'.freeze,

  # TODO: Write general description for CASH
  CASH = 'CASH'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = QV) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/loyalty_ap_is/models/transaction_currency_type.rb', line 38

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

  str = value.to_s.strip

  case str.downcase
  when 'qv' then QV
  when 'point' then POINT
  when 'stamp' then STAMP
  when 'airmiles' then AIRMILES
  when 'miles' then MILES
  when 'cash' then CASH
  when 'stamp_counter' then STAMP_COUNTER
  else
    default_value
  end
end

.validate(value) ⇒ Object



32
33
34
35
36
# File 'lib/loyalty_ap_is/models/transaction_currency_type.rb', line 32

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

  TRANSACTION_CURRENCY_TYPE.include?(value)
end