# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

UserTag available_www_shipping Order   only
UserTag available_www_shipping Version 1.5
UserTag available_www_shipping Routine <<EOR
sub {
	my ($only) = @_;
	my $ups;

	if(! $only or $only =~ /ups/i) {
		eval {
			require Business::UPS;
		};
		$ups = $@ ? 0 : 1;
	}
	
	my @ups_modes;
	if($ups) {
		push @ups_modes,
			'1DM' => {type => 'UPS', description => 'Next Day Air Early AM'},
			'1DML' => {type => 'UPS', description => 'Next Day Air Early AM Letter'},
			'1DA' => {type => 'UPS', description => 'Next Day Air'},
			'1DAL' => {type => 'UPS', description => 'Next Day Air Letter'},
			'1DP' => {type => 'UPS', description => 'Next Day Air Saver'},
			'1DPL' => {type => 'UPS', description => 'Next Day Air Saver Letter'},
			'2DM' => {type => 'UPS', description => '2nd Day Air A.M.'},
			'2DA' => {type => 'UPS', description => '2nd Day Air'},
			'2DML' => {type => 'UPS', description => '2nd Day Air A.M. Letter'},
			'2DAL' => {type => 'UPS', description => '2nd Day Air Letter'},
			'3DS' => {type => 'UPS', description => '3 Day Select'},
			'GNDCOM' => {type => 'UPS', description => 'Ground Commercial'},
			'GNDRES' => {type => 'UPS', description => 'Ground Residential'},
			'XPR' => {type => 'UPS', description => 'Worldwide Express'},
			'XDM' => {type => 'UPS', description => 'Worldwide Express Plus'},
			'XPRL' => {type => 'UPS', description => 'Worldwide Express Letter'},
			'XDML' => {type => 'UPS', description => 'Worldwide Express Plus Letter'},
			'XPD' => {type => 'UPS', description => 'Worldwide Expedited'},
		;
	}

	if (wantarray) {
		return @ups_modes;
	}
	else {
		my $out = '';
		my $i;
		for ($i = 0; $i < @ups_modes; $i += 2) {
			my $ref = $ups_modes[$i + 1];
			$out .= qq{UPSE:$ups_modes[$i]\t$ref->{type}: $ref->{description}\n};
		}
		return $out;
	}
}
EOR
