line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::Mondo::Balance; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::Mondo::Balance |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A class for a Mondo balance, extends L<Business::Mondo::Resource> |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
40
|
use strict; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
247
|
|
14
|
10
|
|
|
10
|
|
34
|
use warnings; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
229
|
|
15
|
|
|
|
|
|
|
|
16
|
10
|
|
|
10
|
|
31
|
use Moo; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
58
|
|
17
|
|
|
|
|
|
|
extends 'Business::Mondo::Resource'; |
18
|
|
|
|
|
|
|
with 'Business::Mondo::Utils'; |
19
|
|
|
|
|
|
|
with 'Business::Mondo::Currency'; |
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
2537
|
use Types::Standard qw/ :all /; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
271
|
|
22
|
10
|
|
|
10
|
|
243261
|
use Business::Mondo::Merchant; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
259
|
|
23
|
10
|
|
|
10
|
|
36
|
use DateTime::Format::DateParse; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
1664
|
|
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 Mondo API |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$Balance = $Balance->get; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get { |
71
|
3
|
|
|
3
|
1
|
25
|
my ( $self ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
31
|
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
|
|
|
|
|
201
|
%{ $data }, |
|
3
|
|
|
|
|
72
|
|
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Business::Mondo> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Business::Mondo::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-mondo |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |