line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::GDAX::API::Withdrawl; |
2
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
3
|
1
|
|
|
1
|
|
24332
|
use 5.20.0; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
407
|
use Moose; |
|
1
|
|
|
|
|
464330
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
8235
|
use Finance::GDAX::API::TypeConstraints; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
7
|
1
|
|
|
1
|
|
614
|
use Finance::GDAX::API; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
8
|
1
|
|
|
1
|
|
10
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
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 'crypto_address' => (is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has 'amount' => (is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'PositiveNum', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
has 'currency' => (is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'Str', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub to_payment { |
29
|
1
|
|
|
1
|
1
|
201
|
my $self = shift; |
30
|
1
|
0
|
33
|
|
|
28
|
unless ($self->payment_method_id && |
|
|
|
33
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->amount && |
32
|
|
|
|
|
|
|
$self->currency) { |
33
|
1
|
|
|
|
|
15
|
die 'payments need amount and currency set'; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
0
|
$self->path('/withdrawls/payment-method'); |
36
|
0
|
|
|
|
|
0
|
$self->method('POST'); |
37
|
0
|
|
|
|
|
0
|
$self->body({ amount => $self->amount, |
38
|
|
|
|
|
|
|
currency => $self->currency, |
39
|
|
|
|
|
|
|
payment_method_id => $self->payment_method_id, |
40
|
|
|
|
|
|
|
}); |
41
|
0
|
|
|
|
|
0
|
return $self->send; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub to_coinbase { |
45
|
1
|
|
|
1
|
1
|
34
|
my $self = shift; |
46
|
1
|
0
|
33
|
|
|
30
|
unless ($self->coinbase_account_id && |
|
|
|
33
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->amount && |
48
|
|
|
|
|
|
|
$self->currency) { |
49
|
1
|
|
|
|
|
9
|
die 'coinbase needs an amount and currency set'; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
0
|
$self->path('/withdrawls/coinbase-account'); |
52
|
0
|
|
|
|
|
0
|
$self->method('POST'); |
53
|
0
|
|
|
|
|
0
|
$self->body({ amount => $self->amount, |
54
|
|
|
|
|
|
|
currency => $self->currency, |
55
|
|
|
|
|
|
|
coinbase_account_id => $self->coinbase_account_id, |
56
|
|
|
|
|
|
|
}); |
57
|
0
|
|
|
|
|
0
|
return $self->send; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub to_crypto { |
61
|
1
|
|
|
1
|
1
|
33
|
my $self = shift; |
62
|
1
|
0
|
33
|
|
|
47
|
unless ($self->crypto_address && |
|
|
|
33
|
|
|
|
|
63
|
|
|
|
|
|
|
$self->amount && |
64
|
|
|
|
|
|
|
$self->currency) { |
65
|
1
|
|
|
|
|
8
|
die 'crypto_address needs an amount and currency set'; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
$self->path('/withdrawls/crypto'); |
68
|
0
|
|
|
|
|
|
$self->method('POST'); |
69
|
0
|
|
|
|
|
|
$self->body({ amount => $self->amount, |
70
|
|
|
|
|
|
|
currency => $self->currency, |
71
|
|
|
|
|
|
|
crypto_address => $self->crypto_address, |
72
|
|
|
|
|
|
|
}); |
73
|
0
|
|
|
|
|
|
return $self->send; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Finance::GDAX::API::Withdrawl - Withdraw funds to a Payment Method or |
82
|
|
|
|
|
|
|
Coinbase |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use Finance::GDAX::API::Withdraw; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$withdraw = Finance::GDAX::API::Withdraw->new( |
89
|
|
|
|
|
|
|
currency => 'USD', |
90
|
|
|
|
|
|
|
amount => '250.00'); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$withdraw->payment_method_id('kwji-wefwe-ewrgeurg-wef'); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$response = $withdraw->to_payment; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Or, to a Coinbase account |
97
|
|
|
|
|
|
|
$withdraw->coinbase_account_id('woifhe-i234h-fwikn-wfihwe'); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$response = $withdraw->to_coinbase; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Or, to a Crypto address |
102
|
|
|
|
|
|
|
$withdraw->crypto_address('1PtbhinXWpKZjD7CXfFR7kG8RF8vJTMCxA'); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 DESCRIPTION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Used to transfer funds out of your GDAX account, either to a |
107
|
|
|
|
|
|
|
predefined Payment Method or your Coinbase account. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Both methods require the same two attributes: "amount" and "currency" |
110
|
|
|
|
|
|
|
to be set, along with their corresponding payment or coinbase account |
111
|
|
|
|
|
|
|
id's. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C<payment_method_id> $string |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
ID of the payment method. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<coinbase_account_id> $string |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
ID of the coinbase account. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 C<crypto_address> $string |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Withdraw funds to a crypto address. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C<amount> $number |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The amount to be withdrawn. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 C<currency> $currency_string |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The currency of the amount -- for example "USD". |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 C<to_payment> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
All attributes must be set before calling this method. The return |
140
|
|
|
|
|
|
|
value is a hash that will describe the result of the payment. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
From the current GDAX API documentation, this is how that returned hash is |
143
|
|
|
|
|
|
|
keyed: |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
{ |
146
|
|
|
|
|
|
|
"id":"593533d2-ff31-46e0-b22e-ca754147a96a", |
147
|
|
|
|
|
|
|
"amount": "10.00", |
148
|
|
|
|
|
|
|
"currency": "USD", |
149
|
|
|
|
|
|
|
"payout_at": "2016-08-20T00:31:09Z" |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 C<to_coinbase> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
All attributes must be set before calling this method. The return |
155
|
|
|
|
|
|
|
value is a hash that will describe the result of the funds move. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
From the current GDAX API documentation, this is how that returned hash is |
158
|
|
|
|
|
|
|
keyed: |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
{ |
161
|
|
|
|
|
|
|
"id":"593533d2-ff31-46e0-b22e-ca754147a96a", |
162
|
|
|
|
|
|
|
"amount":"10.00", |
163
|
|
|
|
|
|
|
"currency": "BTC", |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 C<to_crypto> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
All attributes must be set before calling this method. The return |
169
|
|
|
|
|
|
|
value is a hash that will describe the result of the funds move. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
From the current GDAX API documentation, this is how that returned hash is |
172
|
|
|
|
|
|
|
keyed: |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
{ |
175
|
|
|
|
|
|
|
"id":"593533d2-ff31-46e0-b22e-ca754147a96a", |
176
|
|
|
|
|
|
|
"amount":"10.00", |
177
|
|
|
|
|
|
|
"currency": "BTC", |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 AUTHOR |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Mark Rushing <mark@orbislumen.net> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Home Grown Systems, SPC. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
192
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|