NAME

Business::Shipping - API for shipping-related tasks


SYNOPSIS

Example usage for a rating request:

        use Business::Shipping;
        
        my $rate_request = Business::Shipping->rate_request(
                shipper                 => 'Offline::UPS',
                service                 => 'GNDRES',
                from_zip                => '98682',
                to_zip                  => '98270',
                weight                  => 5.00,
        );
        
        $rate_request->submit() or die $rate_request->error();
        
        print $rate_request->total_charges();


ABSTRACT

Business::Shipping is an API for shipping-related tasks.

Shipping Tasks Implemented at this time:

 * Shipping cost calculation
 * Tracking, availability, and other services are planned for future addition.

Shipping Vendors Implemented at this time:

 * Online UPS (using the Internet and UPS servers)
 * Offline UPS (using tables stored locally)
 * Online USPS
 * Offline FedEX and USPS are planned for support in the future.


CLASS METHODS

rate_request()

This method is used to request shipping rate information from online provides. Later querying offline databases may be supported as well. A hash is accepted as input with the following key values:

An object is returned if the query is successful, or 'undef' otherweise.


MULTI-PACKAGE API

Online::UPS Example

 use Business::Shipping;
 use Business::Shipping::Shipment::UPS;
 
 my $shipment = Business::Shipping::Shipment::UPS->new();
 
 $shipment->init(
        from_zip        => '98682',
        to_zip          => '98270',
        service         => 'GNDRES',
        #
        # user_id, etc. needed here.
        #
 );
 $shipment->add_package(
        id              => '0',
        weight          => 5,
 );

 $shipment->add_package(
        id              => '1',
        weight          => 3,
 );
 
 my $rate_request = Business::Shipping::rate_request( shipper => 'Online::UPS' );
 #
 # Add the shipment to the rate request.
 #
 $rate_request->shipment( $shipment );
 $rate_request->submit() or print $rate_request->error();

 print $rate_request->package('0')->get_charges( 'GNDRES' );
 print $rate_request->package('1')->get_charges( 'GNDRES' );
 print $rate_request->get_total_price( 'GNDRES' );


ERROR/DEBUG HANDLING

The 'event_handlers' argument takes a hashref telling Business::Shipping what to do for error, debug, trace, and the like. The value can be one of four options:

 * 'STDERR'
 * 'STDOUT'
 * 'carp'
 * 'croak'

For example:

 $rate_request->init( 
        'event_handlers' => ({ 
                'error' => 'STDOUT',
                'debug' => undef,
                'trace' => undef,
                'debug3' => undef,
        })
 );
 
The default is 'STDERR' for error handling, and nothing for debug/trace 
handling.  The option 'debug3' adds even more verbosity to the debug.  Note 
that you can still access error messages even with no handler, by accessing
the return values of methods.  For example:

 $rate_request->init( %values ) or print $rate_request->error();
        
However, if you don't save the error value before the next call, it could be
overwritten by a new error.