line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::BalancedPayments::Base; |
2
|
12
|
|
|
12
|
|
5679
|
use Moo; |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
54
|
|
3
|
|
|
|
|
|
|
with 'WebService::Client'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.0600'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
12
|
|
|
12
|
|
3113
|
use Carp qw(croak); |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
540
|
|
8
|
12
|
|
|
12
|
|
6036
|
use HTTP::Request::Common qw(GET POST); |
|
12
|
|
|
|
|
242310
|
|
|
12
|
|
|
|
|
1063
|
|
9
|
12
|
|
|
12
|
|
7734
|
use JSON qw(encode_json); |
|
12
|
|
|
|
|
107031
|
|
|
12
|
|
|
|
|
66
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+base_url' => (is => 'ro', default => 'https://api.balancedpayments.com'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has secret => (is => 'ro', required => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has uris => (is => 'ro', lazy => 1, builder => '_build_uris' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has marketplace => (is => 'ro', lazy => 1, builder => '_build_marketplace'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILD { |
20
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
21
|
0
|
|
|
|
|
|
$self->ua->default_headers->authorization_basic($self->secret, ''); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get_card { |
25
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
26
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
27
|
0
|
|
|
|
|
|
return $self->get($self->_uri('cards', $id)); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub create_card { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $card) = @_; |
32
|
0
|
0
|
|
|
|
|
croak 'The card param must be a hashref' unless ref $card eq 'HASH'; |
33
|
0
|
|
|
|
|
|
return $self->post($self->_uri('cards'), $card); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_customer { |
37
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
38
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
39
|
0
|
|
|
|
|
|
return $self->get($self->_uri('customers', $id)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub create_customer { |
43
|
0
|
|
|
0
|
0
|
|
my ($self, $customer) = @_; |
44
|
0
|
|
0
|
|
|
|
$customer ||= {}; |
45
|
0
|
0
|
|
|
|
|
croak 'The customer param must be a hashref' unless ref $customer eq 'HASH'; |
46
|
0
|
|
|
|
|
|
return $self->post($self->_uri('customers'), $customer); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get_debit { |
50
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
51
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
52
|
0
|
|
|
|
|
|
return $self->get($self->_uri('debits', $id)); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_bank_account { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
57
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
58
|
0
|
|
|
|
|
|
return $self->get($self->_uri('bank_accounts', $id)); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub create_bank_account { |
62
|
0
|
|
|
0
|
0
|
|
my ($self, $bank) = @_; |
63
|
0
|
0
|
|
|
|
|
croak 'The bank account must be a hashref' unless ref $bank eq 'HASH'; |
64
|
0
|
|
|
|
|
|
return $self->post($self->_uri('bank_accounts'), $bank); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_credit { |
68
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
69
|
0
|
0
|
|
|
|
|
croak 'The id param is missing' unless defined $id; |
70
|
0
|
|
|
|
|
|
return $self->get($self->_uri('credits', $id)); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub log { |
74
|
0
|
|
|
0
|
0
|
|
my ($self, $msg) = @_; |
75
|
0
|
0
|
|
|
|
|
return unless $self->logger; |
76
|
0
|
|
|
|
|
|
$self->logger->DEBUG("BP: $msg"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub next { |
80
|
0
|
|
|
0
|
0
|
|
my ($self, $thing) = @_; |
81
|
0
|
|
|
|
|
|
return $self->get( $thing->{meta}{next} ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _uri { |
85
|
0
|
|
|
0
|
|
|
my ($self, $key, $id) = @_; |
86
|
0
|
0
|
0
|
|
|
|
return $id if $id and $id =~ /\//; # in case a uri was passed in |
87
|
0
|
0
|
|
|
|
|
return $self->uris->{$key} . ( defined $id ? "/$id" : '' ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding UTF-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Business::BalancedPayments::Base |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
version 1.0600 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHORS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Ali Anari <ali@tilt.com> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Khaled Hussein <khaled@tilt.com> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Naveed Massjouni <naveed@tilt.com> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Al Newkirk <al@tilt.com> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Will Wolf <will@tilt.com> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Crowdtilt, Inc.. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |