Monzo/Balance.pm

filter: Statementstmt 100% 31 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 40 / 40 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Monzo/Address.pm ↑ Summary Monzo/Version.pm »
1 package Business::Monzo::Balance;
2  
3 =head1 NAME
4  
5 Business::Monzo::Balance
6  
7 =head1 DESCRIPTION
8  
9 A class for a Monzo balance, extends L<Business::Monzo::Resource>
10  
11 =cut
12  
13 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 extends 'Business::Monzo::Resource';
18 11 with 'Business::Monzo::Utils';
19 11 with 'Business::Monzo::Currency';
20  
21 11 ▶use Types::Standard qw/ :all /;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 11 ▶use Business::Monzo::Merchant;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 11 ▶use DateTime::Format::DateParse;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 =head1 ATTRIBUTES
26  
27 The Balance class has the following attributes (with their type).
28  
29 account_id (Str)
30 balance (Int)
31 spend_today (Int)
32 currency (Data::Currency)
33  
34 Note that when a Str is passed to ->currency this will be coerced to a
35 Data::Currency object,
36  
37 =cut
38  
39 11 has [ qw/ account_id / ] => (
40 is => 'ro',
41 isa => Str,
42 required => 1,
43 );
44  
45 11 has [ qw/ balance spend_today / ] => (
46 is => 'ro',
47 isa => Int,
48 );
49  
50 has [ qw/ url / ] => (
51 is => 'ro',
52 lazy => 1,
53 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
54 1 my ( $self ) = @_;
55 1 return $self->client->api_url . '/balance?account_id=' . $self->account_id;
56 },
57 11 );
58  
59 =head1 Operations on an transaction
60  
61 =head2 get
62  
63 Returns a new instance of the object with the attributes populated
64 having called the Monzo API
65  
66 $Balance = $Balance->get;
67  
68 =cut
69  
70 3 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
71 3 my ( $self ) = @_;
72  
73 3 my $data = $self->client->api_get(
74 'balance?account_id=' . $self->account_id
75 );
76  
77 return $self->new(
78 account_id => $self->account_id,
79 client => $self->client,
80 3 %{ $data },
81 );
82 }
83  
84 =head1 SEE ALSO
85  
86 L<Business::Monzo>
87  
88 L<Business::Monzo::Resource>
89  
90 =head1 AUTHOR
91  
92 Lee Johnson - C<leejo@cpan.org>
93  
94 =head1 LICENSE
95  
96 This library is free software; you can redistribute it and/or modify it under
97 the same terms as Perl itself. If you would like to contribute documentation,
98 features, bug fixes, or anything else then please raise an issue / pull request:
99  
100 https://github.com/leejo/business-monzo
101  
102 =cut
103  
104 11 1;
105  
106 # vim: ts=4:sw=4:et
« Monzo/Address.pm ↑ Summary Monzo/Version.pm »