| 1 | package Finance::GDAX::API::Withdrawl; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||
| 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 'crypto_address' => (is => 'rw', | |||||||||||||||||||||||||||||||||||||||||
| 19 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | has 'amount' => (is => 'rw', | |||||||||||||||||||||||||||||||||||||||||
| 22 | isa => 'PositiveNum', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | has 'currency' => (is => 'rw', | |||||||||||||||||||||||||||||||||||||||||
| 25 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | sub to_payment { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_payment: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | unless ($self->payment_method_id && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->payment_method_id and $self->amount and $self->currency
$self->payment_method_id and $self->amount
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
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | $self->amount && | ||||||||||||||||||||||||||||||||||||||||||
| 32 | $self->currency) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | die 'payments need amount and currency set'; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->path('/withdrawls/payment-method'); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $self->method('POST'); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $self->body({ amount => $self->amount, | |||||||||||||||||||||||||||||||||||||||||
| 38 | currency => $self->currency, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | payment_method_id => $self->payment_method_id, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | return $self->send; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub to_coinbase { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_coinbase: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | unless ($self->coinbase_account_id && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->coinbase_account_id and $self->amount and $self->currency
$self->coinbase_account_id and $self->amount
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
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | $self->amount && | ||||||||||||||||||||||||||||||||||||||||||
| 48 | $self->currency) { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | die 'coinbase needs an amount and currency set'; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->path('/withdrawls/coinbase-account'); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->method('POST'); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->body({ amount => $self->amount, | |||||||||||||||||||||||||||||||||||||||||
| 54 | currency => $self->currency, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | coinbase_account_id => $self->coinbase_account_id, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return $self->send; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | sub to_crypto { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_crypto: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | unless ($self->crypto_address && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->crypto_address and $self->amount and $self->currency
$self->crypto_address and $self->amount
MC/DC0%0/3
$self->crypto_address and $self->amount and $self->currency
$self->crypto_address
$self->amount
$self->currency
Truth table25%1/4
A and B and C
A= $self->crypto_addressB= $self->amountC= $self->currency
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | $self->amount && | ||||||||||||||||||||||||||||||||||||||||||
| 64 | $self->currency) { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | 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 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | 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 | |||||||||||||||||||||||||||||||||||||||||||