Class: AfterShip::Tracking
- Inherits:
-
Object
- Object
- AfterShip::Tracking
- Includes:
- Attributes
- Defined in:
- lib/after_ship/tracking.rb
Overview
Wrapper object for AfterShip tracking: www.aftership.com/docs/api/4/trackings/get-trackings-slug-tracking_number
Instance Attribute Summary collapse
-
#active ⇒ Bool
Whether or not AfterShip will continue tracking the shipments.
-
#android ⇒ Array, String
Google cloud message registration IDs to receive the push notifications.
-
#checkpoints ⇒ Array<Checkpoint>
Array of Checkpoint describes the checkpoint information.
-
#courier ⇒ String
Courier name.
-
#created_at ⇒ DateTime
Date and time of the tracking created.
-
#custom_fields ⇒ Hash
Custom fields of the tracking.
-
#customer_name ⇒ String
Customer name of the tracking.
-
#delivery_time ⇒ Fixnum
Total delivery time in days.
-
#destination_country_iso3 ⇒ String
Destination country of the tracking.
-
#emails ⇒ Array<String>
Email address(es) to receive email notifications.
-
#expected_delivery ⇒ DateTime
Expected delivery date (if any).
-
#id ⇒ String
A unique identifier generated by AfterShip for the tracking.
-
#ios ⇒ Array, String
Apple iOS device IDs to receive the push notificaitons.
-
#order_id ⇒ String
Text field for order ID.
-
#order_id_path ⇒ String
Text field for order path.
-
#origin_country_iso3 ⇒ String
Origin country of the tracking.
-
#shipment_package_count ⇒ Number
Number of packages under the tracking.
-
#shipment_type ⇒ String
Shipment type provided by carrier (if any).
-
#shipment_weight ⇒ Fixnum
Shipment weight provied by carrier (if any).
-
#shipment_weight_unit ⇒ String
Weight unit provied by carrier, either in
kgorlb(if any). -
#signed_by ⇒ String
Signed by information for delivered shipment (if any).
-
#slug ⇒ String
Unique code of courier.
-
#smses ⇒ Array<String>
Phone number(s) to receive sms notifications.
-
#source ⇒ String
Source of how this tracking is added.
-
#status ⇒ String
Same as tag, except human-friendly:.
-
#tag ⇒ String
Current status of tracking.
-
#title ⇒ String
Title of the tracking.
-
#tracked_count ⇒ Number
Number of attempts AfterShip tracks at courier’s system.
-
#tracking_account_number ⇒ String
Account number of the shipper for a specific courier.
-
#tracking_number ⇒ String
Tracking number, e.g.
-
#tracking_postal_code ⇒ String
The postal code of receiver’s address.
-
#tracking_ship_date ⇒ String
Shipping date in
YYYYMMDDformat. -
#unique_token ⇒ String
The token to generate the direct tracking link: yourusername.aftership.com/unique_token or www.aftership.com/unique_token.
-
#updated_at ⇒ DateTime
Date and time of the tracking last updated.
Instance Method Summary collapse
-
#initialize(data) ⇒ Tracking
constructor
Better interface for a tracking.
-
#load_attributes(data) ⇒ Object
included
from Attributes
Loop through the data hash and for each key call a setter with the value.
Constructor Details
#initialize(data) ⇒ Tracking
Better interface for a tracking.
226 227 228 229 |
# File 'lib/after_ship/tracking.rb', line 226 def initialize(data) @checkpoints = [] load_attributes(data) end |
Instance Attribute Details
#active ⇒ Bool
Whether or not AfterShip will continue tracking the shipments. Value is false when tag (status) is Delivered, Expired, or further updates for 30 days since last update.
62 63 64 |
# File 'lib/after_ship/tracking.rb', line 62 def active @active end |
#android ⇒ Array, String
Google cloud message registration IDs to receive the push notifications. Accept either array or Comma comma separated as input.
68 69 70 |
# File 'lib/after_ship/tracking.rb', line 68 def android @android end |
#checkpoints ⇒ Array<Checkpoint>
Array of Checkpoint describes the checkpoint information.
221 222 223 |
# File 'lib/after_ship/tracking.rb', line 221 def checkpoints @checkpoints end |
#courier ⇒ String
Courier name.
Custom method!
55 56 57 |
# File 'lib/after_ship/tracking.rb', line 55 def courier @courier end |
#created_at ⇒ DateTime
Date and time of the tracking created.
10 11 12 |
# File 'lib/after_ship/tracking.rb', line 10 def created_at @created_at end |
#custom_fields ⇒ Hash
Custom fields of the tracking.
73 74 75 |
# File 'lib/after_ship/tracking.rb', line 73 def custom_fields @custom_fields end |
#customer_name ⇒ String
Customer name of the tracking.
78 79 80 |
# File 'lib/after_ship/tracking.rb', line 78 def customer_name @customer_name end |
#delivery_time ⇒ Fixnum
Total delivery time in days.
-
Difference of 1st checkpoint time and delivered time for delivered shipments.
-
Difference of 1st checkpoint time and current time for non-delivered shipments.
Value as 0 for pending shipments or delivered shipment with only one checkpoint.
91 92 93 |
# File 'lib/after_ship/tracking.rb', line 91 def delivery_time @delivery_time end |
#destination_country_iso3 ⇒ String
Destination country of the tracking. ISO Alpha-3 (three letters). If you use postal service to send international shipments, AfterShip will automatically get tracking results from destination postal service based on destination country.
99 100 101 |
# File 'lib/after_ship/tracking.rb', line 99 def destination_country_iso3 @destination_country_iso3 end |
#emails ⇒ Array<String>
Email address(es) to receive email notifications. Comma separated for multiple values.
105 106 107 |
# File 'lib/after_ship/tracking.rb', line 105 def emails @emails end |
#expected_delivery ⇒ DateTime
Expected delivery date (if any).
Empty String, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+TIMEZONE.
115 116 117 |
# File 'lib/after_ship/tracking.rb', line 115 def expected_delivery @expected_delivery end |
#id ⇒ String
A unique identifier generated by AfterShip for the tracking.
20 21 22 |
# File 'lib/after_ship/tracking.rb', line 20 def id @id end |
#ios ⇒ Array, String
Apple iOS device IDs to receive the push notificaitons. Accept either array or Comma comma separated as input.
121 122 123 |
# File 'lib/after_ship/tracking.rb', line 121 def ios @ios end |
#order_id ⇒ String
Text field for order ID.
126 127 128 |
# File 'lib/after_ship/tracking.rb', line 126 def order_id @order_id end |
#order_id_path ⇒ String
Text field for order path.
131 132 133 |
# File 'lib/after_ship/tracking.rb', line 131 def order_id_path @order_id_path end |
#origin_country_iso3 ⇒ String
Origin country of the tracking. ISO Alpha-3 (three letters).
136 137 138 |
# File 'lib/after_ship/tracking.rb', line 136 def origin_country_iso3 @origin_country_iso3 end |
#shipment_package_count ⇒ Number
Number of packages under the tracking.
148 149 150 |
# File 'lib/after_ship/tracking.rb', line 148 def shipment_package_count @shipment_package_count end |
#shipment_type ⇒ String
Shipment type provided by carrier (if any).
153 154 155 |
# File 'lib/after_ship/tracking.rb', line 153 def shipment_type @shipment_type end |
#shipment_weight ⇒ Fixnum
Shipment weight provied by carrier (if any).
158 159 160 |
# File 'lib/after_ship/tracking.rb', line 158 def shipment_weight @shipment_weight end |
#shipment_weight_unit ⇒ String
Weight unit provied by carrier, either in kg or lb (if any).
163 164 165 |
# File 'lib/after_ship/tracking.rb', line 163 def shipment_weight_unit @shipment_weight_unit end |
#signed_by ⇒ String
Signed by information for delivered shipment (if any).
168 169 170 |
# File 'lib/after_ship/tracking.rb', line 168 def signed_by @signed_by end |
#slug ⇒ String
Unique code of courier.
48 49 50 |
# File 'lib/after_ship/tracking.rb', line 48 def slug @slug end |
#smses ⇒ Array<String>
Phone number(s) to receive sms notifications. The phone number(s) to receive sms notifications. Phone number should begin with + and +Area Code+ before phone number. Comma separated for multiple values.
175 176 177 |
# File 'lib/after_ship/tracking.rb', line 175 def smses @smses end |
#source ⇒ String
Source of how this tracking is added.
180 181 182 |
# File 'lib/after_ship/tracking.rb', line 180 def source @source end |
#status ⇒ String
Same as tag, except human-friendly:
Custom method!
-
Pending=>Pending -
InfoReceived=> Info Received -
InTransit=> In Transit -
OutForDelivery=> Out For Delivery -
AttemptFail=> Attempt Failed -
Delivered=>Delivered -
Exception=>Exception -
Expired=>Expired
206 207 208 |
# File 'lib/after_ship/tracking.rb', line 206 def status @status end |
#tag ⇒ String
Current status of tracking.
Value: Pending, InfoReceived, InTransit, OutForDelivery, AttemptFail, Delivered, Exception, Expired.
See status definition www.aftership.com/docs/api/4/delivery-status.
190 191 192 |
# File 'lib/after_ship/tracking.rb', line 190 def tag @tag end |
#title ⇒ String
Title of the tracking.
211 212 213 |
# File 'lib/after_ship/tracking.rb', line 211 def title @title end |
#tracked_count ⇒ Number
Number of attempts AfterShip tracks at courier’s system.
216 217 218 |
# File 'lib/after_ship/tracking.rb', line 216 def tracked_count @tracked_count end |
#tracking_account_number ⇒ String
Account number of the shipper for a specific courier. Required by some couriers, such as dynamic-logistics.
43 44 45 |
# File 'lib/after_ship/tracking.rb', line 43 def tracking_account_number @tracking_account_number end |
#tracking_number ⇒ String
Tracking number, e.g. 1ZA2207X6794165804.
25 26 27 |
# File 'lib/after_ship/tracking.rb', line 25 def tracking_number @tracking_number end |
#tracking_postal_code ⇒ String
The postal code of receiver’s address. Required by some couriers, such as deutsch-post.
31 32 33 |
# File 'lib/after_ship/tracking.rb', line 31 def tracking_postal_code @tracking_postal_code end |
#tracking_ship_date ⇒ String
Shipping date in YYYYMMDD format. Required by some couriers, such as deutsch-post.
37 38 39 |
# File 'lib/after_ship/tracking.rb', line 37 def tracking_ship_date @tracking_ship_date end |
#unique_token ⇒ String
The token to generate the direct tracking link: yourusername.aftership.com/unique_token or www.aftership.com/unique_token.
143 144 145 |
# File 'lib/after_ship/tracking.rb', line 143 def unique_token @unique_token end |
#updated_at ⇒ DateTime
Date and time of the tracking last updated.
15 16 17 |
# File 'lib/after_ship/tracking.rb', line 15 def updated_at @updated_at end |
Instance Method Details
#load_attributes(data) ⇒ Object Originally defined in module Attributes
Loop through the data hash and for each key call a setter with the value.