Class: UspsApi::ResponseFormat

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

Overview

Used to specify whether to return 3x3 or 5x5 digit ZIP codes in the response.

Constant Summary collapse

RESPONSE_FORMAT =
[
  # TODO: Write general description for ENUM_3D_BASE
  ENUM_3D_BASE = '3D_BASE'.freeze,

  # TODO: Write general description for ENUM_5D_EXPANDED
  ENUM_5D_EXPANDED = '5D_EXPANDED'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ENUM_3D_BASE) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/usps_api/models/response_format.rb', line 24

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

  str = value.to_s.strip

  case str.downcase
  when 'enum_3d_base' then ENUM_3D_BASE
  when 'enum_5d_expanded' then ENUM_5D_EXPANDED
  else
    default_value
  end
end

.validate(value) ⇒ Object



18
19
20
21
22
# File 'lib/usps_api/models/response_format.rb', line 18

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

  RESPONSE_FORMAT.include?(value)
end