| 1 | package Business::PhoneBill::Allopass::Infos; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | $VERSION = "1.01"; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | Billing::Allopass::Infos - A simple class for infos retrieving from provided Allopass HTML code | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | use Business::PhoneBill::Allopass::Infos; | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | my $ap='<table... .../table>'; # Allopass HTML code | ||||||||||||||||||||||||||||||||||||||||||
| 16 | my $hapnfo=Business::PhoneBill::Allopass::Infos->new(\$ap); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | print $hapnfo->doc_id; | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =item B<new> - Class constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | Business::PhoneBill::Allopass::Infos->new($ap); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | OR | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | Business::PhoneBill::Allopass::Infos->new(\$ap); # Prefered way | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $class=shift; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $ap =shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $self={ | |||||||||||||||||||||||||||||||||||||||||
| 42 | paliers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | site_id => '', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | doc_id => '', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | cc_acc => '', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self=bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->_parse($ap); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | =head1 PROPERTIES | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | =item B<site_id> - Retrieves the site id. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =item B<doc_id> - Retrieves the document id. | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | =item B<paliers> - Array of countries. | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =item B<palier> - Provides ID for given country. | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub site_id {shift->{site_id}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
site_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub doc_id {shift->{doc_id}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub paliers { (keys %{shift->{paliers}}) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paliers: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub palier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
palier: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $pays=shift || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $self->{paliers}{lc($pays)} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =item B<link_num> gives the Allopass's call number page http address for given country | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub link_num { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
link_num: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my $pays=shift || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return '' unless $self->{paliers}{lc($pays)}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | 'http://www.allopass.com/show_accessv2.php4?PALIER='.$self->{paliers}{lc($pays)}.'&SITE_ID='.$self->{site_id}.'&DOC_ID='.$self->{doc_id}; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =item B<link_cc> gives the Allopass's credit card page http address for given language | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub link_cc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
link_cc: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $lang=shift || ''; $lang=_fix_lang($lang); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return '' unless $self->{cc_acc}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | # 'https://secure.allopass.com/show_ccard.php4?LG=FR&SITE_ID='.$self->{site_id}.'&DOC_ID='.$self->{doc_id}; | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | 'https://secure.allopass.com/show_ccard.php4?LG='.$lang.'&SITE_ID='.$self->{site_id}.'&DOC_ID='.$self->{doc_id}; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | Bernard Nauwelaerts <bpn#it-development%be> | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | GPL. Enjoy ! | ||||||||||||||||||||||||||||||||||||||||||
| 116 | See COPYING for further informations on the GPL. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | ### Private -------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $ap =shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $ap=$$ap if ref $ap; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $ap=~s/\n//g; $ap=~s/\/a>/\/a>\n/g; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | foreach (split(/\n/, $ap)) { | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (m!http://www.allopass.com/show_accessv2.php4\?PALIER=(\d+)?\&SITE_ID=(\d+)?\&DOC_ID=(\d+)?\&LG=(..)','phone'.*?><img .*? src="http://www.allopass.com/imgweb/common/flag_(..)?.gif".*?></a>!) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->{paliers}{lc($5)} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->{site_id}=$2; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $self->{doc_id}=$3; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } elsif (m!https://secure.allopass.com/show_ccard.php4\?LG=..&SITE_ID=(\d+)?\&DOC_ID=(\d+)?!) { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->{cc_acc}=1; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | ### Piske c cretins affichent une page vide pour l'achat de codes par carte bancaire si la lang n'est pas bonne :-( | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub _fix_lang { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fix_lang: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $lang=shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $lang=uc($lang); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($lang eq 'FR' || $lang eq 'ES' || $lang eq 'UK') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$lang eq "FR" or $lang eq "ES" or $lang eq "UK"
$lang eq "FR" or $lang eq "ES"
MC/DC0%0/3
$lang eq "FR" or $lang eq "ES" or $lang eq "UK"
$lang eq "FR"
$lang eq "ES"
$lang eq "UK"
Truth table0%0/4
A or B or C
A= $lang eq "FR"B= $lang eq "ES"C= $lang eq "UK"
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $lang; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 'UK' | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||