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.
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
#cost ⇒ Money (readonly)
Returns the label's cost.
28 29 30 |
# File 'lib/friendly_shipping/label.rb', line 28 def cost @cost end |
#data ⇒ Hash (readonly)
Returns additional data related to the label.
34 35 36 |
# File 'lib/friendly_shipping/label.rb', line 34 def data @data end |
#id ⇒ String (readonly)
Returns the label's unique ID.
7 8 9 |
# File 'lib/friendly_shipping/label.rb', line 7 def id @id end |
#label_data ⇒ String (readonly)
Returns the raw label data.
25 26 27 |
# File 'lib/friendly_shipping/label.rb', line 25 def label_data @label_data end |
#label_format ⇒ String (readonly)
Returns the label's format.
22 23 24 |
# File 'lib/friendly_shipping/label.rb', line 22 def label_format @label_format end |
#label_href ⇒ String (readonly)
Returns the URL for the label.
19 20 21 |
# File 'lib/friendly_shipping/label.rb', line 19 def label_href @label_href end |
#service_code ⇒ String (readonly)
Returns the label's service code.
16 17 18 |
# File 'lib/friendly_shipping/label.rb', line 16 def service_code @service_code end |
#shipment_cost ⇒ Money (readonly)
Returns the overall cost of the shipment.
31 32 33 |
# File 'lib/friendly_shipping/label.rb', line 31 def shipment_cost @shipment_cost end |
#shipment_id ⇒ String (readonly)
Returns the label's shipment ID.
10 11 12 |
# File 'lib/friendly_shipping/label.rb', line 10 def shipment_id @shipment_id end |
#tracking_number ⇒ String (readonly)
Returns the label's tracking number.
13 14 15 |
# File 'lib/friendly_shipping/label.rb', line 13 def tracking_number @tracking_number end |