Class: ActiveShipping::LabelResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/active_shipping/label_response.rb

Overview

This is UPS specific for now; the hash is not at all generic or common between carriers.

Instance Attribute Summary collapse

Attributes inherited from Response

#message, #request, #test, #xml

Instance Method Summary collapse

Methods inherited from Response

#success?, #test?

Constructor Details

#initialize(success, message, params = {}, options = {}) ⇒ LabelResponse

Returns a new instance of LabelResponse.



8
9
10
11
# File 'lib/active_shipping/label_response.rb', line 8

def initialize(success, message, params = {}, options = {})
  @params = params
  super
end

Instance Attribute Details

#paramsObject (readonly)

maybe?



6
7
8
# File 'lib/active_shipping/label_response.rb', line 6

def params
  @params
end

Instance Method Details

#labelsObject



13
14
15
16
17
18
19
20
21
# File 'lib/active_shipping/label_response.rb', line 13

def labels
  return @labels if @labels
  packages = params["ShipmentResults"]["PackageResults"]
  packages = [packages] if Hash === packages
  @labels  = packages.map do |package|
    { :tracking_number => package["TrackingNumber"],
      :image           => package["LabelImage"] }
  end
end