Class: FriendlyShipping::Label
- Inherits:
-
Object
- Object
- FriendlyShipping::Label
- Defined in:
- lib/friendly_shipping/label.rb
Overview
Base class for a shipping label returned by a carrier API.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cost ⇒ Money
readonly
The label's cost.
-
#data ⇒ Hash
readonly
Additional data related to the label.
-
#id ⇒ String
readonly
The label's unique ID.
-
#label_data ⇒ String
readonly
The raw label data.
-
#label_format ⇒ String
readonly
The label's format.
-
#label_href ⇒ String
readonly
The URL for the label.
-
#service_code ⇒ String
readonly
The label's service code.
-
#shipment_cost ⇒ Money
readonly
The overall cost of the shipment.
-
#shipment_id ⇒ String
readonly
The label's shipment ID.
-
#tracking_number ⇒ String
readonly
The label's tracking number.
Instance Method Summary collapse
-
#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
constructor
A new instance of Label.
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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/friendly_shipping/label.rb', line 48 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
#cost ⇒ Money (readonly)
Returns the label's cost.
30 31 32 |
# File 'lib/friendly_shipping/label.rb', line 30 def cost @cost end |
#data ⇒ Hash (readonly)
Returns additional data related to the label.
36 37 38 |
# File 'lib/friendly_shipping/label.rb', line 36 def data @data end |
#id ⇒ String (readonly)
Returns the label's unique ID.
9 10 11 |
# File 'lib/friendly_shipping/label.rb', line 9 def id @id end |
#label_data ⇒ String (readonly)
Returns the raw label data.
27 28 29 |
# File 'lib/friendly_shipping/label.rb', line 27 def label_data @label_data end |
#label_format ⇒ String (readonly)
Returns the label's format.
24 25 26 |
# File 'lib/friendly_shipping/label.rb', line 24 def label_format @label_format end |
#label_href ⇒ String (readonly)
Returns the URL for the label.
21 22 23 |
# File 'lib/friendly_shipping/label.rb', line 21 def label_href @label_href end |
#service_code ⇒ String (readonly)
Returns the label's service code.
18 19 20 |
# File 'lib/friendly_shipping/label.rb', line 18 def service_code @service_code end |
#shipment_cost ⇒ Money (readonly)
Returns the overall cost of the shipment.
33 34 35 |
# File 'lib/friendly_shipping/label.rb', line 33 def shipment_cost @shipment_cost end |
#shipment_id ⇒ String (readonly)
Returns the label's shipment ID.
12 13 14 |
# File 'lib/friendly_shipping/label.rb', line 12 def shipment_id @shipment_id end |
#tracking_number ⇒ String (readonly)
Returns the label's tracking number.
15 16 17 |
# File 'lib/friendly_shipping/label.rb', line 15 def tracking_number @tracking_number end |