Class: UspsApi::TrackingLocation
- Defined in:
- lib/usps_api/models/tracking_location.rb
Overview
Location details for the tracking event.
Instance Attribute Summary collapse
-
#drop_site_key ⇒ String
Key for the drop site.
-
#location_type ⇒ LocationType
Type of location (e.g., USPS, CUSTOMER, NON_USPS).
-
#stop_sequence ⇒ Integer
The actual stop number in the route.
-
#stop_type ⇒ PickupOrDelivery
Type of stop (Pickup or Delivery).
-
#zip_code5 ⇒ String
Five-digit ZIP Code.
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(location_type:, stop_type:, stop_sequence:, drop_site_key: SKIP, zip_code5: SKIP) ⇒ TrackingLocation
constructor
A new instance of TrackingLocation.
-
#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(location_type:, stop_type:, stop_sequence:, drop_site_key: SKIP, zip_code5: SKIP) ⇒ TrackingLocation
Returns a new instance of TrackingLocation.
56 57 58 59 60 61 62 63 |
# File 'lib/usps_api/models/tracking_location.rb', line 56 def initialize(location_type:, stop_type:, stop_sequence:, drop_site_key: SKIP, zip_code5: SKIP) @location_type = location_type @drop_site_key = drop_site_key unless drop_site_key == SKIP @zip_code5 = zip_code5 unless zip_code5 == SKIP @stop_type = stop_type @stop_sequence = stop_sequence end |
Instance Attribute Details
#drop_site_key ⇒ String
Key for the drop site. Required when locationType is USPS.
18 19 20 |
# File 'lib/usps_api/models/tracking_location.rb', line 18 def drop_site_key @drop_site_key end |
#location_type ⇒ LocationType
Type of location (e.g., USPS, CUSTOMER, NON_USPS).
14 15 16 |
# File 'lib/usps_api/models/tracking_location.rb', line 14 def location_type @location_type end |
#stop_sequence ⇒ Integer
The actual stop number in the route.
30 31 32 |
# File 'lib/usps_api/models/tracking_location.rb', line 30 def stop_sequence @stop_sequence end |
#stop_type ⇒ PickupOrDelivery
Type of stop (Pickup or Delivery).
26 27 28 |
# File 'lib/usps_api/models/tracking_location.rb', line 26 def stop_type @stop_type end |
#zip_code5 ⇒ String
Five-digit ZIP Code. Required when locationType is CUSTOMER or NON_USPS.
22 23 24 |
# File 'lib/usps_api/models/tracking_location.rb', line 22 def zip_code5 @zip_code5 end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/usps_api/models/tracking_location.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. location_type = hash.key?('locationType') ? hash['locationType'] : nil stop_type = hash.key?('stopType') ? hash['stopType'] : nil stop_sequence = hash.key?('stopSequence') ? hash['stopSequence'] : nil drop_site_key = hash.key?('dropSiteKey') ? hash['dropSiteKey'] : SKIP zip_code5 = hash.key?('ZIPCode5') ? hash['ZIPCode5'] : SKIP # Create object from extracted values. TrackingLocation.new(location_type: location_type, stop_type: stop_type, stop_sequence: stop_sequence, drop_site_key: drop_site_key, zip_code5: zip_code5) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/usps_api/models/tracking_location.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['location_type'] = 'locationType' @_hash['drop_site_key'] = 'dropSiteKey' @_hash['zip_code5'] = 'ZIPCode5' @_hash['stop_type'] = 'stopType' @_hash['stop_sequence'] = 'stopSequence' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 |
# File 'lib/usps_api/models/tracking_location.rb', line 52 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 |
# File 'lib/usps_api/models/tracking_location.rb', line 44 def self.optionals %w[ drop_site_key zip_code5 ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
92 93 94 95 96 97 |
# File 'lib/usps_api/models/tracking_location.rb', line 92 def inspect class_name = self.class.name.split('::').last "<#{class_name} location_type: #{@location_type.inspect}, drop_site_key:"\ " #{@drop_site_key.inspect}, zip_code5: #{@zip_code5.inspect}, stop_type:"\ " #{@stop_type.inspect}, stop_sequence: #{@stop_sequence.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
85 86 87 88 89 |
# File 'lib/usps_api/models/tracking_location.rb', line 85 def to_s class_name = self.class.name.split('::').last "<#{class_name} location_type: #{@location_type}, drop_site_key: #{@drop_site_key},"\ " zip_code5: #{@zip_code5}, stop_type: #{@stop_type}, stop_sequence: #{@stop_sequence}>" end |