Shipment::Base
version 3.10
This module does not DO anything, but can be extended to create a real interface for a shipping service.
package Shipment::SomeShippingService; use Moose; extends 'Shipment::Base'; sub ship { # routine to ship something somewhere via some shipping service } no Moose;
which can then be used to actually DO stuff:
use Shipment::SomeShippingService; use Shipment::Address; use Shipment::Package; my $shipment = Shipment::SomeShippingService->new( from_address => Shipment::Address->new( ... ), to_address => Shipment::Address->new( ... ), packages => [ Shipment::Package->new( ... ), ], ); $shipment->ship( 'ground' );
Shipment::Base - base class for a shipping module
This is a base class for a shipping service such as UPS or FedEx.
Where the shipment is being shipped from and to
type: Shipment::Address
The shipper's account number
type: String
The billing account number
defaults to the account
The billing address (typically not needed)
Who to bill for the shipment (sender, recipient, third_party)
type: BillingOptions
default: sender
Whether the shipment will be picked up or dropped off (most shipping services have multiple pickup options)
type: PickupOptions
default: pickup
Defines the kind of label that will be generated (i.e. pdf, thermal, image)
type: Str
default: pdf
Whether a signature confirmation is required, and what type (default, required, not_required, adult)
type: SignatureOptions
default: default (the default setting for the chosen service)
The type of packaging used (custom, envelope, tube, box, pack)
type: PackageOptions
default: custom
The list of individual packages being shipped
type: ArrayRef[Shipment::Package]
methods handled: all_packages # returns a list of Shipment::Package get_package(index) # returns a Shipment::Package add_package(Shipment::Package) count_packages # returns the number of packages
What units we're dealing with for weight and dimensions (lb, kg and in, cm)
default: lb, in (pounds and inches)
What currency we're dealing with (USD,CAD, etc)
default: USD
The total value of the shipment to be insured
type: Data::Currency
The total value of the shipment
When the shipment will be ready for pickup
type: DateAndTime
The available services
type: HashRef[Shipment::Service]
methods handled: all_services # returns a list of Shipment::Service
Details of what was returned from a call to rate
type: Shipment::Service
The tracking_id returned from a call to ship OR the tracking_id to be used in a call to cancel or track
The tracking activities returned from a call to track
most recent tracking status
ship_date is when the shipment was passed off to the carrier, set by a call to track
All documents for a shipment including all labels
type: Shipment::Label
The manifest document (usually generated by an end of day close, but may also be generated on a per shipment basis)
turn debugging on 1 == warnings for notices and errors >1 == warnings for raw response xml
The last error generated by a method. Should only be non-empty if a method was unsuccessful.
The last warning/alert/notice generated by a method.
The references for the shipment
type: ArrayRef[String]
methods handled: all_references get_reference(index) add_reference($reference) count_references # returns the number of reference strings
Special Delivery Instructions
If available, add a carbon offset charge for the shipment
type: Bool
The routine which compiles a list of available shipping services for from and to addresses.
foreach my $service ( $shipment->all_services ) { print $service->name . "\n"; }
Standard services - ground, express, priority - can be mapped to actual service id's
print $shipment->services->{ground}->id . "\n";
The routine that fetches a detailed rate for a given service type
$shipment->rate( 'ground' ); print $shipment->service->cost . "\n"; print $shipment->service->etd . "\n";
The routine that creates a shipment/label
$shipment->ship( 'ground' ); $shipment->get_package(0)->label->save;
The routine that creates a return shipment
$shipment->return( 'ground' );
The routine that cancels a shipment
$shipment->tracking_id( '12345' ); $shipment->cancel;
The routine that runs end of day close
$shipment->end_of_day;
The routine that fetches tracking information
$shipment->tracking_id( '12345' ); $shipment->track;
In the pre-Moo era Shipment used MooseX::Types::DateTime::ButMaintained for DateTime types but now we use MooX::Types::MooseLike::DateTime which does not do coercion for us.
This method provides coercion for DateTime/DateAndTime types in the way existing code expects it to work so we don't break anything.
Andrew Baerg @ <andrew at pullingshots dot ca>
http://pullingshots.ca/
Issues can be submitted at https://github.com/pullingshots/Shipment/issues
Copyright (C) 2016 Andrew J Baerg, All Rights Reserved
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Andrew Baerg <baergaj@cpan.org>
This software is copyright (c) 2018 by Andrew Baerg.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Shipment, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Shipment
CPAN shell
perl -MCPAN -e shell install Shipment
For more information on module installation, please visit the detailed CPAN module installation guide.