Class: UspsApi::ShipmentTrackingEvent
- Defined in:
- lib/usps_api/models/shipment_tracking_event.rb
Overview
Details about a shipment tracking event, including location, status, and facility information.
Instance Attribute Summary collapse
-
#appointment_date ⇒ DateTime
Date and time of the appointment (ISO 8601).
-
#appointment_id ⇒ String
Appointment ID assigned from FAST.
-
#current_event ⇒ TrackingCurrentEvent
The current event type for the shipment.
-
#current_location ⇒ TrackingCurrentLocation
Current location details for the tracking event.
-
#eta ⇒ DateTime
Estimated time of arrival (ISO 8601).
-
#eta_status ⇒ EtaStatus
The ETA status of the current destination and not the appointment.
-
#external_load_number ⇒ String
Unique identifier for the shipment load.
-
#location ⇒ TrackingLocation
Location details for the tracking event.
-
#positional_info ⇒ TrackingPositionalInfo
Positional information for the shipment.
-
#resource_info ⇒ TrackingResourceInfo
Information about the resource sending the information.
-
#scheduler_crid ⇒ String
Scheduler’s unique identifier.
-
#trailer_id ⇒ String
Unique identifier for the trailer.
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(external_load_number:, appointment_id:, appointment_date:, trailer_id:, scheduler_crid:, location:, current_location:, current_event:, positional_info:, eta: SKIP, eta_status: SKIP, resource_info: SKIP) ⇒ ShipmentTrackingEvent
constructor
A new instance of ShipmentTrackingEvent.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_appointment_date ⇒ Object
- #to_custom_eta ⇒ 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(external_load_number:, appointment_id:, appointment_date:, trailer_id:, scheduler_crid:, location:, current_location:, current_event:, positional_info:, eta: SKIP, eta_status: SKIP, resource_info: SKIP) ⇒ ShipmentTrackingEvent
Returns a new instance of ShipmentTrackingEvent.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 100 def initialize(external_load_number:, appointment_id:, appointment_date:, trailer_id:, scheduler_crid:, location:, current_location:, current_event:, positional_info:, eta: SKIP, eta_status: SKIP, resource_info: SKIP) @external_load_number = external_load_number @appointment_id = appointment_id @appointment_date = appointment_date @trailer_id = trailer_id @scheduler_crid = scheduler_crid @eta = eta unless eta == SKIP @eta_status = eta_status unless eta_status == SKIP @location = location @current_location = current_location @current_event = current_event @positional_info = positional_info @resource_info = resource_info unless resource_info == SKIP end |
Instance Attribute Details
#appointment_date ⇒ DateTime
Date and time of the appointment (ISO 8601).
24 25 26 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 24 def appointment_date @appointment_date end |
#appointment_id ⇒ String
Appointment ID assigned from FAST.
20 21 22 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 20 def appointment_id @appointment_id end |
#current_event ⇒ TrackingCurrentEvent
The current event type for the shipment.
55 56 57 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 55 def current_event @current_event end |
#current_location ⇒ TrackingCurrentLocation
Current location details for the tracking event.
51 52 53 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 51 def current_location @current_location end |
#eta ⇒ DateTime
Estimated time of arrival (ISO 8601). Required unless currentEvent.eventType is FACILITY_ARRIVE or FACILITY_DEPART.
37 38 39 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 37 def eta @eta end |
#eta_status ⇒ EtaStatus
The ETA status of the current destination and not the appointment. Required unless currentEvent.eventType is FACILITY_ARRIVE or FACILITY_DEPART.
43 44 45 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 43 def eta_status @eta_status end |
#external_load_number ⇒ String
Unique identifier for the shipment load.
16 17 18 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 16 def external_load_number @external_load_number end |
#location ⇒ TrackingLocation
Location details for the tracking event.
47 48 49 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 47 def location @location end |
#positional_info ⇒ TrackingPositionalInfo
Positional information for the shipment.
59 60 61 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 59 def positional_info @positional_info end |
#resource_info ⇒ TrackingResourceInfo
Information about the resource sending the information.
63 64 65 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 63 def resource_info @resource_info end |
#scheduler_crid ⇒ String
Scheduler’s unique identifier.
32 33 34 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 32 def scheduler_crid @scheduler_crid end |
#trailer_id ⇒ String
Unique identifier for the trailer.
28 29 30 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 28 def trailer_id @trailer_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 119 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. external_load_number = hash.key?('externalLoadNumber') ? hash['externalLoadNumber'] : nil appointment_id = hash.key?('appointmentID') ? hash['appointmentID'] : nil appointment_date = if hash.key?('appointmentDate') (DateTimeHelper.from_rfc3339(hash['appointmentDate']) if hash['appointmentDate']) end trailer_id = hash.key?('trailerID') ? hash['trailerID'] : nil scheduler_crid = hash.key?('schedulerCRID') ? hash['schedulerCRID'] : nil location = TrackingLocation.from_hash(hash['location']) if hash['location'] current_location = TrackingCurrentLocation.from_hash(hash['currentLocation']) if hash['currentLocation'] current_event = TrackingCurrentEvent.from_hash(hash['currentEvent']) if hash['currentEvent'] positional_info = TrackingPositionalInfo.from_hash(hash['positionalInfo']) if hash['positionalInfo'] eta = if hash.key?('ETA') (DateTimeHelper.from_rfc3339(hash['ETA']) if hash['ETA']) else SKIP end eta_status = hash.key?('ETAStatus') ? hash['ETAStatus'] : SKIP resource_info = TrackingResourceInfo.from_hash(hash['resourceInfo']) if hash['resourceInfo'] # Create object from extracted values. ShipmentTrackingEvent.new(external_load_number: external_load_number, appointment_id: appointment_id, appointment_date: appointment_date, trailer_id: trailer_id, scheduler_crid: scheduler_crid, location: location, current_location: current_location, current_event: current_event, positional_info: positional_info, eta: eta, eta_status: eta_status, resource_info: resource_info) end |
.names ⇒ Object
A mapping from model property names to API property names.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 66 def self.names @_hash = {} if @_hash.nil? @_hash['external_load_number'] = 'externalLoadNumber' @_hash['appointment_id'] = 'appointmentID' @_hash['appointment_date'] = 'appointmentDate' @_hash['trailer_id'] = 'trailerID' @_hash['scheduler_crid'] = 'schedulerCRID' @_hash['eta'] = 'ETA' @_hash['eta_status'] = 'ETAStatus' @_hash['location'] = 'location' @_hash['current_location'] = 'currentLocation' @_hash['current_event'] = 'currentEvent' @_hash['positional_info'] = 'positionalInfo' @_hash['resource_info'] = 'resourceInfo' @_hash end |
.nullables ⇒ Object
An array for nullable fields
93 94 95 96 97 98 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 93 def self.nullables %w[ eta eta_status ] end |
.optionals ⇒ Object
An array for optional fields
84 85 86 87 88 89 90 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 84 def self.optionals %w[ eta eta_status resource_info ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
179 180 181 182 183 184 185 186 187 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 179 def inspect class_name = self.class.name.split('::').last "<#{class_name} external_load_number: #{@external_load_number.inspect}, appointment_id:"\ " #{@appointment_id.inspect}, appointment_date: #{@appointment_date.inspect}, trailer_id:"\ " #{@trailer_id.inspect}, scheduler_crid: #{@scheduler_crid.inspect}, eta: #{@eta.inspect},"\ " eta_status: #{@eta_status.inspect}, location: #{@location.inspect}, current_location:"\ " #{@current_location.inspect}, current_event: #{@current_event.inspect}, positional_info:"\ " #{@positional_info.inspect}, resource_info: #{@resource_info.inspect}>" end |
#to_custom_appointment_date ⇒ Object
160 161 162 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 160 def to_custom_appointment_date DateTimeHelper.to_rfc3339(appointment_date) end |
#to_custom_eta ⇒ Object
164 165 166 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 164 def to_custom_eta DateTimeHelper.to_rfc3339(eta) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
169 170 171 172 173 174 175 176 |
# File 'lib/usps_api/models/shipment_tracking_event.rb', line 169 def to_s class_name = self.class.name.split('::').last "<#{class_name} external_load_number: #{@external_load_number}, appointment_id:"\ " #{@appointment_id}, appointment_date: #{@appointment_date}, trailer_id: #{@trailer_id},"\ " scheduler_crid: #{@scheduler_crid}, eta: #{@eta}, eta_status: #{@eta_status}, location:"\ " #{@location}, current_location: #{@current_location}, current_event: #{@current_event},"\ " positional_info: #{@positional_info}, resource_info: #{@resource_info}>" end |