Class: UspsApi::OriginalConstructCode

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

Overview

A 3-character code to identify the construct of the Original Label Tracking Number.

Constant Summary collapse

ORIGINAL_CONSTRUCT_CODE =
[
  # TODO: Write general description for G01
  G01 = 'G01'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = G01) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'g01' then G01
  when 'i01' then I01
  else
    default_value
  end
end

.validate(value) ⇒ Object



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

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

  ORIGINAL_CONSTRUCT_CODE.include?(value)
end