Class: UspsApi::Dpvcmra

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

Overview

Indicates if the location is a [Commercial Mail Receiving Agency (CMRA)](faq.usps.com/s/article/Commercial-Mail-Receiving-Agency-CMRA ). * ‘Y` - Address was found in the CMRA table. * `N` - Address was not found in the CMRA table.

Constant Summary collapse

DPVCMRA =
[
  # TODO: Write general description for Y
  Y = 'Y'.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



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/usps_api/models/dpvcmra.rb', line 26

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 'n' then N
  else
    default_value
  end
end

.validate(value) ⇒ Object



20
21
22
23
24
# File 'lib/usps_api/models/dpvcmra.rb', line 20

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

  DPVCMRA.include?(value)
end