Class: ActiveMerchant::Shipping::LabelResponse

Inherits:
Response show all
Defined in:
lib/active_shipping/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


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

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

Instance Attribute Details

#paramsObject (readonly)

maybe?


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

def params
  @params
end

Instance Method Details

#labelsObject


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

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