protected function requestBuilder($uri, $method=self::GET, array $body=[])
    {
        $this->internalCurl->reset();
        foreach ($this->options as $option => $value) {
            $this->internalCurl->setOpt($option, $value);
        }

        $url = self::BILLS_URI.$uri;
        $this->internalCurl->setHeader('Accept', 'application/json');
        $this->internalCurl->setHeader('Authorization', 'Bearer '.$this->secretKey);
        switch ($method) {
        case self::GET:
            $this->internalCurl->get($url);
            break;
        case self::POST:
            $this->internalCurl->setHeader('Content-Type', 'application/json;charset=UTF-8');
            $this->internalCurl->post($url, json_encode($body, JSON_UNESCAPED_UNICODE));
            break;
        case self::PUT:
            $this->internalCurl->setHeader('Content-Type', 'application/json;charset=UTF-8');
            $this->internalCurl->put($url, json_encode($body, JSON_UNESCAPED_UNICODE), true);
            break;
        default:
            throw new Exception('Not supported method '.$method.'.');
        }

        if (true === $this->internalCurl->error) {
            throw new BillPaymentsException(clone $this->internalCurl);
        }

        if (false === empty($this->internalCurl->response)) {
            return @json_decode($this->internalCurl->response, true);
        }

        return true;

    }
protected function requestBuilder($uri, $method=self::GET, array $body=[])
    {
        $this->internalCurl->reset();
        foreach ($this->options as $option => $value) {
            $this->internalCurl->setOpt($option, $value);
        }

        $url = self::BILLS_URI.$uri;
        $this->internalCurl->setHeader('Accept', 'application/json');
        $this->internalCurl->setHeader('Authorization', 'Bearer '.$this->secretKey);
        switch ($method) {
        case self::GET:
            $this->internalCurl->get($url);
            break;
        case self::POST:
            $this->internalCurl->setHeader('Content-Type', 'application/json;charset=UTF-8');
            $this->internalCurl->post($url, json_encode($body, JSON_UNESCAPED_UNICODE));
            break;
        case self::PUT:
            $this->internalCurl->setHeader('Content-Type', 'application/json;charset=UTF-8');
            $this->internalCurl->put($url, json_encode($body, JSON_UNESCAPED_UNICODE), true);
            break;
        default:
            throw new Exception('Not supported method '.$method.'.');
        }

        if (true === $this->internalCurl->error) {
            throw new BillPaymentsException(clone $this->internalCurl);
        }

        if (false === empty($this->internalCurl->response)) {
            return @json_decode($this->internalCurl->response, true);
        }

        return true;

    }
protected function requestBuilder ( $ uri , $ method = self :: GET , array $ body = [ ] ) { $ this -> internalCurl -> reset ( ) ; foreach ( $ this -> options as $ option => $ value ) { $ this -> internalCurl -> setOpt ( $ option , $ value ) ; } $ url = self :: BILLS_URI . $ uri ; $ this -> internalCurl -> setHeader ( 'Accept' , 'application/json' ) ; $ this -> internalCurl -> setHeader ( 'Authorization' , 'Bearer ' . $ this -> secretKey ) ; switch ( $ method ) { case self :: GET : $ this -> internalCurl -> get ( $ url ) ; break ; case self :: POST : $ this -> internalCurl -> setHeader ( 'Content-Type' , 'application/json;charset=UTF-8' ) ; $ this -> internalCurl -> post ( $ url , json_encode ( $ body , JSON_UNESCAPED_UNICODE ) ) ; break ; case self :: PUT : $ this -> internalCurl -> setHeader ( 'Content-Type' , 'application/json;charset=UTF-8' ) ; $ this -> internalCurl -> put ( $ url , json_encode ( $ body , JSON_UNESCAPED_UNICODE ) , true ) ; break ; default : throw new Exception ( 'Not supported method ' . $ method . '.' ) ; } if ( true === $ this -> internalCurl -> error ) { throw new BillPaymentsException ( clone $ this -> internalCurl ) ; } if ( false === empty ( $ this -> internalCurl -> response ) ) { return @ json_decode ( $ this -> internalCurl -> response , true ) ; } return true ; }
Build request.

@param string $uri    The url.
@param string $method The method.
@param array  $body   The body.

@return bool|array Return response.

@throws Exception Throw on unsupported $method use.
@throws BillPaymentsException Throw on API return invalid response.
Build request .