protected function _makeApiRequest($type, $endPoint, $securityType = 'NONE', $params = [])
    {
        $params = array_filter($params, 'strlen');

        switch (strtoupper($securityType)) {
            default:
            case 'NONE':
                $client = new Client(['http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION . $endPoint;
                break;
            case 'API-KEY':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION . $endPoint;
                break;
            case 'SIGNED':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION_SIGNED . $endPoint;
                $params['signature'] = hash_hmac('sha256', http_build_query($params), $this->_apiSecret);
                break;
            case 'WAPI_SIGNED':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . $endPoint;
                $params['signature'] = hash_hmac('sha256', http_build_query($params), $this->_apiSecret);
                break;
        }

        switch (strtoupper($type)) {
            default:
            case 'GET':
                $params['query'] = $params;
                break;
            case 'POST':
            case 'PUT':
            case 'DELETE':
                $params['form_params'] = $params;
                break;
            case 'POSTV2':
                $type = 'POST';
                $params['query'] = $params;
                break;
        }

        $response = $client->request(strtoupper($type), $url, $params);

        if ($response->getStatusCode() < 200 || $response->getStatusCode() > 299) {
            throw new BinanceApiException($response->getBody()->getContents());
        }

        return $response;
    }
protected function _makeApiRequest($type, $endPoint, $securityType = 'NONE', $params = [])
    {
        $params = array_filter($params, 'strlen');

        switch (strtoupper($securityType)) {
            default:
            case 'NONE':
                $client = new Client(['http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION . $endPoint;
                break;
            case 'API-KEY':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION . $endPoint;
                break;
            case 'SIGNED':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . ConnectionDetails::API_VERSION_SIGNED . $endPoint;
                $params['signature'] = hash_hmac('sha256', http_build_query($params), $this->_apiSecret);
                break;
            case 'WAPI_SIGNED':
                $client = new Client(['headers' => ['X-MBX-APIKEY' => $this->_apiKey], 'http_errors' => false]);
                $url = ConnectionDetails::API_URL . $endPoint;
                $params['signature'] = hash_hmac('sha256', http_build_query($params), $this->_apiSecret);
                break;
        }

        switch (strtoupper($type)) {
            default:
            case 'GET':
                $params['query'] = $params;
                break;
            case 'POST':
            case 'PUT':
            case 'DELETE':
                $params['form_params'] = $params;
                break;
            case 'POSTV2':
                $type = 'POST';
                $params['query'] = $params;
                break;
        }

        $response = $client->request(strtoupper($type), $url, $params);

        if ($response->getStatusCode() < 200 || $response->getStatusCode() > 299) {
            throw new BinanceApiException($response->getBody()->getContents());
        }

        return $response;
    }
protected function _makeApiRequest ( $ type , $ endPoint , $ securityType = 'NONE' , $ params = [ ] ) { $ params = array_filter ( $ params , 'strlen' ) ; switch ( strtoupper ( $ securityType ) ) { default : case 'NONE' : $ client = new Client ( [ 'http_errors' => false ] ) ; $ url = ConnectionDetails :: API_URL . ConnectionDetails :: API_VERSION . $ endPoint ; break ; case 'API-KEY' : $ client = new Client ( [ 'headers' => [ 'X-MBX-APIKEY' => $ this -> _apiKey ] , 'http_errors' => false ] ) ; $ url = ConnectionDetails :: API_URL . ConnectionDetails :: API_VERSION . $ endPoint ; break ; case 'SIGNED' : $ client = new Client ( [ 'headers' => [ 'X-MBX-APIKEY' => $ this -> _apiKey ] , 'http_errors' => false ] ) ; $ url = ConnectionDetails :: API_URL . ConnectionDetails :: API_VERSION_SIGNED . $ endPoint ; $ params [ 'signature' ] = hash_hmac ( 'sha256' , http_build_query ( $ params ) , $ this -> _apiSecret ) ; break ; case 'WAPI_SIGNED' : $ client = new Client ( [ 'headers' => [ 'X-MBX-APIKEY' => $ this -> _apiKey ] , 'http_errors' => false ] ) ; $ url = ConnectionDetails :: API_URL . $ endPoint ; $ params [ 'signature' ] = hash_hmac ( 'sha256' , http_build_query ( $ params ) , $ this -> _apiSecret ) ; break ; } switch ( strtoupper ( $ type ) ) { default : case 'GET' : $ params [ 'query' ] = $ params ; break ; case 'POST' : case 'PUT' : case 'DELETE' : $ params [ 'form_params' ] = $ params ; break ; case 'POSTV2' : $ type = 'POST' ; $ params [ 'query' ] = $ params ; break ; } $ response = $ client -> request ( strtoupper ( $ type ) , $ url , $ params ) ; if ( $ response -> getStatusCode ( ) < 200 || $ response -> getStatusCode ( ) > 299 ) { throw new BinanceApiException ( $ response -> getBody ( ) -> getContents ( ) ) ; } return $ response ; }
Does an HTTP request to the given endpoint with the given parameters.

@param string $type         The HTTP method.
@param string $endPoint     The API endpoint.
@param string $securityType Security type enum.
@param array  $params       Additional parameters.

@return \Psr\Http\Message\ResponseInterface
@throws BinanceApiException
Does an HTTP request to the given endpoint with the given parameters .