lib/Finance/GDAX/API/Deposit.pm

filter: Statementstmt 79.4% 31 / 39 Branchbran 0.0% 0 / 4 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 63.3% 45 / 71 CC 7 SCAR 16.9
CC
7
Cov
64%
from_payment
8.7
from_coinbase
8.7
BEGIN
1.0
CRAP 5.4
« lib/Finance/GDAX/API/MarginTransfer.pm ↑ Summary blib/lib/Finance/GDAX/API/Position.pm »
1 package Finance::GDAX::API::Deposit;
2 1 our $VERSION = '0.01';
3 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Finance::GDAX::API::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Finance::GDAX::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 extends 'Finance::GDAX::API';
11  
12 1 has 'payment_method_id' => (is => 'rw',
13 isa => 'Str',
14 );
15 1 has 'coinbase_account_id' => (is => 'rw',
16 isa => 'Str',
17 );
18 1 has 'amount' => (is => 'rw',
19 isa => 'PositiveNum',
20 );
21 1 has 'currency' => (is => 'rw',
22 isa => 'Str',
23 );
24  
25 sub from_payment {
26 1 ▶ my $self = shift;
Subroutine from_payment: called CC=4 SCAR=21.7
Pod documented
27 1 ▶ unless ($self->payment_method_id &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->payment_method_id and $self->amount and $self->currency) 0 0 0
Condition33%2/6
$self->payment_method_id and $self->amount and $self->currency
!ll&&!rl&&r
100
$self->payment_method_id and $self->amount
!ll&&!rl&&r
100
MC/DC0%0/3
$self->payment_method_id and $self->amount and $self->currency
$self->payment_method_id $self->amount $self->currency
Truth table25%1/4
A and B and C
A= $self->payment_method_idB= $self->amountC= $self->currency
ABCresult
0XX0
10X0
1100
1111
28 $self->amount &&
29 $self->currency) {
30 1 die 'payments need amount and currency set';
31 }
32 0 $self->path('/deposits/payment-method');
33 0 $self->method('POST');
34 0 $self->body({ amount => $self->amount,
35 currency => $self->currency,
36 payment_method_id => $self->payment_method_id,
37 });
38 0 return $self->send;
39 }
40  
41 sub from_coinbase {
42 1 ▶ my $self = shift;
Subroutine from_coinbase: called CC=4 SCAR=21.7
Pod documented
43 1 ▶ unless ($self->coinbase_account_id &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->coinbase_account_id and $self->amount and $self->currency) 0 0 0
Condition33%2/6
$self->coinbase_account_id and $self->amount and $self->currency
!ll&&!rl&&r
100
$self->coinbase_account_id and $self->amount
!ll&&!rl&&r
100
MC/DC0%0/3
$self->coinbase_account_id and $self->amount and $self->currency
$self->coinbase_account_id $self->amount $self->currency
Truth table25%1/4
A and B and C
A= $self->coinbase_account_idB= $self->amountC= $self->currency
ABCresult
0XX0
10X0
1100
1111
44 $self->amount &&
45 $self->currency) {
46 1 die 'coinbase needs an amount and currency set';
47 }
48 0 $self->path('/deposits/coinbase-account');
49 0 $self->method('POST');
50 0 $self->body({ amount => $self->amount,
51 currency => $self->currency,
52 coinbase_account_id => $self->coinbase_account_id,
53 });
54 0 return $self->send;
55 }
56  
57 1 __PACKAGE__->meta->make_immutable;
58 1 1;
59  
60 =head1 NAME
61  
62 Finance::GDAX::API::Deposit - Deposit funds via Payment Method or
63 Coinbase
64  
65 =head1 SYNOPSIS
66  
67 use Finance::GDAX::API::Deposit;
68  
69 $deposit = Finance::GDAX::API::Deposit->new(
70 currency => 'USD',
71 amount => '250.00');
72 $deposit->payment_method_id('kwji-wefwe-ewrgeurg-wef');
73  
74 $response = $deposit->from_payment;
75  
76 # Or, from a Coinbase account
77 $deposit->coinbase_account_id('woifhe-i234h-fwikn-wfihwe');
78  
79 $response = $deposit->from_coinbase;
80  
81 =head2 DESCRIPTION
82  
83 Used to transfer funds into your GDAX account, either from a
84 predefined Payment Method or your Coinbase account.
85  
86 Both methods require the same two attributes: "amount" and "currency"
87 to be set, along with their corresponding payment or coinbase account
88 id's.
89  
90 =head1 ATTRIBUTES
91  
92 =head2 C<payment_method_id> $string
93  
94 ID of the payment method.
95  
96 Either this or coinbase_account_id must be set.
97  
98 =head2 C<coinbase_account_id> $string
99  
100 ID of the coinbase account.
101  
102 Either this or payment_method_id must be set.
103  
104 =head2 C<amount> $number
105  
106 The amount to be deposited.
107  
108 =head2 C<currency> $currency_string
109  
110 The currency of the amount -- for example "USD".
111  
112 =head1 METHODS
113  
114 =head2 C<from_payment>
115  
116 All attributes must be set before calling this method. The return
117 value is a hash that will describe the result of the payment.
118  
119 From the current GDAX API documentation, this is how that returned hash is
120 keyed:
121  
122 {
123 "amount": 10.00,
124 "currency": "USD",
125 "payment_method_id": "bc677162-d934-5f1a-968c-a496b1c1270b"
126 }
127  
128 =head2 C<from_coinbase>
129  
130 All attributes must be set before calling this method. The return
131 value is a hash that will describe the result of the funds move.
132  
133 From the current GDAX API documentation, this is how that returned hash is
134 keyed:
135  
136 {
137 "id": "593533d2-ff31-46e0-b22e-ca754147a96a",
138 "amount": "10.00",
139 "currency": "BTC",
140 }
141  
142 =cut
143  
144  
145 =head1 AUTHOR
146  
147 Mark Rushing <mark@orbislumen.net>
148  
149 =head1 COPYRIGHT AND LICENSE
150  
151 This software is copyright (c) 2017 by Home Grown Systems, SPC.
152  
153 This is free software; you can redistribute it and/or modify it under
154 the same terms as the Perl 5 programming language system itself.
155  
156 =cut
157  
« lib/Finance/GDAX/API/MarginTransfer.pm ↑ Summary blib/lib/Finance/GDAX/API/Position.pm »