File Coverage

blib/lib/Business/Mondo.pm
Criterion Covered Total %
statement 34 35 97.1
branch 3 6 50.0
condition n/a
subroutine 12 12 100.0
pod 0 5 0.0
total 49 58 84.4


line stmt bran cond sub pod time code
1             package Business::Mondo;
2              
3             =head1 NAME
4              
5             Business::Mondo - DEPRECATED please use Business::Monzo instead
6             (https://api.getmondo.co.uk)
7              
8             =for html
9             <a href='https://travis-ci.org/leejo/business-mondo?branch=master'><img src='https://travis-ci.org/leejo/business-mondo.svg?branch=master' alt='Build Status' /></a>
10             <a href='https://coveralls.io/r/leejo/business-mondo?branch=master'><img src='https://coveralls.io/repos/leejo/business-mondo/badge.png?branch=master' alt='Coverage Status' /></a>
11              
12             =head1 VERSION
13              
14             9999.99
15              
16             =head1 DESCRIPTION
17              
18             Business::Mondo was a library for easy interface to the Mondo banking API,
19             since Mondo have now changed their name to Monzo the namespace of the dist
20             has been updated to L<Business::Monzo> and you should now be using that
21             dist instead.
22              
23             Note the functionality of Business::Mondo remains but may be removed from
24             CPAN at anytime in the future.
25              
26             =cut
27              
28 2     2   81446 use strict;
  2         3  
  2         42  
29 2     2   6 use warnings;
  2         2  
  2         35  
30              
31 2     2   880 use Moo;
  2         15837  
  2         7  
32             with 'Business::Mondo::Version';
33              
34 2     2   2020 use Carp qw/ confess /;
  2         2  
  2         70  
35              
36 2     2   691 use Business::Mondo::Client;
  2         4  
  2         60  
37 2     2   10 use Business::Mondo::Account;
  2         3  
  2         34  
38 2     2   6 use Business::Mondo::Attachment;
  2         3  
  2         692  
39              
40             has [ qw/ token / ] => (
41             is => 'ro',
42             required => 1,
43             );
44              
45             has api_url => (
46             is => 'ro',
47             required => 0,
48             default => sub { $Business::Mondo::API_URL },
49             );
50              
51             has client => (
52             is => 'ro',
53             isa => sub {
54             confess( "$_[0] is not a Business::Mondo::Client" )
55             if ref $_[0] ne 'Business::Mondo::Client';
56             },
57             required => 0,
58             lazy => 1,
59             default => sub {
60             my ( $self ) = @_;
61              
62             # fix any load order issues with Resources requiring a Client
63             $Business::Mondo::Resource::client = Business::Mondo::Client->new(
64             token => $self->token,
65             api_url => $self->api_url,
66             );
67             },
68             );
69              
70             sub transactions {
71 1     1 0 2 my ( $self,%params ) = @_;
72              
73             # transactions requires account_id, whereas transaction doesn't
74             # the Mondo API is a little inconsistent at this point...
75 1 50       4 $params{account_id} || Business::Mondo::Exception->throw({
76             message => "transactions requires params: account_id",
77             });
78              
79             return Business::Mondo::Account->new(
80             client => $self->client,
81             id => $params{account_id},
82 1         20 )->transactions( 'expand[]' => 'merchant' );
83             }
84              
85             sub balance {
86 1     1 0 344 my ( $self,%params ) = @_;
87              
88 1 50       4 $params{account_id} || Business::Mondo::Exception->throw({
89             message => "balance requires params: account_id",
90             });
91              
92             return Business::Mondo::Account->new(
93             client => $self->client,
94             id => $params{account_id},
95 1         21 )->balance( %params );
96             }
97              
98             sub transaction {
99 1     1 0 833 my ( $self,%params ) = @_;
100              
101 1 50       4 if ( my $expand = delete( $params{expand} ) ) {
102 0         0 $params{'expand[]'} = $expand;
103             }
104              
105 1         21 return $self->client->_get_transaction( \%params );
106             }
107              
108             sub accounts {
109 1     1 0 675 my ( $self ) = @_;
110 1         21 return $self->client->_get_accounts;
111             }
112              
113             sub upload_attachment {
114 1     1 0 356 my ( $self,%params ) = @_;
115              
116 1         21 return Business::Mondo::Attachment->new(
117             client => $self->client,
118             )->upload( %params );
119             }
120              
121             =head1 SEE ALSO
122              
123             L<Business::Monzo>
124              
125             =head1 AUTHOR
126              
127             Lee Johnson - C<leejo@cpan.org>
128              
129             =head1 LICENSE
130              
131             This library is free software; you can redistribute it and/or modify it under
132             the same terms as Perl itself. If you would like to contribute documentation,
133             features, bug fixes, or anything else then please raise an issue / pull request:
134              
135             https://github.com/leejo/business-mondo
136              
137             =cut
138              
139             1;
140              
141             # vim: ts=4:sw=4:et