| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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
|
10
|
|
|
10
|
|
63
|
use strict; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
308
|
|
|
14
|
10
|
|
|
10
|
|
48
|
use warnings; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
303
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
10
|
|
|
10
|
|
52
|
use Moo; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
86
|
|
|
17
|
|
|
|
|
|
|
extends 'Business::Monzo::Resource'; |
|
18
|
|
|
|
|
|
|
with 'Business::Monzo::Utils'; |
|
19
|
|
|
|
|
|
|
with 'Business::Monzo::Currency'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
3970
|
use Types::Standard qw/ :all /; |
|
|
10
|
|
|
|
|
26
|
|
|
|
10
|
|
|
|
|
302
|
|
|
22
|
10
|
|
|
10
|
|
423581
|
use Business::Monzo::Merchant; |
|
|
10
|
|
|
|
|
30
|
|
|
|
10
|
|
|
|
|
342
|
|
|
23
|
10
|
|
|
10
|
|
66
|
use DateTime::Format::DateParse; |
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
2542
|
|
|
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
|
|
|
|
|
|
|
has [ qw/ account_id / ] => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
isa => Str, |
|
42
|
|
|
|
|
|
|
required => 1, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has [ qw/ balance spend_today / ] => ( |
|
46
|
|
|
|
|
|
|
is => 'ro', |
|
47
|
|
|
|
|
|
|
isa => Int, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has [ qw/ url / ] => ( |
|
51
|
|
|
|
|
|
|
is => 'ro', |
|
52
|
|
|
|
|
|
|
lazy => 1, |
|
53
|
|
|
|
|
|
|
default => sub { |
|
54
|
|
|
|
|
|
|
my ( $self ) = @_; |
|
55
|
|
|
|
|
|
|
return $self->client->api_url . '/balance?account_id=' . $self->account_id; |
|
56
|
|
|
|
|
|
|
}, |
|
57
|
|
|
|
|
|
|
); |
|
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
|
|
|
|
|
|
|
sub get { |
|
71
|
3
|
|
|
3
|
1
|
39
|
my ( $self ) = @_; |
|
72
|
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
48
|
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
|
|
|
|
|
318
|
%{ $data }, |
|
|
3
|
|
|
|
|
75
|
|
|
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
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |