#! /usr/bin/perl

use strict;
use warnings;

use Finance::Bank::Cahoot;

my $cahoot = Finance::Bank::Cahoot->new(
               credentials => 'ReadLine',
	       credentials_options => { account => '12345678',
					username => 'acmeuser' });
my $accounts = $cahoot->accounts;
foreach my $account (@$accounts) {
  next unless $account->{name} =~ /current/;
  $cahoot->set_account($account->{account});
  my $snapshot = $cahoot->snapshot;
  foreach my $transaction (@$snapshot) {
    print $transaction->date, q{,},
          $transaction->details, q{,},
          $transaction->credit || 0, q{,},
          $transaction->debit || 0, qq{\n};
  }
}
