GoCardless.pm

filter: Statementstmt 98.6% 72 / 73 Branchbran 70.0% 7 / 10 Conditioncond 60.0% 3 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 27 / 27 Podpod 0.0% 0 / 15 totaltotal 81.9% 109 / 133 CC 8 SCAR 3.7
CC
8
Cov
93%
__ANON__
2.1
__ANON__
2.1
__ANON__
2.1
CRAP 1.4
« GoCardless/BillingRequest.pm ↑ Summary GoCardless/Mandate.pm »
1 package Business::GoCardless;
2  
3 =head1 NAME
4  
5 Business::GoCardless - Top level namespace for the Business::GoCardless
6 set of modules
7  
8 =head1 VERSION
9  
10 1.01
11  
12 =head1 DESCRIPTION
13  
14 Business::GoCardless is a set of libraries for easy interface to the gocardless
15 payment service, they implement all of the functionality currently found
16 in the service's API documentation: https://developer.gocardless.com
17  
18 =head1 Do Not Use This Module Directly
19  
20 You should go straight to L<Business::GoCardless::Pro> and start there.
21  
22 =cut
23  
24 55 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 55 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 55 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 55 ▶use Carp qw/ confess /;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 55 ▶use Business::GoCardless::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 55 ▶use Business::GoCardless::Webhook;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 55 $Business::GoCardless::VERSION = '1.01';
34  
35 has api_version => (
36 is => 'ro',
37 required => 0,
38 lazy => 1,
39 1 ▶ default => sub { $ENV{GOCARDLESS_API_VERSION} // 1 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
$ENV{"GOCARDLESS_API_VERSION"} // 1
l!l
01
MC/DC0%0/1
$ENV{"GOCARDLESS_API_VERSION"} // 1
$ENV{"GOCARDLESS_API_VERSION"}
Truth table50%1/2
A
A= $ENV{"GOCARDLESS_API_VERSION"}
Aresult
11
00
40 55 );
41  
42 55 has token => (
43 is => 'ro',
44 required => 1,
45 );
46  
47 has client_details => (
48 is => 'ro',
49 4 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
50 4 ▶ confess( "$_[0] is not a hashref" )
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] ne "HASH" 0 4 4
51 if ref( $_[0] ) ne 'HASH';
52 },
53 required => 0,
54 lazy => 1,
55 4 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
56 4 my ( $self ) = @_;
57 return {
58 4 api_version => $self->api_version,
59 };
60 },
61 55 );
62  
63 has client => (
64 is => 'ro',
65 4 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
66 4 ▶ confess( "$_[0] is not a Business::GoCardless::Client" )
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] ne "Business::GoCardless::Client" 0 4 4
67 if ref $_[0] ne 'Business::GoCardless::Client'
68 },
69 required => 0,
70 lazy => 1,
71 4 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
72 4 my ( $self ) = @_;
73  
74 return Business::GoCardless::Client->new(
75 4 %{ $self->client_details },
76 token => $self->token,
77 api_version => $self->api_version,
78 );
79 },
80 55 );
81  
82  
83 4 ▶sub confirm_resource {
Subroutine confirm_resource: called CC=1 SCAR=0.0
Pod undocumented
84 4 my ( $self,%params ) = @_;
85 4 return $self->client->_confirm_resource( \%params );
86 }
87  
88 1 ▶sub new_bill_url {
Subroutine new_bill_url: called CC=1 SCAR=0.0
Pod undocumented
89 1 my ( $self,%params ) = @_;
90 1 return $self->client->_new_bill_url( \%params );
91 }
92  
93 2 ▶sub bill {
Subroutine bill: called CC=2 SCAR=6.9
Pod undocumented
94 2 my ( $self,$id ) = @_;
95  
96 2 ▶ if ( $self->client->api_version > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->client->api_version > 1) { } 1 1 2
97 1 return $self->payment( $id );
98 } else {
99 1 return $self->_generic_find_obj( $id,'Bill' );
100 }
101 }
102  
103 4 ▶sub bills {
Subroutine bills: called CC=2 SCAR=6.9
Pod undocumented
104 4 my ( $self,%filters ) = @_;
105  
106 4 ▶ if ( $self->client->api_version > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->client->api_version > 1) { } 2 2 4
107 2 return $self->payments( %filters );
108 } else {
109 2 return $self->merchant( $self->client->merchant_id )
110 ->bills( \%filters );
111 }
112 }
113  
114 7 ▶sub merchant {
Subroutine merchant: called CC=2 SCAR=7.0
Pod undocumented
115 7 my ( $self,$merchant_id ) = @_;
116  
117 7 ▶ $merchant_id //= $self->client->merchant_id;
Condition66%2/3
$merchant_id //= $self->client->merchant_id
l!l&&r!l&&!r
610
MC/DC0%0/2
$merchant_id //= $self->client->merchant_id
$merchant_id $self->client->merchant_id
Truth table66%2/3
A //= B
A= $merchant_idB= $self->client->merchant_id
ABresult
1X1
011
000
118 7 return Business::GoCardless::Merchant->new(
119 client => $self->client,
120 id => $merchant_id
121 );
122 }
123  
124 1 ▶sub payouts {
Subroutine payouts: called CC=2 SCAR=7.6
Pod undocumented
125 1 my ( $self,%filters ) = @_;
126  
127 1 ▶ if ( $self->client->api_version > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->client->api_version > 1) { } 0 1 1
128 0 return $self->_list( 'payouts',\%filters );
129 } else {
130 1 return $self->merchant( $self->client->merchant_id )
131 ->payouts( \%filters );
132 }
133 }
134  
135 2 ▶sub payout {
Subroutine payout: called CC=1 SCAR=0.0
Pod undocumented
136 2 my ( $self,$id ) = @_;
137 2 return $self->_generic_find_obj( $id,'Payout','payouts' );
138 }
139  
140 1 ▶sub new_pre_authorization_url {
Subroutine new_pre_authorization_url: called CC=1 SCAR=0.0
Pod undocumented
141 1 my ( $self,%params ) = @_;
142 1 return $self->client->_new_pre_authorization_url( \%params );
143 }
144  
145 1 ▶sub pre_authorization {
Subroutine pre_authorization: called CC=1 SCAR=0.0
Pod undocumented
146 1 my ( $self,$id ) = @_;
147 1 return $self->_generic_find_obj( $id,'PreAuthorization' );
148 }
149  
150 1 ▶sub pre_authorizations {
Subroutine pre_authorizations: called CC=1 SCAR=0.0
Pod undocumented
151 1 my ( $self,%filters ) = @_;
152 1 return $self->merchant( $self->client->merchant_id )
153 ->pre_authorizations( \%filters );
154 }
155  
156 1 ▶sub new_subscription_url {
Subroutine new_subscription_url: called CC=1 SCAR=0.0
Pod undocumented
157 1 my ( $self,%params ) = @_;
158 1 return $self->client->_new_subscription_url( \%params );
159 }
160  
161 1 ▶sub subscription {
Subroutine subscription: called CC=1 SCAR=0.0
Pod undocumented
162 1 my ( $self,$id ) = @_;
163 1 return $self->_generic_find_obj( $id,'Subscription' );
164 }
165  
166 1 ▶sub subscriptions {
Subroutine subscriptions: called CC=1 SCAR=0.0
Pod undocumented
167 1 my ( $self,%filters ) = @_;
168 1 return $self->merchant( $self->client->merchant_id )
169 ->subscriptions( \%filters );
170 }
171  
172 1 ▶sub users {
Subroutine users: called CC=1 SCAR=0.0
Pod undocumented
173 1 my ( $self,%filters ) = @_;
174 1 return $self->merchant( $self->client->merchant_id )
175 ->users( \%filters );
176 }
177  
178 2 ▶sub webhook {
Subroutine webhook: called CC=1 SCAR=0.0
Pod undocumented
179 2 my ( $self,$data ) = @_;
180  
181 2 return Business::GoCardless::Webhook->new(
182 client => $self->client,
183 json => $data,
184 );
185 }
186  
187 9 ▶sub _generic_find_obj {
Subroutine _generic_find_obj: called CC=1 SCAR=0.0
188 9 my ( $self,$id,$class,$sub_key ) = @_;
189 9 $class = "Business::GoCardless::$class";
190 9 my $obj = $class->new(
191 id => $id,
192 client => $self->client
193 );
194 9 return $obj->find_with_client( $sub_key );
195 }
196  
197 =head1 SEE ALSO
198  
199 L<Business::GoCardless::Pro>
200  
201 =head1 AUTHOR
202  
203 Lee Johnson - C<lee@payprop.com>
204  
205 =head1 CONTRIBUTORS
206  
207 grifferz - C<andy-github.com@strugglers.net>
208  
209 =head1 LICENSE
210  
211 This library is free software; you can redistribute it and/or modify it under
212 the same terms as Perl itself. If you would like to contribute documentation,
213 features, bug fixes, or anything else then please raise an issue / pull request:
214  
215 https://github.com/payprop/business-gocardless
216  
217 =cut
218  
219 55 1;
220  
221 # vim: ts=4:sw=4:et
« GoCardless/BillingRequest.pm ↑ Summary GoCardless/Mandate.pm »