Class: UspsApi::MailingEventType

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

Overview

Identifies the type of mailing events that can be notified about.

Constant Summary collapse

MAILING_EVENT_TYPE =
[
  # TODO: Write general description for EMAIL_ALERT
  EMAIL_ALERT = 'EMAIL_ALERT'.freeze,

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

  # TODO: Write general description for
  # ENUM_EMAIL_DELIVERYNON_DELIVERY_ACTIVITY
  ENUM_EMAIL_DELIVERYNON_DELIVERY_ACTIVITY = 'EMAIL_DELIVERY/NON_DELIVERY_ACTIVITY'.freeze,

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

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

  # TODO: Write general description for
  # ENUM_PACKAGE_ADDRESSED_TO_MEMYUSPS_ONLY
  ENUM_PACKAGE_ADDRESSED_TO_MEMYUSPS_ONLY = 'PACKAGE_ADDRESSED_TO_ME/MYUSPS_ONLY'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = EMAIL_ALERT) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/usps_api/models/mailing_event_type.rb', line 40

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

  str = value.to_s.strip

  case str.downcase
  when 'email_alert' then EMAIL_ALERT
  when 'email_future_delivery' then EMAIL_FUTURE_DELIVERY
  when 'enum_email_deliverynon_delivery_activity' then ENUM_EMAIL_DELIVERYNON_DELIVERY_ACTIVITY
  when 'email_today_delivery' then EMAIL_TODAY_DELIVERY
  when 'email_available_for_pickup' then EMAIL_AVAILABLE_FOR_PICKUP
  when 'enum_package_addressed_to_memyusps_only' then ENUM_PACKAGE_ADDRESSED_TO_MEMYUSPS_ONLY
  when 'other_activity' then OTHER_ACTIVITY
  else
    default_value
  end
end

.validate(value) ⇒ Object



34
35
36
37
38
# File 'lib/usps_api/models/mailing_event_type.rb', line 34

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

  MAILING_EVENT_TYPE.include?(value)
end