NAME
Business::Shipping::RateRequest - Abstract class
VERSION
$Rev: 306 $
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 Cache::FileCache, and reload them if an identical request is made later. See submit() for implementation details.
$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
Dan Browning <db@kavod.com>, Kavod Technologies, http://www.kavod.com.
COPYRIGHT AND LICENCE
Copyright (c) 2003-2004 Kavod Technologies, Dan Browning. 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.