Class: WalmartApIs::RefundType

Inherits:
Object
  • Object
show all
Defined in:
lib/walmart_ap_is/models/refund_type.rb

Overview

Why the refund is being issued. Compressed from gmp-orders-mono's 22-entry RefundReason enum to the three classes that actually drive downstream behaviour today (return-flow vs cancel-flow vs goodwill-credit). Free-form sub-reason goes in reason.

Constant Summary collapse

REFUND_TYPE =
[
  # TODO: Write general description for RETURN
  RETURN = 'RETURN'.freeze,

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = RETURN) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/walmart_ap_is/models/refund_type.rb', line 29

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

  str = value.to_s.strip

  case str.downcase
  when 'return' then RETURN
  when 'cancellation' then CANCELLATION
  when 'goodwill' then GOODWILL
  else
    default_value
  end
end

.validate(value) ⇒ Object



23
24
25
26
27
# File 'lib/walmart_ap_is/models/refund_type.rb', line 23

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

  REFUND_TYPE.include?(value)
end