Class: UspsApi::AvailableNotificationOptions

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

Overview

Noticication options that are available for the tracking number

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(future_delivery: SKIP, alert_delivery: SKIP, today_delivery: SKIP, up: SKIP, dnd: SKIP) ⇒ AvailableNotificationOptions

Returns a new instance of AvailableNotificationOptions.



63
64
65
66
67
68
69
70
# File 'lib/usps_api/models/available_notification_options.rb', line 63

def initialize(future_delivery: SKIP, alert_delivery: SKIP,
               today_delivery: SKIP, up: SKIP, dnd: SKIP)
  @future_delivery = future_delivery unless future_delivery == SKIP
  @alert_delivery = alert_delivery unless alert_delivery == SKIP
  @today_delivery = today_delivery unless today_delivery == SKIP
  @up = up unless up == SKIP
  @dnd = dnd unless dnd == SKIP
end

Instance Attribute Details

#alert_deliveryTrueClass | FalseClass

Mail piece eligibility for Alert - Delivery Expection requests. All past and future activity on the package.

Returns:

  • (TrueClass | FalseClass)


20
21
22
# File 'lib/usps_api/models/available_notification_options.rb', line 20

def alert_delivery
  @alert_delivery
end

#dndTrueClass | FalseClass

Mail piece eligibility for DND Delivery Activity requests. Notification of each delivery or delivery attempt.

Returns:

  • (TrueClass | FalseClass)


34
35
36
# File 'lib/usps_api/models/available_notification_options.rb', line 34

def dnd
  @dnd
end

#future_deliveryTrueClass | FalseClass

Mail piece eligibility for Future Delivery Expected Delivery Date / Time Updates requests. Future activity only on the package.

Returns:

  • (TrueClass | FalseClass)


15
16
17
# File 'lib/usps_api/models/available_notification_options.rb', line 15

def future_delivery
  @future_delivery
end

#today_deliveryTrueClass | FalseClass

Mail piece eligibility for Today Delivery Day of Delivery Update requests.

Returns:

  • (TrueClass | FalseClass)


25
26
27
# File 'lib/usps_api/models/available_notification_options.rb', line 25

def today_delivery
  @today_delivery
end

#upTrueClass | FalseClass

Mail piece eligibility for UP / Mail Pickup Available for Pickup requests.

Returns:

  • (TrueClass | FalseClass)


29
30
31
# File 'lib/usps_api/models/available_notification_options.rb', line 29

def up
  @up
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/usps_api/models/available_notification_options.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  future_delivery =
    hash.key?('futureDelivery') ? hash['futureDelivery'] : SKIP
  alert_delivery = hash.key?('alertDelivery') ? hash['alertDelivery'] : SKIP
  today_delivery = hash.key?('todayDelivery') ? hash['todayDelivery'] : SKIP
  up = hash.key?('UP') ? hash['UP'] : SKIP
  dnd = hash.key?('DND') ? hash['DND'] : SKIP

  # Create object from extracted values.
  AvailableNotificationOptions.new(future_delivery: future_delivery,
                                   alert_delivery: alert_delivery,
                                   today_delivery: today_delivery,
                                   up: up,
                                   dnd: dnd)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
# File 'lib/usps_api/models/available_notification_options.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['future_delivery'] = 'futureDelivery'
  @_hash['alert_delivery'] = 'alertDelivery'
  @_hash['today_delivery'] = 'todayDelivery'
  @_hash['up'] = 'UP'
  @_hash['dnd'] = 'DND'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/usps_api/models/available_notification_options.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



48
49
50
51
52
53
54
55
56
# File 'lib/usps_api/models/available_notification_options.rb', line 48

def self.optionals
  %w[
    future_delivery
    alert_delivery
    today_delivery
    up
    dnd
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



94
95
96
97
98
99
100
# File 'lib/usps_api/models/available_notification_options.rb', line 94

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/usps_api/models/available_notification_options.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} future_delivery: #{@future_delivery.inspect}, alert_delivery:"\
  " #{@alert_delivery.inspect}, today_delivery: #{@today_delivery.inspect}, up:"\
  " #{@up.inspect}, dnd: #{@dnd.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



103
104
105
106
107
# File 'lib/usps_api/models/available_notification_options.rb', line 103

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} future_delivery: #{@future_delivery}, alert_delivery: #{@alert_delivery},"\
  " today_delivery: #{@today_delivery}, up: #{@up}, dnd: #{@dnd}>"
end