Class: UspsApi::TrackingSubscriptionBasedOnASpecificTrackingNumber
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::TrackingSubscriptionBasedOnASpecificTrackingNumber
- Defined in:
- lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb
Overview
Filter by tracking number
Instance Attribute Summary collapse
-
#tracking_event_types ⇒ Array[TrackingEventType]
Specify what tracking events should be include in the subscription: </p> ALL - All Below Updates </p> PACKAGE_DELIVERED - Receive a message when package has been delivered to the recipient’s address or when it’s been delivered to a delivery partner (if applicable).
-
#tracking_number ⇒ String
Specify the Mailer ID that should be included in the subscription.
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(tracking_number:, tracking_event_types: SKIP, additional_properties: nil) ⇒ TrackingSubscriptionBasedOnASpecificTrackingNumber
constructor
A new instance of TrackingSubscriptionBasedOnASpecificTrackingNumber.
-
#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(tracking_number:, tracking_event_types: SKIP, additional_properties: nil) ⇒ TrackingSubscriptionBasedOnASpecificTrackingNumber
Returns a new instance of TrackingSubscriptionBasedOnASpecificTrackingNumber.
65 66 67 68 69 70 71 72 73 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 65 def initialize(tracking_number:, tracking_event_types: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @tracking_number = tracking_number @tracking_event_types = tracking_event_types unless tracking_event_types == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#tracking_event_types ⇒ Array[TrackingEventType]
Specify what tracking events should be include in the subscription: </p> ALL - All Below Updates </p> PACKAGE_DELIVERED - Receive a message when package has been delivered to the recipient’s
address or when it's been delivered to a
delivery partner (if applicable). </p> AVAILABLE_FOR_PICKUP - Receive a message when your package is ready to be picked up at your
local Post Office location. </p>
DELIVERY_EXCEPTION_UPDATES - Receive a message when there are other delivery updates, alerts
about potential delays (including
weather-related delays), or
actions needed (e.g., Schedule Redelivery)
related to your package. (Exceptions?)</p> PACKAGE_IN_TRANSIT_UPDATES - Receive a message when your package is in-transit with the current
expected delivery date, if available.
(InTransit?)</p> PACKAGE_DELAYED - Package has been delayed DEFAULT - Includes PACKAGE_DELIVERED, AVAILABLE_FOR_PICKUP, DELIVERY_EXCEPTION_UPDATES, and PACKAGE_IN_TRANSIT_UPDATES
43 44 45 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 43 def tracking_event_types @tracking_event_types end |
#tracking_number ⇒ String
Specify the Mailer ID that should be included in the subscription. Once a subscription is created this field cannot be changed through a future edit, instead the subscription should be deleted and a new subscription should be created.
17 18 19 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 17 def tracking_number @tracking_number 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 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 76 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tracking_number = hash.key?('trackingNumber') ? hash['trackingNumber'] : nil tracking_event_types = hash.key?('trackingEventTypes') ? hash['trackingEventTypes'] : 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. TrackingSubscriptionBasedOnASpecificTrackingNumber.new(tracking_number: tracking_number, tracking_event_types: tracking_event_types, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['tracking_number'] = 'trackingNumber' @_hash['tracking_event_types'] = 'trackingEventTypes' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 54 def self.optionals %w[ tracking_event_types ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 100 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.tracking_number, ->(val) { val.instance_of? String }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['trackingNumber'], ->(val) { val.instance_of? String }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
120 121 122 123 124 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 120 def inspect class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number.inspect}, tracking_event_types:"\ " #{@tracking_event_types.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
113 114 115 116 117 |
# File 'lib/usps_api/models/tracking_subscription_based_on_a_specific_tracking_number.rb', line 113 def to_s class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number}, tracking_event_types:"\ " #{@tracking_event_types}, additional_properties: #{@additional_properties}>" end |