|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace R3bers\BittrexApi\Api; |
|
6
|
|
|
|
|
7
|
|
|
use Exception; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class Account |
|
11
|
|
|
* @package R3bers\BittrexApi\Api |
|
12
|
|
|
*/ |
|
13
|
|
|
class Account extends Api |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @return array |
|
17
|
|
|
* @throws Exception |
|
18
|
|
|
*/ |
|
19
|
1 |
|
public function getBalances(): array |
|
20
|
|
|
{ |
|
21
|
1 |
|
return $this->get('/balances'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param string $currency |
|
26
|
|
|
* @return array |
|
27
|
|
|
* @throws Exception |
|
28
|
|
|
*/ |
|
29
|
1 |
|
public function getBalance(string $currency): array |
|
30
|
|
|
{ |
|
31
|
1 |
|
return $this->get('/balances/' . $currency); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param string $currency |
|
36
|
|
|
* @return array |
|
37
|
|
|
* @throws Exception |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function getDepositAddress(string $currency): array |
|
40
|
|
|
{ |
|
41
|
1 |
|
return $this->get('/addresses/' . $currency); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $currency |
|
46
|
|
|
* @param float $quantity |
|
47
|
|
|
* @param string $address |
|
48
|
|
|
* @param string|null $paymentId |
|
49
|
|
|
* @return array |
|
50
|
|
|
* @throws Exception |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function withdraw(string $currency, float $quantity, string $address, ?string $paymentId = null): array |
|
53
|
|
|
{ |
|
54
|
|
|
$newWithdrawal = [ |
|
55
|
1 |
|
'currencySymbol' => $currency, |
|
56
|
1 |
|
'quantity' => $quantity, |
|
57
|
1 |
|
'cryptoAddress' => $address, |
|
58
|
|
|
]; |
|
59
|
|
|
|
|
60
|
1 |
|
if (!is_null($paymentId)) { |
|
61
|
1 |
|
$newWithdrawal['cryptoAddressTag'] = $paymentId; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
1 |
|
return $this->post('/withdrawals', json_encode($newWithdrawal)); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param string $uuid |
|
69
|
|
|
* @return array |
|
70
|
|
|
* @throws Exception |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function getOrder(string $uuid): array |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->get('/orders/' . $uuid); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function getOrderHistory(?string $marketSymbol = null, ?string $nextPageToken = null, ?string $previousPageToken = null, ?string $pageSize = null, |
|
78
|
|
|
?string $startDate = null, ?string $endDate = null): array |
|
79
|
|
|
{ |
|
80
|
1 |
|
$parameters = $this->historyPagination($nextPageToken, $previousPageToken, $pageSize, $startDate, $endDate); |
|
81
|
|
|
|
|
82
|
1 |
|
if (!is_null($marketSymbol)) $parameters['marketSymbol'] = $marketSymbol; |
|
83
|
|
|
|
|
84
|
1 |
|
return $this->get('/orders/closed', $parameters); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param string|null $nextPageToken |
|
89
|
|
|
* @param string|null $previousPageToken |
|
90
|
|
|
* @param string|null $pageSize |
|
91
|
|
|
* @param string|null $startDate |
|
92
|
|
|
* @param string|null $endDate |
|
93
|
|
|
* @return array |
|
94
|
|
|
*/ |
|
95
|
3 |
|
private function historyPagination(?string $nextPageToken = null, ?string $previousPageToken = null, ?string $pageSize = null, ?string $startDate = null, |
|
96
|
|
|
?string $endDate = null): array |
|
97
|
|
|
{ |
|
98
|
3 |
|
$pagination = []; |
|
99
|
|
|
|
|
100
|
3 |
|
if (!is_null($nextPageToken)) $pagination['nextPageToken'] = $nextPageToken; |
|
101
|
3 |
|
if (!is_null($previousPageToken)) $pagination['previousPageToken'] = $previousPageToken; |
|
102
|
3 |
|
if (!is_null($pageSize)) $pagination['pageSize'] = $pageSize; |
|
103
|
3 |
|
if (!is_null($startDate)) $pagination['startDate'] = $startDate; |
|
104
|
3 |
|
if (!is_null($endDate)) $pagination['endDate'] = $endDate; |
|
105
|
|
|
|
|
106
|
3 |
|
return $pagination; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param string|null $currencySymbol |
|
111
|
|
|
* @param string|null $status |
|
112
|
|
|
* @param string|null $nextPageToken |
|
113
|
|
|
* @param string|null $previousPageToken |
|
114
|
|
|
* @param string|null $pageSize |
|
115
|
|
|
* @param string|null $startDate |
|
116
|
|
|
* @param string|null $endDate |
|
117
|
|
|
* @return array |
|
118
|
|
|
* @throws Exception |
|
119
|
|
|
*/ |
|
120
|
1 |
|
public function getWithdrawalHistory(?string $currencySymbol = null, ?string $status = null, ?string $nextPageToken = null, ?string $previousPageToken = null, |
|
121
|
|
|
?string $pageSize = null, ?string $startDate = null, ?string $endDate = null): array |
|
122
|
|
|
{ |
|
123
|
1 |
|
$parameters = $this->historyPagination($nextPageToken, $previousPageToken, $pageSize, $startDate, $endDate); |
|
124
|
|
|
|
|
125
|
1 |
|
if (!is_null($currencySymbol)) $parameters['currencySymbol'] = $currencySymbol; |
|
126
|
1 |
|
if (!is_null($status)) $parameters['status'] = $status; |
|
127
|
|
|
|
|
128
|
1 |
|
return $this->get('/withdrawals/closed', $parameters); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @param string|null $currencySymbol |
|
133
|
|
|
* @param string|null $status |
|
134
|
|
|
* @param string|null $nextPageToken |
|
135
|
|
|
* @param string|null $previousPageToken |
|
136
|
|
|
* @param string|null $pageSize |
|
137
|
|
|
* @param string|null $startDate |
|
138
|
|
|
* @param string|null $endDate |
|
139
|
|
|
* @return array |
|
140
|
|
|
* @throws Exception |
|
141
|
|
|
*/ |
|
142
|
1 |
|
public function getDepositHistory(?string $currencySymbol = null, ?string $status = null, ?string $nextPageToken = null, ?string $previousPageToken = null, |
|
143
|
|
|
?string $pageSize = null, ?string $startDate = null, ?string $endDate = null): array |
|
144
|
|
|
{ |
|
145
|
1 |
|
$parameters = $this->historyPagination($nextPageToken, $previousPageToken, $pageSize, $startDate, $endDate); |
|
146
|
|
|
|
|
147
|
1 |
|
if (!is_null($currencySymbol)) $parameters['currencySymbol'] = $currencySymbol; |
|
148
|
1 |
|
if (!is_null($status)) $parameters['status'] = $status; |
|
149
|
|
|
|
|
150
|
1 |
|
return $this->get('/deposits/closed', $parameters); |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|