Class: UspsApi::EstimateDelivery
- Defined in:
- lib/usps_api/models/estimate_delivery.rb
Overview
Section Heading that displays Delivery Date information. For all Mail Classes, occurs once for each HFPU Location. Additionally, for PME Street & PO Box, occurs once for each Customer Delivery Option.
Instance Attribute Summary collapse
-
#expected_delivery_date_time ⇒ DateTime
The estimated delivery date in locale time at the destination.
-
#guaranteed_delivery ⇒ TrueClass | FalseClass
If true, the scheduledDeliveryDateTime and expectedDeliveryDateTime are guaranteed.
-
#hold_for_pickup_location ⇒ Facility
This is USPS® facility information.
-
#scheduled_delivery_date_time ⇒ DateTime
The estimated delivery date in locale time at the destination.
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.
Instance Method Summary collapse
-
#initialize(scheduled_delivery_date_time: SKIP, expected_delivery_date_time: SKIP, guaranteed_delivery: SKIP, hold_for_pickup_location: SKIP) ⇒ EstimateDelivery
constructor
A new instance of EstimateDelivery.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_expected_delivery_date_time ⇒ Object
- #to_custom_scheduled_delivery_date_time ⇒ Object
-
#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(scheduled_delivery_date_time: SKIP, expected_delivery_date_time: SKIP, guaranteed_delivery: SKIP, hold_for_pickup_location: SKIP) ⇒ EstimateDelivery
Returns a new instance of EstimateDelivery.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 60 def initialize(scheduled_delivery_date_time: SKIP, expected_delivery_date_time: SKIP, guaranteed_delivery: SKIP, hold_for_pickup_location: SKIP) unless scheduled_delivery_date_time == SKIP @scheduled_delivery_date_time = scheduled_delivery_date_time end unless expected_delivery_date_time == SKIP @expected_delivery_date_time = expected_delivery_date_time end @guaranteed_delivery = guaranteed_delivery unless guaranteed_delivery == SKIP @hold_for_pickup_location = hold_for_pickup_location unless hold_for_pickup_location == SKIP end |
Instance Attribute Details
#expected_delivery_date_time ⇒ DateTime
The estimated delivery date in locale time at the destination.
24 25 26 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 24 def expected_delivery_date_time @expected_delivery_date_time end |
#guaranteed_delivery ⇒ TrueClass | FalseClass
If true, the scheduledDeliveryDateTime and expectedDeliveryDateTime are guaranteed.
29 30 31 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 29 def guaranteed_delivery @guaranteed_delivery end |
#hold_for_pickup_location ⇒ Facility
This is USPS® facility information.
33 34 35 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 33 def hold_for_pickup_location @hold_for_pickup_location end |
#scheduled_delivery_date_time ⇒ DateTime
The estimated delivery date in locale time at the destination. Note: This field has been deprecated in favor of ‘expectedDeliveryDateTime` and will be removed in a future release. Please transition to using `expectedDeliveryDateTime`.
20 21 22 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 20 def scheduled_delivery_date_time @scheduled_delivery_date_time end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. scheduled_delivery_date_time = if hash.key?('scheduledDeliveryDateTime') (DateTimeHelper.from_rfc3339(hash['scheduledDeliveryDateTime']) if hash['scheduledDeliveryDateTime']) else SKIP end expected_delivery_date_time = if hash.key?('expectedDeliveryDateTime') (DateTimeHelper.from_rfc3339(hash['expectedDeliveryDateTime']) if hash['expectedDeliveryDateTime']) else SKIP end guaranteed_delivery = hash.key?('guaranteedDelivery') ? hash['guaranteedDelivery'] : SKIP hold_for_pickup_location = Facility.from_hash(hash['holdForPickupLocation']) if hash['holdForPickupLocation'] # Create object from extracted values. EstimateDelivery.new(scheduled_delivery_date_time: scheduled_delivery_date_time, expected_delivery_date_time: expected_delivery_date_time, guaranteed_delivery: guaranteed_delivery, hold_for_pickup_location: hold_for_pickup_location) end |
.names ⇒ Object
A mapping from model property names to API property names.
36 37 38 39 40 41 42 43 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 36 def self.names @_hash = {} if @_hash.nil? @_hash['scheduled_delivery_date_time'] = 'scheduledDeliveryDateTime' @_hash['expected_delivery_date_time'] = 'expectedDeliveryDateTime' @_hash['guaranteed_delivery'] = 'guaranteedDelivery' @_hash['hold_for_pickup_location'] = 'holdForPickupLocation' @_hash end |
.nullables ⇒ Object
An array for nullable fields
56 57 58 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 56 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
46 47 48 49 50 51 52 53 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 46 def self.optionals %w[ scheduled_delivery_date_time expected_delivery_date_time guaranteed_delivery hold_for_pickup_location ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
119 120 121 122 123 124 125 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 119 def inspect class_name = self.class.name.split('::').last "<#{class_name} scheduled_delivery_date_time: #{@scheduled_delivery_date_time.inspect},"\ " expected_delivery_date_time: #{@expected_delivery_date_time.inspect}, guaranteed_delivery:"\ " #{@guaranteed_delivery.inspect}, hold_for_pickup_location:"\ " #{@hold_for_pickup_location.inspect}>" end |
#to_custom_expected_delivery_date_time ⇒ Object
106 107 108 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 106 def to_custom_expected_delivery_date_time DateTimeHelper.to_rfc3339(expected_delivery_date_time) end |
#to_custom_scheduled_delivery_date_time ⇒ Object
102 103 104 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 102 def to_custom_scheduled_delivery_date_time DateTimeHelper.to_rfc3339(scheduled_delivery_date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
111 112 113 114 115 116 |
# File 'lib/usps_api/models/estimate_delivery.rb', line 111 def to_s class_name = self.class.name.split('::').last "<#{class_name} scheduled_delivery_date_time: #{@scheduled_delivery_date_time},"\ " expected_delivery_date_time: #{@expected_delivery_date_time}, guaranteed_delivery:"\ " #{@guaranteed_delivery}, hold_for_pickup_location: #{@hold_for_pickup_location}>" end |