Class: UspsApi::EMail
- Defined in:
- lib/usps_api/models/e_mail.rb
Overview
E-mail notification.
Instance Attribute Summary collapse
-
#alert_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Alert - Delivery Expection requests.
-
#dnd ⇒ TrueClass | FalseClass
Mail piece eligibility for DND Delivery Activity requests.
-
#first_displayable ⇒ TrueClass | FalseClass
Mail piece eligibility for FS First displayable event for Informed Delivery / MyUSPS only requests.
-
#future_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Future Delivery Expected Delivery Date / Time Updates requests.
-
#other_activity ⇒ TrueClass | FalseClass
Mail piece eligibility for OA In-Transit / Other Activity requests.
-
#today_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Today Delivery Day of Delivery Update requests.
-
#up ⇒ TrueClass | FalseClass
Mail piece eligibility for UP / Mail Pickup Available for Pickup requests.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(future_delivery: SKIP, alert_delivery: SKIP, today_delivery: SKIP, up: SKIP, dnd: SKIP, first_displayable: SKIP, other_activity: SKIP) ⇒ EMail
constructor
A new instance of EMail.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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, first_displayable: SKIP, other_activity: SKIP) ⇒ EMail
Returns a new instance of EMail.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/usps_api/models/e_mail.rb', line 76 def initialize(future_delivery: SKIP, alert_delivery: SKIP, today_delivery: SKIP, up: SKIP, dnd: SKIP, first_displayable: SKIP, other_activity: 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 @first_displayable = first_displayable unless first_displayable == SKIP @other_activity = other_activity unless other_activity == SKIP end |
Instance Attribute Details
#alert_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Alert - Delivery Expection requests. All past and future activity on the package.
20 21 22 |
# File 'lib/usps_api/models/e_mail.rb', line 20 def alert_delivery @alert_delivery end |
#dnd ⇒ TrueClass | FalseClass
Mail piece eligibility for DND Delivery Activity requests. Notification of each delivery or delivery attempt.
34 35 36 |
# File 'lib/usps_api/models/e_mail.rb', line 34 def dnd @dnd end |
#first_displayable ⇒ TrueClass | FalseClass
Mail piece eligibility for FS First displayable event for Informed Delivery / MyUSPS only requests.
39 40 41 |
# File 'lib/usps_api/models/e_mail.rb', line 39 def first_displayable @first_displayable end |
#future_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Future Delivery Expected Delivery Date / Time Updates requests. Future activity only on the package.
15 16 17 |
# File 'lib/usps_api/models/e_mail.rb', line 15 def future_delivery @future_delivery end |
#other_activity ⇒ TrueClass | FalseClass
Mail piece eligibility for OA In-Transit / Other Activity requests.
43 44 45 |
# File 'lib/usps_api/models/e_mail.rb', line 43 def other_activity @other_activity end |
#today_delivery ⇒ TrueClass | FalseClass
Mail piece eligibility for Today Delivery Day of Delivery Update requests.
25 26 27 |
# File 'lib/usps_api/models/e_mail.rb', line 25 def today_delivery @today_delivery end |
#up ⇒ TrueClass | FalseClass
Mail piece eligibility for UP / Mail Pickup Available for Pickup requests.
29 30 31 |
# File 'lib/usps_api/models/e_mail.rb', line 29 def up @up end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/usps_api/models/e_mail.rb', line 89 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 first_displayable = hash.key?('firstDisplayable') ? hash['firstDisplayable'] : SKIP other_activity = hash.key?('otherActivity') ? hash['otherActivity'] : SKIP # Create object from extracted values. EMail.new(future_delivery: future_delivery, alert_delivery: alert_delivery, today_delivery: today_delivery, up: up, dnd: dnd, first_displayable: first_displayable, other_activity: other_activity) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/usps_api/models/e_mail.rb', line 46 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['first_displayable'] = 'firstDisplayable' @_hash['other_activity'] = 'otherActivity' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/usps_api/models/e_mail.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/usps_api/models/e_mail.rb', line 59 def self.optionals %w[ future_delivery alert_delivery today_delivery up dnd first_displayable other_activity ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
115 116 117 118 119 120 121 |
# File 'lib/usps_api/models/e_mail.rb', line 115 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
132 133 134 135 136 137 138 |
# File 'lib/usps_api/models/e_mail.rb', line 132 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}, first_displayable: #{@first_displayable.inspect},"\ " other_activity: #{@other_activity.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
124 125 126 127 128 129 |
# File 'lib/usps_api/models/e_mail.rb', line 124 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}, first_displayable:"\ " #{@first_displayable}, other_activity: #{@other_activity}>" end |