blib/lib/Finance/CampBX.pm

filter: Statementstmt 28.0% 14 / 50 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.6% 4 / 15 Podpod 100% 11 / 11 totaltotal 36.2% 29 / 80 CC 3 SCAR 12.6
CC
3
Cov
26%
sendrequest
12.0
ticker
2.0
depth
2.0
CRAP 3.5
↑ Summary
1 package Finance::CampBX;
2 1 $Finance::CampBX::VERSION = '0.2';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use JSON -support_by_pp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub ticker(){
Subroutine ticker: not called CC=1 SCAR=6.9
Pod documented
9 0 return sendrequest("http://campbx.com/api/xticker.php");
10 }
11  
12 0 ▶sub depth(){
Subroutine depth: not called CC=1 SCAR=6.9
Pod documented
13 0 return sendrequest("http://campbx.com/api/xdepth.php");
14 }
15  
16 0 ▶sub balance(){
Subroutine balance: not called CC=1 SCAR=6.9
Pod documented
17 0 my $self = shift;
18 0 my ($userid, $password) = @_;
19 0 return sendrequest('https://campbx.com/api/myfunds.php', {'user'=>$userid, 'pass'=>$password });
20 }
21  
22 0 ▶sub orders(){
Subroutine orders: not called CC=1 SCAR=6.9
Pod documented
23 0 my $self = shift;
24 0 my ($userid, $password) = @_;
25 0 return sendrequest('https://campbx.com/api/myorders.php', {'user'=>$userid, 'pass'=>$password });
26 }
27  
28 0 ▶sub margins(){
Subroutine margins: not called CC=1 SCAR=6.9
Pod documented
29 0 my $self = shift;
30 0 my ($userid, $password) = @_;
31 0 return sendrequest('https://campbx.com/api/mymargins.php', {'user'=>$userid, 'pass'=>$password });
32 }
33  
34 0 ▶sub getbtcaddress(){
Subroutine getbtcaddress: not called CC=1 SCAR=6.9
Pod documented
35 0 my $self = shift;
36 0 my ($userid, $password) = @_;
37 0 return sendrequest('https://campbx.com/api/getbtcaddr.php', {'user'=>$userid, 'pass'=>$password });
38 }
39  
40 0 ▶sub quicktrade(){
Subroutine quicktrade: not called CC=1 SCAR=6.9
Pod documented
41 0 my $self = shift;
42 0 my ($userid, $password, $trademode, $quantity, $price) = @_;
43 0 return sendrequest('https://campbx.com/api/tradeenter.php', { 'user'=>$userid, 'pass'=>$password, 'TradeMode'=>$trademode, 'Quantity'=> $quantity, 'Price'=>$price });
44 }
45  
46 0 ▶sub cancelorder(){
Subroutine cancelorder: not called CC=1 SCAR=6.9
Pod documented
47 0 my $self = shift;
48 0 my ($userid, $password, $type, $orderid) = @_;
49 0 return sendrequest('https://campbx.com/api/tradecancel.php', { 'user'=>$userid, 'pass'=>$password, 'Type'=>$type, 'OrderID'=>$orderid });
50 }
51  
52 0 ▶sub sendtobtc(){
Subroutine sendtobtc: not called CC=1 SCAR=6.9
Pod documented
53 0 my $self = shift;
54 0 my ($userid, $password, $btcaddress, $btcamount) = @_;
55 0 return sendrequest('https://campbx.com/api/sendbtc.php', { 'user'=>$userid, 'pass'=>$password, 'BTCTo'=>$btcaddress, 'BTCAmt'=>$btcamount });
56 }
57  
58  
59 0 ▶sub sendrequest(){
Subroutine sendrequest: not called CC=3 SCAR=24.8
Pod documented
60 0 my ( $url, $options ) = @_;
61 0 my $response;
62 0 my $browser = LWP::UserAgent->new( agent => "Perl-Finance-CampBX" );
63 0 ▶ if ($options){
Branch: 1 branch
BranchTrueFalseTotal
if ($options) { } 0 0 0
64 0 $response = $browser->post( $url, $options );
65 }else{
66 0 $response = $browser->post( $url );
67 }
68 0 ▶ if ($response->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
69 0 my $content = $response->content;
70 0 my $json = new JSON;
71 0 return $json->utf8->decode($content);
72 } else {
73 0 return 0;
74 }
75 }
76  
77 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
78 0 my $package = shift;
79 0 return bless({}, $package);
80 }
81  
82 1 1;
83 __END__
↑ Summary