Class: LoyaltyApIs::BalanceCurrencyType

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

Overview

Balance Currency Type.

Constant Summary collapse

BALANCE_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,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = QV) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/loyalty_ap_is/models/balance_currency_type.rb', line 41

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
  when 'nbs' then NBS
  else
    default_value
  end
end

.validate(value) ⇒ Object



35
36
37
38
39
# File 'lib/loyalty_ap_is/models/balance_currency_type.rb', line 35

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

  BALANCE_CURRENCY_TYPE.include?(value)
end