Class: FdxV660Api::RewardType

Inherits:
Object
  • Object
show all
Defined in:
lib/fdx_v660_api/models/reward_type.rb

Overview

The type of the reward balance. Example: a reward program awarding "Stars" for purchases would use the POINTS reward type. * CASHBACK: Rewards balances enumerated using a monetary amount * MILES: Rewards balances enumerated using distance * POINTS: Default when a reward balance is not of type CASHBACK or MILES

Constant Summary collapse

REWARD_TYPE =
[
  # TODO: Write general description for CASHBACK
  CASHBACK = 'CASHBACK'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CASHBACK) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fdx_v660_api/models/reward_type.rb', line 30

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

  str = value.to_s.strip

  case str.downcase
  when 'cashback' then CASHBACK
  when 'miles' then MILES
  when 'points' then POINTS
  else
    default_value
  end
end

.validate(value) ⇒ Object



24
25
26
27
28
# File 'lib/fdx_v660_api/models/reward_type.rb', line 24

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

  true
end