Class: UspsApi::CancelReasonCode1

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

Overview

The reason the appointment was cancelled. Only set when the appointment is cancelled A = Appointment made in error, D = Delivery appointment Cancelled per request of consignee, E = Product combined into another existing appointment, M = Major change in expected delivery window, P = Product not available

Constant Summary collapse

CANCEL_REASON_CODE1 =
[
  # TODO: Write general description for A
  A = 'A'.freeze,

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = A) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/usps_api/models/cancel_reason_code1.rb', line 36

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

  str = value.to_s.strip

  case str.downcase
  when 'a' then A
  when 'd' then D
  when 'e' then E
  when 'm' then M
  when 'p' then P
  else
    default_value
  end
end

.validate(value) ⇒ Object



30
31
32
33
34
# File 'lib/usps_api/models/cancel_reason_code1.rb', line 30

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

  CANCEL_REASON_CODE1.include?(value)
end