Subject: | full statement support |
Generally 2-3 pages of entries are made available by the web interface, but the statement method currently only grabs the most recent. The way the web interface works is a bit bizarre; once you've visited the HTML view of each of the previous pages (in reverse order), the statement.stm link has all the data without needing any parameter changes.
This patch adds an option $full parameter to the statement method, which if set causes it to visit the links before grabbing the statement.stm data.
diff -urN Finance-Bank-LloydsTSB-1.01/Changes Finance-Bank-LloydsTSB-1.01gs/Changes
--- Finance-Bank-LloydsTSB-1.01/Changes Mon Jun 10 17:33:50 2002
+++ Finance-Bank-LloydsTSB-1.01gs/Changes Mon Jan 27 23:54:10 2003
@@ -1,5 +1,9 @@
Revision history for Perl extension Finance::Bank::LloydsTSB.
+1.01gs Mon Jan 27 11:36:17 2003
+ - added option "full" parameter to "statement" method to
+ get all entries
+
1.01 Mon Jun 10 17:26:54 2002
- added the "statement" method.
diff -urN Finance-Bank-LloydsTSB-1.01/LloydsTSB.pm Finance-Bank-LloydsTSB-1.01gs/LloydsTSB.pm
--- Finance-Bank-LloydsTSB-1.01/LloydsTSB.pm Mon Jun 10 17:33:37 2002
+++ Finance-Bank-LloydsTSB-1.01gs/LloydsTSB.pm Mon Jan 27 23:53:18 2003
@@ -1,7 +1,7 @@
package Finance::Bank::LloydsTSB;
use strict;
use Carp;
-our $VERSION = '1.01';
+our $VERSION = '1.01gs';
use LWP::UserAgent;
our $ua = LWP::UserAgent->new(
env_proxy => 1,
@@ -77,11 +77,17 @@
sub statement {
my $ac = shift;
+ my $full = shift || 0;
my $code;
($code = $ac->sort_code.$ac->account_no) =~ s/\D//g;
my $stm = $Finance::Bank::LloydsTSB::ua->get("https://online.lloydstsb.co.uk/statement.ibc?Account=$code");
+ if($full) {
+ while($stm->content=~m{<a title=\"View your current statement and any previous pages\" href=\"(https://online\.lloydstsb\.co\.uk/statement\.ibc\?Account=\d+\&PageRequired=\d+)\">}) {
+ $stm=$Finance::Bank::LloydsTSB::ua->get($1);
+ }
+ }
$stm = $Finance::Bank::LloydsTSB::ua->get("https://online.lloydstsb.co.uk/statment.stm?Account=$code");
- croak unless $stm->is_success;
+ croak() unless $stm->is_success;
return $stm->content;
}
@@ -127,7 +133,7 @@
sub end()
{
- my ($self,$tag) = @_;
+y my ($self,$tag) = @_;
$intable-- if($tag eq 'table');
if($tag eq 'td')
{
@@ -143,7 +149,6 @@
1;
__END__
-# Below is stub documentation for your module. You better edit it!
=head1 NAME
@@ -185,10 +190,13 @@
Return the balance as a signed floating point value.
- $ac->statement
+ $ac->statement([$full])
Return a mini-statement as a line-separated list of transactions.
-Each transaction is a comma-separated list. B<WARNING>: this interface
+Each transaction is a comma-separated list. If $full is set, all
+available entries will be returned (there is a performance cost in
+doing this). Otherwise, only the most recent page of entries are
+returned. B<WARNING>: this interface
is currently only useful for display, and hence may change in later
versions of this module.