The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::Shipping::RateRequest - Abstract class

DESCRIPTION

Abstract Class: real implementations are done in subclasses.

Represents a request for shipping cost estimation.

METHODS

$rate_request->is_success()

Boolean. 1 = Rate Request was successful.

$rate_request->cache()

Boolean. 1 = Save results using CHI, and reload them if an identical request is made later. See submit() for implementation details.

$rate_request->cache_config()

Allows configuration of CHI cache. Pass it a hash reference of a CHI config. Defaults to {driver = 'File'}>.

 $rate_request->cache_config({ driver => 'Memory', global => 1 });

$rate_request->invalid()

Boolean. 1 = Rate request was invalid, because user supplied invalid data. This can be useful in determining whether or not to log incident reports (see UserTag/business-shipping.tag for an example implementation).

$rate_request->results()

Hashref. Stores the results of a rate request, for example:

 {
   'UPS' => [ 
              { 
                id      => 1,
                charges => 10.50
              },
              { 
                id      => 2,
                charges => 23.00
              }
            ]
 }
                

See _handle_response() for implementation details.

$rate_request->shipment()

Stores a Business::Shipping::Shipment object. Many methods are forwarded to it. At this time, each RateRequest only has one Shipment.

$rate_request->error_details()

Arrayref. Stores the error results of a rate request. There can be multiple errors for one request. Each entry in the array represents an error. Each error is a hashref with the following keys:

 error_code     : The error code
 error_msg      : A description error message

Additional keys may be added by the shipper class.

$rate_request->execute()

This method sets some values (optional), executes the request, then parses the results.

$rate_request->validate()

Does some validation common to all RateRequest objects, but most of the validation goes on in the subclass.

$rate_request->get_unique_hash()

Calls unique() on all subclasses to determine a list of unique elements.

Returns a hash of element_name => element_value. Used by gen_unique_key().

$rate_request->hash_to_sorted_values()

Sorts hash alphabetically, then returns just the values. (So that the key will have the values sorted in the same order always).

$rate_request->gen_unique_key( )

Calls get_unique_hash(), sorts them with hash_to_sorted_values(), then returns them in string format.

$rate_request->rate()

Iterates the $self->results hash and sums the charges from each package->charges. Returns the total.

Example of what the results look like:

 [
     { 
         name => 'UPS_Online',
         rates   => [
                        {
                            code        => '03',
                            short_name  => 'GNDRES',
                            name        => 'Ground Residential',
                            est_deliv   => 4,
                            charges     => 5.32,
                            charges_formatted => '$5.32',
                        },
                    ]
     }
 ];

$rate_request->get_unique_keys()

$rate_request->_gen_unique_values()

$rate_request->calc_debug_string()

Arrange the values of some important variables in a pretty format. Return a scalar string.

$rate_request->display_price_components()

Return formatted string of price component information

AUTHOR

Daniel Browning, db@kavod.com, http://www.kavod.com/

COPYRIGHT AND LICENCE

Copyright 2003-2011 Daniel Browning <db@kavod.com>. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. See LICENSE for more info.