Class: AfterShip::Checkpoint

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Checkpoint

Better interface for a checkpoint.

Parameters:

  • data (Hash)

    checkpoint hash



107
108
109
# File 'lib/after_ship/checkpoint.rb', line 107

def initialize(data)
  load_attributes(data)
end

Instance Attribute Details

#checkpoint_timeDateTime

Date and time of the checkpoint, provided by courier.

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

Should always be available.

Returns:

  • (DateTime)


38
39
40
# File 'lib/after_ship/checkpoint.rb', line 38

def checkpoint_time
  @checkpoint_time
end

#cityString

Location info (if any).

May be empty.

Returns:

  • (String)


45
46
47
# File 'lib/after_ship/checkpoint.rb', line 45

def city
  @city
end

#country_iso3String

Country ISO Alpha-3 (three letters) of the checkpoint.

May be empty.

Returns:

  • (String)


52
53
54
# File 'lib/after_ship/checkpoint.rb', line 52

def country_iso3
  @country_iso3
end

#country_nameString

Country name of the checkpoint, may also contain other location info. Seems to be Alpha-2 code, e.g. IN, DE.

May be empty.

Returns:

  • (String)


60
61
62
# File 'lib/after_ship/checkpoint.rb', line 60

def country_name
  @country_name
end

#courierString

Courier name.

Custom method!

Returns:

  • (String)


26
27
28
# File 'lib/after_ship/checkpoint.rb', line 26

def courier
  @courier
end

#created_atDateTime

Date and time of the tracking created.

Should always be available.

Returns:

  • (DateTime)


12
13
14
# File 'lib/after_ship/checkpoint.rb', line 12

def created_at
  @created_at
end

#messageString

Checkpoint message

Should always be available.

Returns:

  • (String)


67
68
69
# File 'lib/after_ship/checkpoint.rb', line 67

def message
  @message
end

#slugString

The unique code of courier for this checkpoint message.

Should always be available.

Returns:

  • (String)


19
20
21
# File 'lib/after_ship/checkpoint.rb', line 19

def slug
  @slug
end

#stateString

Location info (if any).

May be empty.

Returns:

  • (String)


74
75
76
# File 'lib/after_ship/checkpoint.rb', line 74

def state
  @state
end

#statusString

Same as tag, except human-friendly:

  • Pending => Pending

  • InfoReceived => Info Received

  • InTransit => In Transit

  • OutForDelivery => Out For Delivery

  • AttemptFail => Attempt Failed

  • Delivered => Delivered

  • Exception => Exception

  • Expired => Expired

Returns:

  • (String)


95
96
97
# File 'lib/after_ship/checkpoint.rb', line 95

def status
  @status
end

#tagString

Status of the checkpoint.

Should always be available.

Returns:

  • (String)


81
82
83
# File 'lib/after_ship/checkpoint.rb', line 81

def tag
  @tag
end

#zipString

Location info (if any).

May be empty.

Returns:

  • (String)


102
103
104
# File 'lib/after_ship/checkpoint.rb', line 102

def zip
  @zip
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)