Class: UspsApi::DpvConfirmation

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

Overview

The DPV Confirmation indicator identifies whether the address provided maps to a known USPS address record, whether the USPS delivers to the address or not. If the USPS does not deliver to the address, the USPS may deliver to a PO Box instead. ‘carrierRoute` values of `R777` and `R779`, for example, may require the shipper to ask the recipient where they receive their USPS mail, which may be different than their physical address. * `Y` - Address was DPV confirmed for both primary and (if present) secondary numbers. A value of `Y` does not necessarily imply that USPS delivers to that address. * `D` - Address was DPV confirmed for the primary number only, and the secondary number information was missing. * `S` - Address was DPV confirmed for the primary number only, and the secondary number information was present but not confirmed. * `N` - Both primary and (if present) secondary number information failed to DPV confirm.

Constant Summary collapse

DPV_CONFIRMATION =
[
  # TODO: Write general description for Y
  Y = 'Y'.freeze,

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = Y) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/usps_api/models/dpv_confirmation.rb', line 41

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

  str = value.to_s.strip

  case str.downcase
  when 'y' then Y
  when 'd' then D
  when 's' then S
  when 'n' then N
  else
    default_value
  end
end

.validate(value) ⇒ Object



35
36
37
38
39
# File 'lib/usps_api/models/dpv_confirmation.rb', line 35

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

  DPV_CONFIRMATION.include?(value)
end