Sha256: 65c4ab2f56bcebfb2c072c59fda05781a9a37b674d45314aa068ccaf57b4dd04

Contents?: true

Size: 627 Bytes

Versions: 8

Compression:

Stored size: 627 Bytes

Contents

module ActiveShipping

  # This is UPS specific for now; the hash is not at all generic
  # or common between carriers.
  class LabelResponse < Response
    attr :params # maybe?

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

    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_shipping-1.1.3 lib/active_shipping/label_response.rb
active_shipping-1.1.2 lib/active_shipping/label_response.rb
active_shipping-1.1.1 lib/active_shipping/label_response.rb
active_shipping-1.1.0 lib/active_shipping/label_response.rb
active_shipping-1.0.1 lib/active_shipping/label_response.rb
active_shipping-1.0.0 lib/active_shipping/label_response.rb
active_shipping-1.0.0.pre4 lib/active_shipping/label_response.rb
active_shipping-1.0.0.pre3 lib/active_shipping/label_response.rb