Class: UspsApi::AppointmentType

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

Overview

The type of appointment. PALLET = 1, BEDLOAD = 2, DROP_AND_PICK = 3, SPEEDLINE = 4. Required for Dropship appointments.

Constant Summary collapse

APPOINTMENT_TYPE =
[
  # TODO: Write general description for PALLET
  PALLET = 'PALLET'.freeze,

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = PALLET) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/usps_api/models/appointment_type.rb', line 30

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

  str = value.to_s.strip

  case str.downcase
  when 'pallet' then PALLET
  when 'bedload' then BEDLOAD
  when 'drop_and_pick' then DROP_AND_PICK
  when 'speedline' then SPEEDLINE
  else
    default_value
  end
end

.validate(value) ⇒ Object



24
25
26
27
28
# File 'lib/usps_api/models/appointment_type.rb', line 24

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

  APPOINTMENT_TYPE.include?(value)
end