| 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 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @param string|null $marketSymbol | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @throws Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  |     public function getOrderHistory(?string $marketSymbol = null): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 1 |  |         $parameters = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 1 |  |         if (!is_null($marketSymbol)) $parameters['marketSymbol'] = $marketSymbol; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  |         return $this->get('/orders/closed', $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @param string|null $currencySymbol | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @param string|null $status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @throws Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  |     public function getWithdrawalHistory(?string $currencySymbol = null, ?string $status = null): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 1 |  |         $parameters = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 1 |  |         if (!is_null($currencySymbol)) $parameters['currencySymbol'] = $currencySymbol; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  |         if (!is_null($status)) $parameters['status'] = $status; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 1 |  |         return $this->get('/withdrawals/closed', $parameters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param string|null $currencySymbol | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param string|null $status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @throws Exception | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 113 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 114 | 1 |  |     public function getDepositHistory(?string $currencySymbol = null, ?string $status = null): array | 
            
                                                        
            
                                    
            
            
                | 115 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 116 | 1 |  |         $parameters = []; | 
            
                                                        
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 118 | 1 |  |         if (!is_null($currencySymbol)) $parameters['currencySymbol'] = $currencySymbol; | 
            
                                                        
            
                                    
            
            
                | 119 | 1 |  |         if (!is_null($status)) $parameters['status'] = $status; | 
            
                                                        
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 121 | 1 |  |         return $this->get('/deposits/closed', $parameters); | 
            
                                                        
            
                                    
            
            
                | 122 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 123 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 124 |  |  |  |