line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::GDAX::API::Deposit; |
2
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
3
|
1
|
|
|
1
|
|
24954
|
use 5.20.0; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
468
|
use Moose; |
|
1
|
|
|
|
|
990255
|
|
|
1
|
|
|
|
|
11
|
|
6
|
1
|
|
|
1
|
|
13184
|
use Finance::GDAX::API::TypeConstraints; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
85
|
|
7
|
1
|
|
|
1
|
|
597
|
use Finance::GDAX::API; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
64
|
|
8
|
1
|
|
|
1
|
|
15
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Finance::GDAX::API'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'payment_method_id' => (is => 'rw', |
13
|
|
|
|
|
|
|
isa => 'Str', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
has 'coinbase_account_id' => (is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Str', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
has 'amount' => (is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'PositiveNum', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has 'currency' => (is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub from_payment { |
26
|
1
|
|
|
1
|
1
|
225
|
my $self = shift; |
27
|
1
|
0
|
33
|
|
|
27
|
unless ($self->payment_method_id && |
|
|
|
33
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->amount && |
29
|
|
|
|
|
|
|
$self->currency) { |
30
|
1
|
|
|
|
|
13
|
die 'payments need amount and currency set'; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
0
|
$self->path('/deposits/payment-method'); |
33
|
0
|
|
|
|
|
0
|
$self->method('POST'); |
34
|
0
|
|
|
|
|
0
|
$self->body({ amount => $self->amount, |
35
|
|
|
|
|
|
|
currency => $self->currency, |
36
|
|
|
|
|
|
|
payment_method_id => $self->payment_method_id, |
37
|
|
|
|
|
|
|
}); |
38
|
0
|
|
|
|
|
0
|
return $self->send; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub from_coinbase { |
42
|
1
|
|
|
1
|
1
|
35
|
my $self = shift; |
43
|
1
|
0
|
33
|
|
|
45
|
unless ($self->coinbase_account_id && |
|
|
|
33
|
|
|
|
|
44
|
|
|
|
|
|
|
$self->amount && |
45
|
|
|
|
|
|
|
$self->currency) { |
46
|
1
|
|
|
|
|
10
|
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
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
58
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|