| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | Finance::Bank::IE::AvantCard - Finance::Bank interface for AvantCard (Ireland) | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =cut | ||||||||||||||||||||
| 6 | package Finance::Bank::IE::AvantCard; | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | use base qw( Finance::Bank::IE ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $VERSION = "0.30"; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | ▶ | use HTML::TokeParser; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | my %pages = ( | |||||||||||||||||||
| 17 | login => { | ||||||||||||||||||||
| 18 | url => 'https://onlinebanking.avantcard.ie/Enrolment/Login', | ||||||||||||||||||||
| 19 | sentinel => 'enter your login details below', | ||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||
| 21 | login2 => { | ||||||||||||||||||||
| 22 | url => 'https://onlinebanking.avantcard.ie/Enrolment/Memorable', | ||||||||||||||||||||
| 23 | sentinel => 'Please enter the following characters from your memorable word.', | ||||||||||||||||||||
| 24 | }, | ||||||||||||||||||||
| 25 | accounts => { | ||||||||||||||||||||
| 26 | url => 'https://onlinebanking.avantcard.ie/Overview/Overview', | ||||||||||||||||||||
| 27 | sentinel => 'Overview', | ||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||
| 29 | expired => { | ||||||||||||||||||||
| 30 | url => 'https://onlinebanking.avantcard.ie/Errors/Http450', | ||||||||||||||||||||
| 31 | sentinel => 'Your Online Banking session has expired.', | ||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||
| 33 | sitedown => { | ||||||||||||||||||||
| 34 | sentinel => 'not available at this time', | ||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | # XXX this needs to be everywhere, but have access to %pages | ||||||||||||||||||||
| 39 | 0 | ▶ | sub _pages { | ||||||||||||||||||
|
Subroutine
_pages: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||
| 41 | 0 | return \%pages; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub _submit_first_login_page { | ||||||||||||||||||
|
Subroutine
_submit_first_login_page: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||
| 46 | 0 | ▶ | my $confref = shift || $self->cached_config(); | ||||||||||||||||||
|
Condition0%0/3
shift() || $self->cached_config
MC/DC0%0/2
shift() || $self->cached_config
shift()
$self->cached_config
Truth table0%0/3
A || B
A= shift()B= $self->cached_config
| |||||||||||||||||||||
| 47 | 0 | my $form = $self->_agent()->current_form(); | |||||||||||||||||||
| 48 | 0 | $self->_agent()->field( "UserName", $confref->{user} ); | |||||||||||||||||||
| 49 | 0 | $self->_agent()->field( "Password", $confref->{password}); | |||||||||||||||||||
| 50 | 0 | return $self->_agent()->submit_form(); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | sub _submit_second_login_page { | ||||||||||||||||||
|
Subroutine
_submit_second_login_page: not called CC=7 SCAR=40.3
| |||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||
| 55 | 0 | ▶ | my $confref = shift || $self->cached_config(); | ||||||||||||||||||
|
Condition0%0/3
shift() || $self->cached_config
MC/DC0%0/2
shift() || $self->cached_config
shift()
$self->cached_config
Truth table0%0/3
A || B
A= shift()B= $self->cached_config
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | my $word = $confref->{memorable}; | |||||||||||||||||||
| 58 | 0 | my $content = $self->_agent()->content(); | |||||||||||||||||||
| 59 | 0 | my $parser = new HTML::TokeParser( \$content ); | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | while ( my $tag = $parser->get_tag( "div" )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | ▶ | next unless $tag->[1]{class} eq 'memorableInput'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | ▶ | while ( my $text = $parser->get_trimmed_text("input")) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 0 | my ( $card ) = $text =~ /^(\d+)/; | |||||||||||||||||||
| 65 | 0 | ▶ | if ( !defined( $card )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | 0 | die "unable to get a card out of $text\n"; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | 0 | $tag = $parser->get_tag("input"); | |||||||||||||||||||
| 69 | $self->_agent()->field($tag->[1]{name}, | ||||||||||||||||||||
| 70 | 0 | substr( $word, $card - 1, 1 )); | |||||||||||||||||||
| 71 | 0 | ▶ | last if $tag->[1]{name} eq 'MemorableWords4'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | 0 | return $self->_agent()->submit_form(); | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | sub _parse_account_balance_page { | ||||||||||||||||||
|
Subroutine
_parse_account_balance_page: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||
| 79 | 0 | my $content = $self->_agent()->content(); | |||||||||||||||||||
| 80 | 0 | my $parser = new HTML::TokeParser( \$content ); | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | my @accounts; | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | SELECTS: | ||||||||||||||||||||
| 85 | 0 | ▶ | while ( my $tag = $parser->get_tag( "select" )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | 0 | ▶ | if ( $tag->[1]{id} eq 'CreditCardSelection' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | 0 | ▶ | while ( $tag = $parser->get_tag( "option", "/select" )) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 0 | ▶ | if ( $tag->[0] eq '/select' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 89 | 0 | last SELECTS; | |||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||
| 91 | 0 | my %account; | |||||||||||||||||||
| 92 | 0 | my $detail = $parser->get_trimmed_text("/option"); | |||||||||||||||||||
| 93 | ( $account{nick}, $account{account_no}, | ||||||||||||||||||||
| 94 | $account{status}, $account{balance}, | ||||||||||||||||||||
| 95 | 0 | $account{limit} ) = split( /__+/, $detail ); | |||||||||||||||||||
| 96 | 0 | $account{type} = $account{nick}; | |||||||||||||||||||
| 97 | 0 | $account{currency} = "EUR"; | |||||||||||||||||||
| 98 | 0 | $account{balance} =~ s/[^0-9.]//g; | |||||||||||||||||||
| 99 | 0 | push @accounts, bless \%account, | |||||||||||||||||||
| 100 | "Finance::Bank::IE::AvantCard::Account"; | ||||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | return @accounts; | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | # XXX promote | ||||||||||||||||||||
| 110 | package Finance::Bank::IE::AvantCard::Account; | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 1 | ▶ | no strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 113 | 0 | ▶ | sub AUTOLOAD { my $self=shift; $AUTOLOAD =~ s/.*:://; $self->{$AUTOLOAD} } | ||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 1 | 1; | |||||||||||||||||||