Class: UspsApi::MailClass11

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

Overview

The mail service requested. Note: - ‘FIRST-CLASS_PACKAGE_RETURN_SERVICE` is deprecated and will convert to `USPS_GROUND_ADVANTAGE_RETURN_SERVICE` - `GROUND_RETURN_SERVICE` is deprecated and will convert to `USPS_GROUND_ADVANTAGE_RETURN_SERVICE`

Constant Summary collapse

MAIL_CLASS11 =
[
  # TODO: Write general description for FIRSTCLASS_PACKAGE_RETURN_SERVICE
  FIRSTCLASS_PACKAGE_RETURN_SERVICE = 'FIRST-CLASS_PACKAGE_RETURN_SERVICE'.freeze,

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FIRSTCLASS_PACKAGE_RETURN_SERVICE) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/usps_api/models/mail_class11.rb', line 35

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

  str = value.to_s.strip

  case str.downcase
  when 'firstclass_package_return_service' then FIRSTCLASS_PACKAGE_RETURN_SERVICE
  when 'ground_return_service' then GROUND_RETURN_SERVICE
  when 'priority_mail_express_return_service' then PRIORITY_MAIL_EXPRESS_RETURN_SERVICE
  when 'priority_mail_return_service' then PRIORITY_MAIL_RETURN_SERVICE
  when 'usps_ground_advantage_return_service' then USPS_GROUND_ADVANTAGE_RETURN_SERVICE
  else
    default_value
  end
end

.validate(value) ⇒ Object



29
30
31
32
33
# File 'lib/usps_api/models/mail_class11.rb', line 29

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

  MAIL_CLASS11.include?(value)
end