line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::GoCardless::Merchant; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::GoCardless::Merchant |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A class for a gocardless merchant, extends L |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
19
|
|
|
19
|
|
119
|
use strict; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
519
|
|
14
|
19
|
|
|
19
|
|
91
|
use warnings; |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
434
|
|
15
|
|
|
|
|
|
|
|
16
|
19
|
|
|
19
|
|
88
|
use Moo; |
|
19
|
|
|
|
|
33
|
|
|
19
|
|
|
|
|
105
|
|
17
|
|
|
|
|
|
|
extends 'Business::GoCardless::Resource'; |
18
|
|
|
|
|
|
|
|
19
|
19
|
|
|
19
|
|
6254
|
use Carp qw/ carp /; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
989
|
|
20
|
|
|
|
|
|
|
|
21
|
19
|
|
|
19
|
|
118
|
use Business::GoCardless::Bill; |
|
19
|
|
|
|
|
44
|
|
|
19
|
|
|
|
|
463
|
|
22
|
19
|
|
|
19
|
|
6193
|
use Business::GoCardless::PreAuthorization; |
|
19
|
|
|
|
|
52
|
|
|
19
|
|
|
|
|
593
|
|
23
|
19
|
|
|
19
|
|
7183
|
use Business::GoCardless::Payout; |
|
19
|
|
|
|
|
61
|
|
|
19
|
|
|
|
|
569
|
|
24
|
19
|
|
|
19
|
|
7202
|
use Business::GoCardless::User; |
|
19
|
|
|
|
|
55
|
|
|
19
|
|
|
|
|
596
|
|
25
|
19
|
|
|
19
|
|
7181
|
use Business::GoCardless::Paginator; |
|
19
|
|
|
|
|
72
|
|
|
19
|
|
|
|
|
9343
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
balance |
30
|
|
|
|
|
|
|
created_at |
31
|
|
|
|
|
|
|
description |
32
|
|
|
|
|
|
|
email |
33
|
|
|
|
|
|
|
eur_balance |
34
|
|
|
|
|
|
|
eur_pending_balance |
35
|
|
|
|
|
|
|
first_name |
36
|
|
|
|
|
|
|
gbp_balance |
37
|
|
|
|
|
|
|
gbp_pending_balance |
38
|
|
|
|
|
|
|
hide_variable_amount |
39
|
|
|
|
|
|
|
id |
40
|
|
|
|
|
|
|
last_name |
41
|
|
|
|
|
|
|
name |
42
|
|
|
|
|
|
|
next_payout_amount |
43
|
|
|
|
|
|
|
next_payout_date |
44
|
|
|
|
|
|
|
pending_balance |
45
|
|
|
|
|
|
|
sub_resource_uris |
46
|
|
|
|
|
|
|
uri |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has [ qw/ |
51
|
|
|
|
|
|
|
balance |
52
|
|
|
|
|
|
|
created_at |
53
|
|
|
|
|
|
|
description |
54
|
|
|
|
|
|
|
email |
55
|
|
|
|
|
|
|
eur_balance |
56
|
|
|
|
|
|
|
eur_pending_balance |
57
|
|
|
|
|
|
|
first_name |
58
|
|
|
|
|
|
|
gbp_balance |
59
|
|
|
|
|
|
|
gbp_pending_balance |
60
|
|
|
|
|
|
|
hide_variable_amount |
61
|
|
|
|
|
|
|
id |
62
|
|
|
|
|
|
|
last_name |
63
|
|
|
|
|
|
|
name |
64
|
|
|
|
|
|
|
next_payout_amount |
65
|
|
|
|
|
|
|
next_payout_date |
66
|
|
|
|
|
|
|
pending_balance |
67
|
|
|
|
|
|
|
sub_resource_uris |
68
|
|
|
|
|
|
|
uri |
69
|
|
|
|
|
|
|
/ ] => ( |
70
|
|
|
|
|
|
|
is => 'rw', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub BUILD { |
74
|
7
|
|
|
7
|
0
|
96
|
my ( $self ) = @_; |
75
|
|
|
|
|
|
|
|
76
|
7
|
|
|
|
|
72
|
my $data = $self->client->api_get( sprintf( $self->endpoint,$self->id ) ); |
77
|
|
|
|
|
|
|
|
78
|
7
|
|
|
|
|
14
|
foreach my $attr ( keys( %{ $data } ) ) { |
|
7
|
|
|
|
|
35
|
|
79
|
113
|
|
|
|
|
123
|
eval { $self->$attr( $data->{$attr} ); }; |
|
113
|
|
|
|
|
256
|
|
80
|
113
|
50
|
|
|
|
173
|
$@ && do { |
81
|
0
|
|
|
|
|
0
|
carp( "Couldn't set $attr on @{[ ref( $self ) ]}: $@" ); |
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
7
|
|
|
|
|
60
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 List operations on a merchant |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
bills |
91
|
|
|
|
|
|
|
pre_authorizations |
92
|
|
|
|
|
|
|
subscriptions |
93
|
|
|
|
|
|
|
payouts |
94
|
|
|
|
|
|
|
users |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my @bills = $Merchant->bills( \%filter ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Note that these methods marked have a dual interface, when called in list context |
99
|
|
|
|
|
|
|
they will return the first 100 resource objects, when called in scalar context |
100
|
|
|
|
|
|
|
they will return a L object. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
2
|
0
|
9
|
sub bills { shift->_list( 'bills',shift ) } |
105
|
1
|
|
|
1
|
0
|
5
|
sub pre_authorizations { shift->_list( 'pre_authorizations',shift )} |
106
|
1
|
|
|
1
|
0
|
5
|
sub subscriptions { shift->_list( 'subscriptions',shift ) } |
107
|
1
|
|
|
1
|
0
|
5
|
sub payouts { shift->_list( 'payouts',shift ) } |
108
|
1
|
|
|
1
|
0
|
5
|
sub users { shift->_list( 'users',shift ) } |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _list { |
111
|
6
|
|
|
6
|
|
18
|
my ( $self,$endpoint,$filters ) = @_; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $class = { |
114
|
|
|
|
|
|
|
bills => 'Bill', |
115
|
|
|
|
|
|
|
pre_authorizations => 'PreAuthorization', |
116
|
|
|
|
|
|
|
subscriptions => 'Subscription', |
117
|
|
|
|
|
|
|
payouts => 'Payout', |
118
|
|
|
|
|
|
|
users => 'User', |
119
|
6
|
|
|
|
|
35
|
}->{ $endpoint }; |
120
|
|
|
|
|
|
|
|
121
|
6
|
|
50
|
|
|
19
|
$filters //= {}; |
122
|
6
|
|
50
|
|
|
34
|
$filters->{per_page} ||= 100; |
123
|
6
|
|
50
|
|
|
28
|
$filters->{page} ||= 1; |
124
|
|
|
|
|
|
|
|
125
|
6
|
|
|
|
|
33
|
my $uri = sprintf( $self->endpoint,$self->id ) . "/$endpoint"; |
126
|
|
|
|
|
|
|
|
127
|
6
|
50
|
|
|
|
12
|
if ( keys( %{ $filters } ) ) { |
|
6
|
|
|
|
|
21
|
|
128
|
6
|
|
|
|
|
26
|
$uri .= '?' . $self->client->normalize_params( $filters ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
6
|
|
|
|
|
29
|
my ( $data,$links,$info ) = $self->client->api_get( $uri ); |
132
|
|
|
|
|
|
|
|
133
|
6
|
|
|
|
|
17
|
$class = "Business::GoCardless::$class"; |
134
|
10
|
|
|
|
|
76
|
my @objects = map { $class->new( client => $self->client,%{ $_ } ) } |
|
10
|
|
|
|
|
178
|
|
135
|
6
|
|
|
|
|
15
|
@{ $data }; |
|
6
|
|
|
|
|
13
|
|
136
|
|
|
|
|
|
|
|
137
|
6
|
0
|
|
|
|
133
|
return wantarray ? ( @objects ) : Business::GoCardless::Paginator->new( |
|
|
50
|
|
|
|
|
|
138
|
|
|
|
|
|
|
class => $class, |
139
|
|
|
|
|
|
|
client => $self->client, |
140
|
|
|
|
|
|
|
links => $links, |
141
|
|
|
|
|
|
|
info => $info ? JSON->new->decode( $info ) : {}, |
142
|
|
|
|
|
|
|
objects => \@objects, |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Lee Johnson - C |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
151
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation, |
152
|
|
|
|
|
|
|
features, bug fixes, or anything else then please raise an issue / pull request: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
https://github.com/Humanstate/business-gocardless |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |