Finance::Bank::Cahoot - Check your Cahoot bank accounts from Perl
This module provides a rudimentary interface to the Cahoot online banking system at https://www.cahoot.com/. You will need either Crypt::SSLeay or IO::Socket::SSL installed for HTTPS support to work with WWW::Mechanize.
https://www.cahoot.com/
Crypt::SSLeay
IO::Socket::SSL
my $cahoot = Finance::Bank::Cahoot->new(credentials => 'Constant', credentials_options => { account => '12345678', password => 'verysecret', place => 'London', date => '01/01/1906', username => 'dummy', maiden => 'Smith' } ); my $accounts = $cahoot->accounts; $cahoot->set_account($accounts->[0]->{account}); my $snapshot = $cahoot->snapshot; foreach my $row (@$snapshot) { print join ',', @$row; print "\n"; }
Create a new instance of a connection to the Cahoot server.
new can be called in two different ways. It can take a single parameter, credentials, which will accept an already created credentials object, of type Finance::Bank::Cahoot::CredentialsProvider::*. Alternatively, it can take two parameters, credentials and credentials_options. In this case credentials is the name of a credentials class to create an instance of, and credentials_options is a hash of the options to pass-through to the constructor of the chosen class.
new
credentials
Finance::Bank::Cahoot::CredentialsProvider::*
credentials_options
If the second form of new is being used, and the chosen class is not one of the ones supplied as standard then it will need to be required first.
required
If any errors occur then new will croak.
croak
my $cahoot = Finance::Bank::Cahoot->new(credentials => 'Constant', credentials_options => { account => '12345678', password => 'verysecret', place => 'London', date => '01/01/1906', username => 'dummy', maiden => 'Smith' } ); # Or create the credentials object ourselves my $credentials = Finance::Bank::Cahoot::CredentialsProvider::Constant->new( account => '12345678', password => 'verysecret', place => 'London', date => '01/01/1906', username => 'dummy', maiden => 'Smith' } ); my $cahoot = Finance::Bank::Cahoot->new(credentials => $credentials);
Login to the Cahoot server using the credentials supplied to new. This method is implicit for all data access methods, so typically does not need to be called explicitly. The method takes no arguments and will only call one of memorable place, date or mother's maiden name as expected by the Cahoot portal.
Returns a list reference containing a summary of any accounts available from the supplied credentials. If a login has yet to occur accounts will automatically do this.
accounts
my $accounts = $cahoot->accounts;
Each item in the list is a hash reference that holds summary information for a single account, and contains this data:
Select an account for data retrieval using an 8-digit account number. If a login has yet to occur or a list of accounts has yet to be retrieved, set_account will automatically do this and cache the results.
set_account
my @accounts = $cahoot->accounts; $cahoot->set_account($accounts->[0]->{account}); # Or without first loading a list of accounts $cahoot->set_account('12345678);
Returns a list reference containing a summary of all statements available for an account. When called with the optional parameter containing an 8-digit account number, statements will automatically login (if required) and select that account.
statements
If no account has been selected and no account is supplied by the caller, statements will croak.
Each item in the returned list is a hash reference that holds summary information for a single statement, and contains this data:
DD/MM/YY - DD/MM/YY
time
Select a statement for data retrieval using a statement description previously returned from statements. The text description of the statement must be supplied as a parameter to the method and an account must have been selected using set_account. If no account has been selected or no statement name is supplied by the caller, statement will croak.
statement
$cahoot->set_account('12345678); my $statements = $cahoot->statements; $cahoot->set_statement($statements->[0]->{description});
Return a list of direct debits currently active on the account. An optional account parameter may be supplied as an 8-digit account number. If no account has previously been selected or no account number is supplied, debits will croak. The return value is a reference to a list of Finance::Bank::Cahoot::DirectDebit objects. Each entry in the list is a single direct debit.
debits
Finance::Bank::Cahoot::DirectDebit
$cahoot->set_account('12345678'); my $debits = $cahoot->debits; foreach my $debit (@$debits) { print $debit->payee, q{,}, $debit->reference, q{,}, $debit->amount || 0, q{,}, $debit->date || 0, q{,}, $debit->frequency || 0, qq{\n}; }
Return a table of transactions from the account snapshot. An optional account parameter may be supplied as an 8-digit account number. If no account has previously been selected or no account number is supplied, snapshot will croak. The return value is a reference to a list of list references. Each entry in the top-level list is a row in the statement and the rows are data from the account in the order date, description, amount withdrawn, amount paid in.
snapshot
$cahoot->set_account('12345678'); my $snapshot = $cahoot->snapshot; foreach my $row (@$snapshot) { print join ',', @$row; print "\n"; }
Return a table of transactions from a selected statement. An optional account parameter may be supplied as an 8-digit account number. If no account has previously been selected or no account number is supplied, statement will croak. The return value is a reference to a list of Finance::Bank::Cahoot::Statement::Entry objects. Each entry in list is a row in the statement.
Finance::Bank::Cahoot::Statement::Entry
$cahoot->set_account('12345678'); my $statement = $cahoot->statement; foreach my $transaction (@$statement) { print $transaction->date, q{,}, $transaction->details, q{,}, $transaction->credit || 0, q{,}, $transaction->debit || 0, q{,}, $transaction->balance || 0, qq{\n}; }
This warning is from Simon Cozens' Finance::Bank::LloydsTSB, and seems just as apt here.
Finance::Bank::LloydsTSB
This is code for online banking, and that means your money, and that means BE CAREFUL. You are encouraged, nay, expected, to audit the source of this module yourself to reassure yourself that I am not doing anything untoward with your banking data. This software is useful to me, but is provided under NO GUARANTEE, explicit or implied.
This has only been tested on my own accounts. I imagine it should work on any account types, but I can't guarantee this.
Jon Connell <jon@figsandfudge.com>
This module borrows heavily from Finance::Bank::Natwest by Jody Belka.
Copyright 2008 by Jon Connell Copyright 2003 by Jody Belka
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Finance::Bank::Cahoot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Bank::Cahoot
CPAN shell
perl -MCPAN -e shell install Finance::Bank::Cahoot
For more information on module installation, please visit the detailed CPAN module installation guide.