Class: UspsApi::ReturnCode
- Inherits:
-
Object
- Object
- UspsApi::ReturnCode
- Defined in:
- lib/usps_api/models/return_code.rb
Overview
The return code from the address match. * ‘32` - Default Match * `31` - Single Match * `22` - Multiple Response Match * `21` - Address Not Found * `13` - Invalid City * `12` - Invalid State Code * `11` - Invalid ZIP Code * `10` - Invalid Address
Constant Summary collapse
- RETURN_CODE =
[ # TODO: Write general description for ENUM_32 ENUM_32 = 32, # TODO: Write general description for ENUM_31 ENUM_31 = 31, # TODO: Write general description for ENUM_22 ENUM_22 = 22, # TODO: Write general description for ENUM_21 ENUM_21 = 21, # TODO: Write general description for ENUM_13 ENUM_13 = 13, # TODO: Write general description for ENUM_12 ENUM_12 = 12, # TODO: Write general description for ENUM_11 ENUM_11 = 11, # TODO: Write general description for ENUM_10 ENUM_10 = 10 ].freeze
Class Method Summary collapse
Class Method Details
.from_value(value, default_value = ENUM_32) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/usps_api/models/return_code.rb', line 44 def self.from_value(value, default_value = ENUM_32) return default_value if value.nil? str = value.to_s.strip if str.match?(/\A\d+\z/) num = str.to_i return num if RETURN_CODE.include?(num) return default_value end case str.downcase when 'enum_32' then ENUM_32 when 'enum_31' then ENUM_31 when 'enum_22' then ENUM_22 when 'enum_21' then ENUM_21 when 'enum_13' then ENUM_13 when 'enum_12' then ENUM_12 when 'enum_11' then ENUM_11 when 'enum_10' then ENUM_10 else default_value end end |
.validate(value) ⇒ Object
38 39 40 41 42 |
# File 'lib/usps_api/models/return_code.rb', line 38 def self.validate(value) return false if value.nil? RETURN_CODE.include?(value) end |