Class: AfterShip::Tracking

Inherits:
Object
  • Object
show all
Includes:
Attributes
Defined in:
lib/after_ship/tracking.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Tracking

Better interface for a tracking.

Parameters:

  • data (Hash)

    tracking hash



226
227
228
229
# File 'lib/after_ship/tracking.rb', line 226

def initialize(data)
  @checkpoints = []
  load_attributes(data)
end

Instance Attribute Details

#activeBool

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.

Returns:

  • (Bool)


62
63
64
# File 'lib/after_ship/tracking.rb', line 62

def active
  @active
end

#androidArray, String

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

Returns:

  • (Array, String)


68
69
70
# File 'lib/after_ship/tracking.rb', line 68

def android
  @android
end

#checkpointsArray<Checkpoint>

Array of Checkpoint describes the checkpoint information.

Returns:



221
222
223
# File 'lib/after_ship/tracking.rb', line 221

def checkpoints
  @checkpoints
end

#courierString

Courier name.

Custom method!

Returns:

  • (String)


55
56
57
# File 'lib/after_ship/tracking.rb', line 55

def courier
  @courier
end

#created_atDateTime

Date and time of the tracking created.

Returns:

  • (DateTime)


10
11
12
# File 'lib/after_ship/tracking.rb', line 10

def created_at
  @created_at
end

#custom_fieldsHash

Custom fields of the tracking.

Returns:

  • (Hash)


73
74
75
# File 'lib/after_ship/tracking.rb', line 73

def custom_fields
  @custom_fields
end

#customer_nameString

Customer name of the tracking.

Returns:

  • (String)


78
79
80
# File 'lib/after_ship/tracking.rb', line 78

def customer_name
  @customer_name
end

#delivery_timeFixnum

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.

Returns:

  • (Fixnum)


91
92
93
# File 'lib/after_ship/tracking.rb', line 91

def delivery_time
  @delivery_time
end

#destination_country_iso3String

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.

Returns:

  • (String)


99
100
101
# File 'lib/after_ship/tracking.rb', line 99

def destination_country_iso3
  @destination_country_iso3
end

#emailsArray<String>

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

Returns:

  • (Array<String>)


105
106
107
# File 'lib/after_ship/tracking.rb', line 105

def emails
  @emails
end

#expected_deliveryDateTime

Expected delivery date (if any).

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

Returns:

  • (DateTime)


115
116
117
# File 'lib/after_ship/tracking.rb', line 115

def expected_delivery
  @expected_delivery
end

#idString

A unique identifier generated by AfterShip for the tracking.

Returns:

  • (String)


20
21
22
# File 'lib/after_ship/tracking.rb', line 20

def id
  @id
end

#iosArray, String

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

Returns:

  • (Array, String)


121
122
123
# File 'lib/after_ship/tracking.rb', line 121

def ios
  @ios
end

#order_idString

Text field for order ID.

Returns:

  • (String)


126
127
128
# File 'lib/after_ship/tracking.rb', line 126

def order_id
  @order_id
end

#order_id_pathString

Text field for order path.

Returns:

  • (String)


131
132
133
# File 'lib/after_ship/tracking.rb', line 131

def order_id_path
  @order_id_path
end

#origin_country_iso3String

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

Returns:

  • (String)


136
137
138
# File 'lib/after_ship/tracking.rb', line 136

def origin_country_iso3
  @origin_country_iso3
end

#shipment_package_countNumber

Number of packages under the tracking.

Returns:

  • (Number)


148
149
150
# File 'lib/after_ship/tracking.rb', line 148

def shipment_package_count
  @shipment_package_count
end

#shipment_typeString

Shipment type provided by carrier (if any).

Returns:

  • (String)


153
154
155
# File 'lib/after_ship/tracking.rb', line 153

def shipment_type
  @shipment_type
end

#shipment_weightFixnum

Shipment weight provied by carrier (if any).

Returns:

  • (Fixnum)


158
159
160
# File 'lib/after_ship/tracking.rb', line 158

def shipment_weight
  @shipment_weight
end

#shipment_weight_unitString

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

Returns:

  • (String)


163
164
165
# File 'lib/after_ship/tracking.rb', line 163

def shipment_weight_unit
  @shipment_weight_unit
end

#signed_byString

Signed by information for delivered shipment (if any).

Returns:

  • (String)


168
169
170
# File 'lib/after_ship/tracking.rb', line 168

def signed_by
  @signed_by
end

#slugString

Unique code of courier.

Returns:

  • (String)


48
49
50
# File 'lib/after_ship/tracking.rb', line 48

def slug
  @slug
end

#smsesArray<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.

Returns:

  • (Array<String>)


175
176
177
# File 'lib/after_ship/tracking.rb', line 175

def smses
  @smses
end

#sourceString

Source of how this tracking is added.

Returns:

  • (String)


180
181
182
# File 'lib/after_ship/tracking.rb', line 180

def source
  @source
end

#statusString

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

Returns:

  • (String)


206
207
208
# File 'lib/after_ship/tracking.rb', line 206

def status
  @status
end

#tagString

Current status of tracking.

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

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

Returns:

  • (String)


190
191
192
# File 'lib/after_ship/tracking.rb', line 190

def tag
  @tag
end

#titleString

Title of the tracking.

Returns:

  • (String)


211
212
213
# File 'lib/after_ship/tracking.rb', line 211

def title
  @title
end

#tracked_countNumber

Number of attempts AfterShip tracks at courier’s system.

Returns:

  • (Number)


216
217
218
# File 'lib/after_ship/tracking.rb', line 216

def tracked_count
  @tracked_count
end

#tracking_account_numberString

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

Returns:

  • (String)


43
44
45
# File 'lib/after_ship/tracking.rb', line 43

def 
  @tracking_account_number
end

#tracking_numberString

Tracking number, e.g. 1ZA2207X6794165804.

Returns:

  • (String)


25
26
27
# File 'lib/after_ship/tracking.rb', line 25

def tracking_number
  @tracking_number
end

#tracking_postal_codeString

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

Returns:

  • (String)


31
32
33
# File 'lib/after_ship/tracking.rb', line 31

def tracking_postal_code
  @tracking_postal_code
end

#tracking_ship_dateString

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

Returns:

  • (String)


37
38
39
# File 'lib/after_ship/tracking.rb', line 37

def tracking_ship_date
  @tracking_ship_date
end

#unique_tokenString

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

Returns:

  • (String)


143
144
145
# File 'lib/after_ship/tracking.rb', line 143

def unique_token
  @unique_token
end

#updated_atDateTime

Date and time of the tracking last updated.

Returns:

  • (DateTime)


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.

Parameters:

  • data (Hash)