Remove legacy DHL code. (#4450)

master
PJ Hampton 2017-08-21 21:08:15 +01:00 committed by Zaahir Moolla
parent c932b6a7a5
commit dea0663089
2 changed files with 0 additions and 102 deletions

View File

@ -1,71 +0,0 @@
package DDG::Goodie::DHL;
# ABSTRACT: track a package through DHL.
use strict;
use DDG::Goodie;
zci is_cached => 1;
zci answer_type => "dhl";
# Regex for usps.
my $dhl_qr = qr/dhl/io;
my $tracking_qr = qr/package|track(?:ing|)|num(?:ber|)|\#/i;
triggers query_nowhitespace_nodash => qr/
^$dhl_qr.*?([\d]{9,})$|
^([\d]{9,}).*?$dhl_qr$|
^(?:$tracking_qr|$dhl_qr|)*([\d]{10})(?:$tracking_qr|$dhl_qr|)*$
/xo;
handle query_nowhitespace_nodash => sub {
# If a Canada Post package number (2 for exclusively).
my $is_dhl = 0;
# Tracking number.
my $package_number = '';
# Exclsuive trigger.
if ($1 || $2) {
$package_number = $1 || $2;
$is_dhl = 2;
}
elsif ($3) {
$package_number = $3;
my $checksum = 0;
my @chars = split( //, $package_number );
my $length = scalar(@chars);
my $char_count = 0;
my $odd_sum = 0;
my $even_sum = 0;
foreach my $char (@chars) {
$char_count++;
if ($char_count % 2 == 0) {
$even_sum += $char;
}
else {
$odd_sum += $char;
}
}
$even_sum *= 1;
$odd_sum *= 1;
# $checksum = ($odd_sum+$even_sum) % 7;
# $checksum = 10-$checksum if $checksum;
$checksum = join( '', @chars[ 0 .. $length - 2 ] ) % 7;
if ($checksum eq $chars[-1]) {
$is_dhl = 1;
}
}
if ($is_dhl) {
return $package_number, heading => "DHL Shipment Tracking", html => "Track this shipment at <a href='http://www.dhl-usa.com/content/us/en/express/tracking.shtml?brand=DHL&AWB=$package_number'>DHL</a>.";
}
return;
};
1;

31
t/DHL.t
View File

@ -1,31 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Deep;
use DDG::Test::Goodie;
zci answer_type => 'dhl';
zci is_cached => 1;
ddg_goodie_test(
[qw( DDG::Goodie::DHL )],
'dhl 123456789' => test_zci(
"123456789",
heading => 'DHL Shipment Tracking',
html => qq(Track this shipment at <a href='http://www.dhl-usa.com/content/us/en/express/tracking.shtml?brand=DHL&AWB=123456789'>DHL</a>.)
),
'tracking 1234567891' => test_zci(
"1234567891",
heading => 'DHL Shipment Tracking',
html => qq(Track this shipment at <a href='http://www.dhl-usa.com/content/us/en/express/tracking.shtml?brand=DHL&AWB=1234567891'>DHL</a>.)
),
'DHL 123456789' => test_zci(
'123456789',
heading => 'DHL Shipment Tracking',
html => "Track this shipment at <a href='http://www.dhl-usa.com/content/us/en/express/tracking.shtml?brand=DHL&AWB=123456789'>DHL</a>.",
),
);
done_testing;