Class: AfterShip::Courier

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

Overview

Wrapper object for AfterShip courier: www.aftership.com/docs/api/4/couriers/get-couriers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Courier

Better interface for a courier.

Parameters:

  • data (Hash)

    tracking hash



41
42
43
# File 'lib/after_ship/courier.rb', line 41

def initialize(data)
  load_attributes(data)
end

Instance Attribute Details

#nameString

Name of courier.

Returns:

  • (String)


15
16
17
# File 'lib/after_ship/courier.rb', line 15

def name
  @name
end

#other_nameString

Other name of courier.

Returns:

  • (String)


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

def other_name
  @other_name
end

#phoneString

Contact phone number of courier.

Returns:

  • (String)


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

def phone
  @phone
end

#required_fieldsArray

The extra fields need for tracking, such as ‘tracking_account_number`, `tracking_postal_code`, `tracking_ship_date`.

Returns:

  • (Array)


36
37
38
# File 'lib/after_ship/courier.rb', line 36

def required_fields
  @required_fields
end

#slugString

Unique code of courier.

Returns:

  • (String)


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

def slug
  @slug
end

#web_urlString

Website link of courier.

Returns:

  • (String)


30
31
32
# File 'lib/after_ship/courier.rb', line 30

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