blib/lib/Finance/Bank/ES/Cajamadrid.pm

filter: Statementstmt 44.1% 19 / 43 Branchbran 14.2% 2 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 38.4% 25 / 65 SCAR 27.1
CC
6
Cov
37%
check_balances
20.0
ver_saldos
12.0
BEGIN
1.0
CRAP 15.1
↑ Summary
1 package Finance::Bank::ES::Cajamadrid;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use WWW::Mechanize;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 our $VERSION='0.04';
8
9
10 # hackery for https proxy support, inspired by Finance::Bank::Barclays
11 # thanks Dave Holland!
12 1 my $https_proxy=$ENV{https_proxy};
13 1 ▶delete $ENV{https_proxy} if($https_proxy);
Branch: 1 branch
BranchTrueFalseTotal
if $https_proxy 0 1 1
14 1 our $browser = WWW::Mechanize->new(env_proxy=>1);
15 1 $browser->env_proxy; # Load proxy settings (but not the https proxy)
16 1 ▶$ENV{https_proxy}=$https_proxy if($https_proxy);
Branch: 1 branch
BranchTrueFalseTotal
if $https_proxy 0 1 1
17
18 sub check_balances {
19 0 ▶ my ($class,%opts)=@_;
Subroutine check_balances: not called CC=4 SCAR=30.0
Pod undocumented
20 0 ▶ croak "Must provide a DNI number" unless exists $opts{dni};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"dni"} 0 0 0
21 0 ▶ croak "Must provide a PIN" unless exists $opts{pin};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"pin"} 0 0 0
22 0 my $base="https://oi.cajamadrid.es";
23 0 my $re='<tr><td class=oiparialgrissin><a class=enlaceverdeabajo .*?;">(\d+)&nbsp;.*?<td class=oiparialgrissin align=right>(.*?)&nbsp;Euros</td>.*?</tr>';
24 0 my $self=bless { %opts }, $class;
25 0 $browser->quiet(1);
26 0 $browser->agent_alias("Windows IE 6");
27 0 $browser->get("$base/CajaMadrid/oi/pt_oi/Login/login");
28 0 $browser->form('f1');
29 0 $browser->field("Documento_s", $opts{dni});
30 0 $browser->field("ClaveAcceso_s", $opts{pin});
31 0 my $r=$browser->submit();
32 0 $browser->form('f_lanzar')
33 ->action("$base/CajaMadrid/oi/puente_oi?pagina=5950&tran=0");
34 0 $r=$browser->submit();
35 0 my $datos=$r->content;
36 0 my @cuentas=();
37 0 ▶ while ($datos=~m{$re}gs){
Branch: 1 branch
BranchTrueFalseTotal
if ($datos =~ /$re/gs) 0 0 0
38 0 push @cuentas,( { numero => $1,
39 saldo => $2 } );
40 }
41 0 return @cuentas;
42 }
43 sub ver_saldos {
44 0 ▶ my ($class,%opts)=@_;
Subroutine ver_saldos: not called CC=3 SCAR=24.8
Pod undocumented
45 0 ▶ croak "Debe proporcionar un DNI" unless exists $opts{dni};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"dni"} 0 0 0
46 0 ▶ croak "Debe proporcionar un PIN" unless exists $opts{pin};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"pin"} 0 0 0
47 0 return &check_balances($class,%opts);
48 }
49 1 1;
50 __END__
↑ Summary