Class: FriendlyShipping::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/label.rb

Overview

Base class for a shipping label returned by a carrier API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, shipment_id: nil, tracking_number: nil, service_code: nil, label_href: nil, label_format: nil, label_data: nil, cost: nil, shipment_cost: nil, data: {}) ⇒ Label

Returns a new instance of Label.

Parameters:

  • id (String) (defaults to: nil)

    the label's unique ID

  • shipment_id (String) (defaults to: nil)

    the label's shipment ID

  • tracking_number (String) (defaults to: nil)

    the label's tracking number

  • service_code (String) (defaults to: nil)

    the label's service code

  • label_href (String) (defaults to: nil)

    the URL for the label

  • label_format (String) (defaults to: nil)

    the label's format

  • label_data (String) (defaults to: nil)

    the raw label data

  • cost (Money) (defaults to: nil)

    the label's cost

  • shipment_cost (Money) (defaults to: nil)

    the overall cost of the shipment

  • data (Hash) (defaults to: {})

    additional data related to the label



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/friendly_shipping/label.rb', line 46

def initialize(
  id: nil,
  shipment_id: nil,
  tracking_number: nil,
  service_code: nil,
  label_href: nil,
  label_format: nil,
  label_data: nil,
  cost: nil,
  shipment_cost: nil,
  data: {}
)
  @id = id
  @shipment_id = shipment_id
  @tracking_number = tracking_number
  @service_code = service_code
  @label_href = label_href
  @label_format = label_format
  @cost = FriendlyShipping::Types::Money.optional[cost]
  @shipment_cost = FriendlyShipping::Types::Money.optional[shipment_cost]
  @label_data = label_data
  @data = data
end

Instance Attribute Details

#costMoney (readonly)

Returns the label's cost.

Returns:

  • (Money)

    the label's cost



28
29
30
# File 'lib/friendly_shipping/label.rb', line 28

def cost
  @cost
end

#dataHash (readonly)

Returns additional data related to the label.

Returns:

  • (Hash)

    additional data related to the label



34
35
36
# File 'lib/friendly_shipping/label.rb', line 34

def data
  @data
end

#idString (readonly)

Returns the label's unique ID.

Returns:

  • (String)

    the label's unique ID



7
8
9
# File 'lib/friendly_shipping/label.rb', line 7

def id
  @id
end

#label_dataString (readonly)

Returns the raw label data.

Returns:

  • (String)

    the raw label data



25
26
27
# File 'lib/friendly_shipping/label.rb', line 25

def label_data
  @label_data
end

#label_formatString (readonly)

Returns the label's format.

Returns:

  • (String)

    the label's format



22
23
24
# File 'lib/friendly_shipping/label.rb', line 22

def label_format
  @label_format
end

#label_hrefString (readonly)

Returns the URL for the label.

Returns:

  • (String)

    the URL for the label



19
20
21
# File 'lib/friendly_shipping/label.rb', line 19

def label_href
  @label_href
end

#service_codeString (readonly)

Returns the label's service code.

Returns:

  • (String)

    the label's service code



16
17
18
# File 'lib/friendly_shipping/label.rb', line 16

def service_code
  @service_code
end

#shipment_costMoney (readonly)

Returns the overall cost of the shipment.

Returns:

  • (Money)

    the overall cost of the shipment



31
32
33
# File 'lib/friendly_shipping/label.rb', line 31

def shipment_cost
  @shipment_cost
end

#shipment_idString (readonly)

Returns the label's shipment ID.

Returns:

  • (String)

    the label's shipment ID



10
11
12
# File 'lib/friendly_shipping/label.rb', line 10

def shipment_id
  @shipment_id
end

#tracking_numberString (readonly)

Returns the label's tracking number.

Returns:

  • (String)

    the label's tracking number



13
14
15
# File 'lib/friendly_shipping/label.rb', line 13

def tracking_number
  @tracking_number
end