Skip to content
This repository was archived by the owner on Jun 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #356 from jgillman/add-insured-value-for-ups
Browse files Browse the repository at this point in the history
Add InsuredValue option for UPS packages
  • Loading branch information
kmcphillips committed Apr 20, 2016
2 parents 9fa3ee8 + 8671a6d commit b26844f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/active_shipping/carriers/ups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,13 @@ def build_package_node(xml, package, options = {})
end
end
end

if package_value = package.options[:insured_value]
xml.InsuredValue do
xml.CurrencyCode(package.options[:currency] || 'USD')
xml.MonetaryValue(package_value.to_f)
end
end
end

# not implemented: * Shipment/Package/LargePackageIndicator element
Expand Down
12 changes: 12 additions & 0 deletions test/remote/ups_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,16 @@ def test_create_shipment_with_dry_ice_options
assert response.success?
assert_instance_of ActiveShipping::LabelResponse, response
end

def test_create_shipment_with_insured_value
response = @carrier.create_shipment(
location_fixtures[:beverly_hills_with_name],
location_fixtures[:new_york_with_name],
package_fixtures.values_at(:insured_value),
:test => true
)

assert response.success?
assert_instance_of ActiveShipping::LabelResponse, response
end
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def package_fixtures
:chocolate_stuff => Package.new(80, [2, 6, 12], :units => :imperial),
:frozen_stuff => Package.new(80, [2, 6, 12], :units => :imperial, :dry_ice => {weight: 1.4}),
:declared_value => Package.new(80, [2, 6, 12], :units => :imperial, :currency => 'USD', :value => 999.99),
:insured_value => Package.new(80, [2, 6, 12], :units => :imperial, :currency => 'USD', :insured_value => 999.99),
:tshirts => Package.new(10 * 16, nil, :units => :imperial),
:shipping_container => Package.new(2200000, [2440, 2600, 6058], :description => '20 ft Standard Container', :units => :metric),
:largest_gold_bar => Package.new(250000, [45.5, 22.5, 17], :value => 15300000),
Expand Down

0 comments on commit b26844f

Please sign in to comment.