From a455b946908c87f2606cfd8e2a2659b1aa50a8fe Mon Sep 17 00:00:00 2001 From: Munvier Date: Thu, 11 Jun 2020 13:53:21 +0200 Subject: [PATCH] Provide setter/getter for headers x-mbx-used-weight and x-mbx-used-weight-1 --- php-binance-api.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/php-binance-api.php b/php-binance-api.php index 8cd3e78e..c8e8f005 100755 --- a/php-binance-api.php +++ b/php-binance-api.php @@ -53,7 +53,10 @@ class API protected $exchangeInfo = NULL; protected $lastRequest = []; - + + private $xMbxUsedWeight = 0; + private $xMbxUsedWeight1m = 0; + /** * Constructor for the class, * send as many argument as you want. @@ -1015,7 +1018,15 @@ protected function httpRequest(string $url, string $method = "GET", array $param 'header' => $header, 'json' => $json ]; - + + if (isset($header['x-mbx-used-weight'])) { + $this->setXMbxUsedWeight($header['x-mbx-used-weight']); + } + + if (isset($header['x-mbx-used-weight-1m'])) { + $this->setXMbxUsedWeight1m($header['x-mbx-used-weight-1m']); + } + if(isset($json['msg'])){ // should always output error, not only on httpdebug // not outputing errors, hides it from users and ends up with tickets on github @@ -2347,5 +2358,22 @@ private function floorDecimal($n, $decimals=2) { return floor($n * pow(10, $decimals)) / pow(10, $decimals); } + + + private function setXMbxUsedWeight (int $usedWeight) : void { + $this->xMbxUsedWeight = $usedWeight; + } + + private function setXMbxUsedWeight1m (int $usedWeight1m) : void { + $this->xMbxUsedWeight1m = $usedWeight1m; + } + + public function getXMbxUsedWeight () : int { + $this->xMbxUsedWeight; + } + + public function getXMbxUsedWeight1m () : int { + $this->xMbxUsedWeight1m; + } }