Class: UspsApi::Notes

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

Overview

When a mailClass will be returned with more than one estimate the notes will be returned with information on what differentiates the two estimates.

Constant Summary collapse

NOTES =
[
  # TODO: Write general description for WEIGHT_LESS_THAN_1_POUND
  WEIGHT_LESS_THAN_1_POUND = 'WEIGHT_LESS_THAN_1_POUND'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = WEIGHT_LESS_THAN_1_POUND) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'weight_less_than_1_pound' then WEIGHT_LESS_THAN_1_POUND
  when 'weight_greater_than_or_equal_to_1_pound' then WEIGHT_GREATER_THAN_OR_EQUAL_TO_1_POUND
  else
    default_value
  end
end

.validate(value) ⇒ Object



19
20
21
22
23
# File 'lib/usps_api/models/notes.rb', line 19

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

  NOTES.include?(value)
end