class AfterShip::Tracking

Wrapper object for AfterShip tracking: www.aftership.com/docs/api/4/trackings/get-trackings-slug-tracking_number

Attributes

active[RW]

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.

@return [Bool]

android[RW]

Google cloud message registration IDs to receive the push notifications. Accept either array or Comma comma separated as input.

@return [Array, String]

checkpoints[R]

Array of Checkpoint describes the checkpoint information.

@return [Array<Checkpoint>]

courier[RW]

Courier name.

Custom method!

@return [String]

created_at[R]

Date and time of the tracking created.

@return [DateTime]

custom_fields[RW]

Custom fields of the tracking.

@return [Hash]

customer_name[RW]

Customer name of the tracking.

@return [String]

delivery_time[RW]

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.

@return [Fixnum]

destination_country_iso3[RW]

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.

@return [String]

emails[RW]

Email address(es) to receive email notifications. Comma separated for multiple values.

@return [Array<String>]

expected_delivery[R]

Expected delivery date (if any).

Empty String, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+TIMEZONE.

@return [DateTime]

id[RW]

A unique identifier generated by AfterShip for the tracking.

@return [String]

ios[RW]

Apple iOS device IDs to receive the push notificaitons. Accept either array or Comma comma separated as input.

@return [Array, String]

order_id[RW]

Text field for order ID.

@return [String]

order_id_path[RW]

Text field for order path.

@return [String]

origin_country_iso3[RW]

Origin country of the tracking. ISO Alpha-3 (three letters).

@return [String]

shipment_package_count[RW]

Number of packages under the tracking.

@return [Number]

shipment_type[RW]

Shipment type provided by carrier (if any).

@return [String]

shipment_weight[RW]

Shipment weight provied by carrier (if any).

@return [Fixnum]

shipment_weight_unit[RW]

Weight unit provied by carrier, either in kg or lb (if any).

@return [String]

signed_by[RW]

Signed by information for delivered shipment (if any).

@return [String]

slug[R]

Unique code of courier.

@return [String]

smses[RW]

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.

@return [Array<String>]

source[RW]

Source of how this tracking is added.

@return [String]

status[RW]

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

@return [String]

tag[R]

Current status of tracking.

Value: Pending, InfoReceived, InTransit, OutForDelivery, AttemptFail, Delivered, Exception, Expired.

See status definition www.aftership.com/docs/api/4/delivery-status.

@return [String]

title[RW]

Title of the tracking.

@return [String]

tracked_count[RW]

Number of attempts AfterShip tracks at courier's system.

@return [Number]

tracking_account_number[RW]

Account number of the shipper for a specific courier. Required by some couriers, such as dynamic-logistics.

@return [String]

tracking_number[RW]

Tracking number, e.g. 1ZA2207X6794165804.

@return [String]

tracking_postal_code[RW]

The postal code of receiver's address. Required by some couriers, such as deutsch-post.

@return [String]

tracking_ship_date[R]

Shipping date in YYYYMMDD format. Required by some couriers, such as deutsch-post.

@return [String]

unique_token[RW]

The token to generate the direct tracking link: yourusername.aftership.com/unique_token or www.aftership.com/unique_token.

@return [String]

updated_at[R]

Date and time of the tracking last updated.

@return [DateTime]

Public Class Methods

new(data) click to toggle source

Better interface for a tracking.

@param data [Hash] tracking hash

# File lib/after_ship/tracking.rb, line 226
def initialize(data)
  @checkpoints = []
  load_attributes(data)
end

Public Instance Methods

checkpoints=(value) click to toggle source

Array of Checkpoint describes the checkpoint information.

@return [Array<Checkpoint>]

# File lib/after_ship/tracking.rb, line 286
def checkpoints=(value)
  @checkpoints = value.map { |data| Checkpoint.new(data) }
end
created_at=(value) click to toggle source

Date and time of the tracking created.

@return [DateTime]

# File lib/after_ship/tracking.rb, line 234
def created_at=(value)
  @created_at = DateTime.parse(value)
end
expected_delivery=(value) click to toggle source

Expected delivery date (if any).

@return [DateTime]

# File lib/after_ship/tracking.rb, line 265
def expected_delivery=(value)
  @expected_delivery = DateUtils.parse(value)
end
slug=(value) click to toggle source

Unique code of courier.

@return [String]

# File lib/after_ship/tracking.rb, line 256
def slug=(value)
  @slug        = value
  self.courier = value.upcase
  @slug
end
tag=(value) click to toggle source

Current status of tracking.

Value: Pending, InfoReceived, InTransit, OutForDelivery, AttemptFail, Delivered, Exception, Expired.

See status definition www.aftership.com/docs/api/4/delivery-status.

@return [String]

# File lib/after_ship/tracking.rb, line 277
def tag=(value)
  @tag        = value
  self.status = TAG_STATUS.fetch(value)
  @tag
end
tracking_ship_date=(value) click to toggle source

Shipping date in YYYYMMDD format. Required by some couriers, such as deutsch-post.

@return [DateTime]

# File lib/after_ship/tracking.rb, line 249
def tracking_ship_date=(value)
  @tracking_ship_date = DateUtils.parse(value)
end
updated_at=(value) click to toggle source

Date and time of the tracking last updated.

@return [DateTime]

# File lib/after_ship/tracking.rb, line 241
def updated_at=(value)
  @updated_at = DateTime.parse(value)
end