Class: UspsApi::Reason

Inherits:
Object
  • Object
show all
Defined in:
lib/usps_api/models/reason.rb

Overview

Reason for the dispute.

Constant Summary collapse

REASON =
[
  # TODO: Write general description for INCORRECT_ASSESSED_WEIGHT
  INCORRECT_ASSESSED_WEIGHT = 'INCORRECT_ASSESSED_WEIGHT'.freeze,

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

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

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

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

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = INCORRECT_ASSESSED_WEIGHT) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/usps_api/models/reason.rb', line 47

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

  str = value.to_s.strip

  case str.downcase
  when 'incorrect_assessed_weight' then INCORRECT_ASSESSED_WEIGHT
  when 'incorrect_assessed_zone' then INCORRECT_ASSESSED_ZONE
  when 'incorrect_assessed_packaging' then INCORRECT_ASSESSED_PACKAGING
  when 'incorrect_assessed_dimensions' then INCORRECT_ASSESSED_DIMENSIONS
  when 'incorrect_assessed_duplicate' then INCORRECT_ASSESSED_DUPLICATE
  when 'undocumented' then UNDOCUMENTED
  when 'noncompliant_dimensions' then NONCOMPLIANT_DIMENSIONS
  when 'return_label' then RETURN_LABEL
  when 'misshipped' then MISSHIPPED
  when 'other' then OTHER
  else
    default_value
  end
end

.validate(value) ⇒ Object



41
42
43
44
45
# File 'lib/usps_api/models/reason.rb', line 41

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

  REASON.include?(value)
end