Class: UspsApi::PostOfficeType1

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

Overview

postOfficeType1.

Constant Summary collapse

POST_OFFICE_TYPE1 =
[
  # TODO: Write general description for CONTRACT_POSTAL_UNIT
  CONTRACT_POSTAL_UNIT = 'CONTRACT_POSTAL_UNIT'.freeze,

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CONTRACT_POSTAL_UNIT) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'contract_postal_unit' then CONTRACT_POSTAL_UNIT
  when 'post_office' then POST_OFFICE
  when 'self_service_kiosk' then SELF_SERVICE_KIOSK
  when 'village_post_office' then VILLAGE_POST_OFFICE
  else
    default_value
  end
end

.validate(value) ⇒ Object



23
24
25
26
27
# File 'lib/usps_api/models/post_office_type1.rb', line 23

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

  POST_OFFICE_TYPE1.include?(value)
end