Business-Monzo
view release on metacpan or search on metacpan
t/business/monzo.t view on Meta::CPAN
is( $Monzo->client->api_patch,'PATCH','api_patch' );
done_testing();
sub test_transaction {
my ( $Monzo,$mock,$proxy_mock ) = @_;
note( "Transaction" );
$mock->mock( 'json',sub { _transaction_json() } );
isa_ok(
my $Transaction = $Monzo->transaction( id => 1 ),
'Business::Monzo::Transaction'
);
$mock->mock( 'json',sub { _transactions_json() } );
isa_ok(
$Transaction = ( $Monzo->transactions( account_id => 1 ) )[1],
'Business::Monzo::Transaction'
);
}
sub test_account {
my ( $Monzo,$mock,$proxy_mock ) = @_;
note( "Account" );
$mock->mock( 'json',sub { _accounts_json() } );
isa_ok(
my $Account = ( $Monzo->accounts )[1],
'Business::Monzo::Account'
);
ok $proxy_mock->called('detect'), 'UA is lazily built and proxy detected first time';
$proxy_mock->clear;
}
sub test_balance {
my ( $Monzo,$mock,$proxy_mock ) = @_;
$mock->mock( 'json',sub { _balance_json() } );
isa_ok(
$Monzo->balance( account_id => 1 ),
'Business::Monzo::Balance'
);
ok !$proxy_mock->called('detect'), 'UA is reused and proxy not redetected on subsequent runs';
$proxy_mock->clear;
}
sub test_attachment {
my ( $Monzo,$mock,$proxy_mock ) = @_;
isa_ok(
$Monzo->upload_attachment(
file_name => 'foo.png',
file_type => 'image/png',
),
'Business::Monzo::Attachment'
);
ok !$proxy_mock->called('detect'), 'UA is reused and proxy not redetected on subsequent runs';
$proxy_mock->clear;
}
sub _transaction_json {
return decode_json( qq{{
"transaction": {
"account_balance": 13013,
"amount": -510,
"created": "2015-08-22T12:20:18Z",
"currency": "GBP",
"description": "THE DE BEAUVOIR DELI C LONDON GBR",
"id": "tx_00008zIcpb1TB4yeIFXMzx",
"merchant": {
"address": {
"address": "98 Southgate Road",
"city": "London",
"country": "GB",
"latitude": 51.54151,
"longitude": -0.08482400000002599,
"postcode": "N1 3JD",
"region": "Greater London"
},
"created": "2015-08-22T12:20:18Z",
"group_id": "grp_00008zIcpbBOaAr7TTP3sv",
"id": "merch_00008zIcpbAKe8shBxXUtl",
"logo": "https://pbs.twimg.com/profile_images/527043602623389696/68_SgUWJ.jpeg",
"emoji": "ð",
"name": "The De Beauvoir Deli Co.",
"category": "eating_out"
},
"metadata": {},
"notes": "Salmon sandwich ð",
"is_load": false,
"settled": "2015-08-23T12:20:18Z"
}
}} );
}
sub _transactions_json {
return decode_json( qq{{
"transactions": [
{
"account_balance": 13013,
"amount": -510,
"created": "2015-08-22T12:20:18Z",
"currency": "GBP",
"description": "THE DE BEAUVOIR DELI C LONDON GBR",
"id": "tx_00008zIcpb1TB4yeIFXMzx",
"merchant": "merch_00008zIcpbAKe8shBxXUtl",
"metadata": {},
"notes": "Salmon sandwich ð",
( run in 0.892 second using v1.01-cache-2.11-cpan-b16cb0d3907 )