Class: UspsApi::ShipmentsCommitment
- Defined in:
- lib/usps_api/models/shipments_commitment.rb
Overview
The commitment and the scheduled delivery date of the package.
Instance Attribute Summary collapse
-
#expected_delivery_date ⇒ String
Date in the YYYY-MM-DD format.
-
#guaranteed_delivery ⇒ TrueClass | FalseClass
If true, the expectedDeliveryDate is guaranteed.
-
#is_priority_mail_next_day ⇒ TrueClass | FalseClass
Indicates if the commitment is for Priority Mail Next Day service.
-
#name ⇒ String
Commitment name such as 1 Day, 2 Days, 3 Days, MILITARY, DPO, NO STD, or UNAVAILABLE.
-
#schedule_delivery_date ⇒ Date
Date USPS expects that the package or mailpiece will be delivered based on the origin, destination, and drop-off time and date in the request.
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(name: SKIP, schedule_delivery_date: SKIP, expected_delivery_date: SKIP, guaranteed_delivery: SKIP, is_priority_mail_next_day: SKIP, additional_properties: nil) ⇒ ShipmentsCommitment
constructor
A new instance of ShipmentsCommitment.
-
#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(name: SKIP, schedule_delivery_date: SKIP, expected_delivery_date: SKIP, guaranteed_delivery: SKIP, is_priority_mail_next_day: SKIP, additional_properties: nil) ⇒ ShipmentsCommitment
Returns a new instance of ShipmentsCommitment.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 66 def initialize(name: SKIP, schedule_delivery_date: SKIP, expected_delivery_date: SKIP, guaranteed_delivery: SKIP, is_priority_mail_next_day: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @name = name unless name == SKIP @schedule_delivery_date = schedule_delivery_date unless schedule_delivery_date == SKIP @expected_delivery_date = expected_delivery_date unless expected_delivery_date == SKIP @guaranteed_delivery = guaranteed_delivery unless guaranteed_delivery == SKIP unless is_priority_mail_next_day == SKIP @is_priority_mail_next_day = is_priority_mail_next_day end @additional_properties = additional_properties end |
Instance Attribute Details
#expected_delivery_date ⇒ String
Date in the YYYY-MM-DD format.
29 30 31 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 29 def expected_delivery_date @expected_delivery_date end |
#guaranteed_delivery ⇒ TrueClass | FalseClass
If true, the expectedDeliveryDate is guaranteed.
33 34 35 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 33 def guaranteed_delivery @guaranteed_delivery end |
#is_priority_mail_next_day ⇒ TrueClass | FalseClass
Indicates if the commitment is for Priority Mail Next Day service.
37 38 39 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 37 def is_priority_mail_next_day @is_priority_mail_next_day end |
#name ⇒ String
Commitment name such as 1 Day, 2 Days, 3 Days, MILITARY, DPO, NO STD, or UNAVAILABLE.
15 16 17 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 15 def name @name end |
#schedule_delivery_date ⇒ Date
Date USPS expects that the package or mailpiece will be delivered based on the origin, destination, and drop-off time and date in the request. Actual delivery date may vary based on when the package or mailpiece is entered or other conditions. Note: This field has been deprecated in favor of ‘expectedDeliveryDate` and will be removed in a future release. Please transition to using `expectedDeliveryDate`.
25 26 27 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 25 def schedule_delivery_date @schedule_delivery_date end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP schedule_delivery_date = hash.key?('scheduleDeliveryDate') ? hash['scheduleDeliveryDate'] : SKIP expected_delivery_date = hash.key?('expectedDeliveryDate') ? hash['expectedDeliveryDate'] : SKIP guaranteed_delivery = hash.key?('guaranteedDelivery') ? hash['guaranteedDelivery'] : SKIP is_priority_mail_next_day = hash.key?('isPriorityMailNextDay') ? hash['isPriorityMailNextDay'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. ShipmentsCommitment.new(name: name, schedule_delivery_date: schedule_delivery_date, expected_delivery_date: expected_delivery_date, guaranteed_delivery: guaranteed_delivery, is_priority_mail_next_day: is_priority_mail_next_day, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 40 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['schedule_delivery_date'] = 'scheduleDeliveryDate' @_hash['expected_delivery_date'] = 'expectedDeliveryDate' @_hash['guaranteed_delivery'] = 'guaranteedDelivery' @_hash['is_priority_mail_next_day'] = 'isPriorityMailNextDay' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 62 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 59 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 51 def self.optionals %w[ name schedule_delivery_date expected_delivery_date guaranteed_delivery is_priority_mail_next_day ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
116 117 118 119 120 121 122 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 116 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.
134 135 136 137 138 139 140 141 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 134 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, schedule_delivery_date:"\ " #{@schedule_delivery_date.inspect}, expected_delivery_date:"\ " #{@expected_delivery_date.inspect}, guaranteed_delivery: #{@guaranteed_delivery.inspect},"\ " is_priority_mail_next_day: #{@is_priority_mail_next_day.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
125 126 127 128 129 130 131 |
# File 'lib/usps_api/models/shipments_commitment.rb', line 125 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, schedule_delivery_date: #{@schedule_delivery_date},"\ " expected_delivery_date: #{@expected_delivery_date}, guaranteed_delivery:"\ " #{@guaranteed_delivery}, is_priority_mail_next_day: #{@is_priority_mail_next_day},"\ " additional_properties: #{@additional_properties}>" end |