blib/lib/WebService/FaucetBOX.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use strict;
2 use warnings;
3 package WebService::FaucetBOX;
4 $WebService::FaucetBOX::VERSION = '0.01';
5 # ABSTRACT: WebService::FaucetBOX - FaucetBOX (faucetbox.com) API bindings
6  
7 use Moo;
8 with 'WebService::Client';
9  
10 use Function::Parameters;
11  
12  
13 # sub BUILD {
14 # my ($self) = @_;
15 # $self->ua->add_handler("request_send", sub { shift->dump; return });
16 # $self->ua->add_handler("response_done", sub { shift->dump; return });
17 # }
18  
19 around post => fun($orig, $self, $path, $params, %args) {
20 $params->{api_key} = $self->api_key;
21 $params->{currency} = $self->currency;
22 $args{headers}->{'Content-Type'} = 'application/x-www-form-urlencoded';
23 return $self->$orig($path, $params, %args);
24 };
25  
26  
27 has '+base_url' => ( default => 'https://faucetbox.com/api/v1' );
28  
29  
30 has currency => ( is => 'rw', default => 'BTC' );
31  
32  
33 has api_key => ( is => 'ro', required => 1 );
34  
35  
36  
37 method send($to, $amount, :$referral = 'false') {
38 return $self->post("/send", {
39 to => $to,
40 amount => $amount,
41 referral => $referral
42 });
43 }
44  
45  
46 method getBalance {
47 return $self->post( "/balance" );
48 }
49  
50  
51 method getCurrencies {
52 return $self->post( "/currencies" );
53 }
54  
55  
56 method getPayouts( $count ) {
57 return $self->post( "/payouts", { count => $count } );
58 }
59  
60  
61 method sendReferralEarnings( $to, $amount ) {
62 return $self->send($to, $amount, 'true');
63 }
64  
65  
66 1;
67  
68 __END__