my $online_rate_request = new Business::Shipping::RateRequest::Online; my $packages = [ Business::Shipping::Package->new( 'weight' => '10' ), Business::Shipping::Package->new( 'weight' => '32' ), Business::Shipping::Package->new( 'weight' => '5' ), ]; my $shipment = Business::Shipping::Shipment->new(); $shipment->packages( $packages );

$rate_request->set_shipment( $shipment ); $rate_requets->set( user_id => 'user_id', password => 'password', # If you set the service, it will only get prices for that one service # If you leave out the service, it will try to get all available prices # service => 'GNDRES',

# If you set the shipper, it will only get prices for that shipper
# If you leave out the shipper, it will try to get all available prices
# shipper => 'UPS'

);

$rate_request->submit() or print $rate_request->error();

# get_services() for UPS would have to do some extra stuff. # It needs to use their services to find stuff... # For offline... what could we do? # # Does it support multiple services per request? # USPS: domestic and international: YES # UPS: no and no. ( but it can if you send a request first)

# combined_services_hash has "UPS Ground Residential" => 23.15 my %services = $rate_request->get_combined_services_hash();

#

my $results = $rate_request->get_result_hashref();

# This is what the results will look like $results = { 'UPS' => { 'GNDRES' => { 'price' => 23.15, 'description' => 'Ground Residential', }, '1DA' => { 'price' => 44.95, 'shipping' => 40.00, 'tax' => 4.95, 'description' => 'One Day Air', }, }, 'USPS' => { 'Priority' => { 'price' => 15.00, 'description' => 'Priority Mail', }, 'Express' => { 'price' => 30.00, 'description' => 'Express Mail', 'restrictions' => '', }, }, };

%simple_hash = ( 'UPS Ground Residential' => '4.00', 'UPS One Day Air' => '20.00', 'USPS Priority Mail' => '5.99', );

foreach my $shipper ( %{ $results } ) { foreach my $service ( keys %{ $shipper } ) { print $shipper . $service . $service->{ price }; } }

# For now, lets not support multiple shipments per request, until all the drivers can do it (LPW::Multiple) # Multiple shipments per request: # USPS International

# Multiple Packages per request: # USPS Domestic # UPS Domestic # UPS International.

$rate_request->set( 'tx_type' => 'online_rate_request', 'user_id' => '', );

foreach my $service ( $rate_request->find_services() ) { }

$rate_request->submit() or die $rate_request->error();

my $shipping = Business::Shipping->new();