Business-FedEx-DirectConnect
view release on metacpan or search on metacpan
DirectConnect.pm view on Meta::CPAN
This method will accept a valid FedEx UTI number and a hash of values. The first
arg must be a valid UTI. Using these values set_data will construct and return a
valid FedEx request string.
Assuming you pass a valid FedEx UTI this method will find the correct
Transaction Number for you. You need not pass this in. Also no need to pass in your
FedEx Account Number or Meter Number. You should pass these when creating a new
Business::FedEx::DirectConnect object.
This method will allow you to use either the number field provided in the FedEx
documentation or the hash (case insensitive) %FE_RE found in Business::FedEx::Constants.
If the hash key you pass is not present in Business::FedEx::Constants you will
be warned.
Here is a tracking example where 29 is the "tracking number" field FedEx has
provided.
$t->set_data(5000, 'tracking_number'=>'836603877972') or die $t->errstr;
is the same as
$t->set_data(5000, 29 =>'836603877972') or die $t->errstr;
=item $t->get_data($field_name_or_tag...)
This method returns data set with C<$t-E<gt>set_data>. With no args it
returns a reference to the underlying hash, otherwise it returns the
corresponding values.
=item $t->has_required(UTI)
Check the required fields and return an array of missing fields if any. Currently, this
function only does a simple check on most common fields. There are conditional fields that will
be added later. For example, if the ship_date > today you will be required to pass
a future_day_shipment flag. This function does not have this level of functionality yet.
=item $t->required(UTI)
Method to return the required fields for a given FedEx UTI.
=item $t->transaction()
Send transaction to FedEx. Optionally you can pass the full request string if you choose not to use
the set_data method. Returns the full reply from FedEx.
=item $t->label('someLabel.png')
This method will decode the binary image data from FedEx and save it to a file.
If nothing is passed the binary data string will be returned. You can also pass an image
key if binary data is stored in a different field. The default is 188 for FedEx labels.
For example, if you wanted to access a COD buffer stream you would pass a 411.
$t->label('COD.png', 411);
=item $t->lookup('tracking_number')
This method will return the value for an item returned from FedEx. Refer to
the C<Business::FedEx::Constants> %FE_RE hash to see all possible values.
=item $t->rbuf()
Returns the decoded string portion of the FedEx reply.
=item $t->hash_ret()
Returns a hash of the FedEx reply values
my $stuff= $t->hash_ret;
foreach (keys %{$stuff}) {
print $_. ' => ' . $stuff->{$_} . "\n";
}
=item $t->errstr()
Returns an error code and message
$t->transaction() || die 'Error: '.$t->errstr();
=item $t->errcode()
Returns just an error code, useful for programatic handling of errors. Note that
the return code is alphanumeric (and not just a number).
if (!$t->transaction())
{
if ($t->errcode() eq '0038') # 0038 is an invalid tracking number
{
[..code relating to an invalid tracking number..]
}
}
=item $t->user_data(I<new_data>)
The object provides a place for you to store a scalar. This method
optionally sets it to the value you specify, and returns the old value.
=back
=head1 ERRORS/BUGS
=over 4
=item Request Error: 501 Protocol scheme 'https' is not supported
This will occur if your LWP does not support SSL (i.e. https). I suggest
installing the L<Crypt::SSLeay> module.
=back
=head1 IDEAS/TODO
Build methods for each type of transaction so you don't need to
know UTIs and other FedEx codes. FedEx Express Ship-A-Package UTI 2016
would be called via $object->FDXE_ship();
Build for multiple request. FedEx currently can only accept
one transaction per request. I might try something with LWP::Parallel::UserAgent.
Better parsing for the FedEx return data.
=head1 AUTHOR
( run in 1.162 second using v1.01-cache-2.11-cpan-7fcb06a456a )