protected function doRequest($type, $endpoint, $params=[])
    {
    	$base = ($this->useSSL) ? "https" : "http";
    	$url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
	    
		if ($this->useBasicAuth)
            $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
        else
            $auth = $this->secret;
	    
    	$headers = array(
  			'Accept' => 'application/json',
  			'Authorization' => $auth,
            'Content-Type'=>'application/json'
  		);

        $body = json_encode($params);

        try {
        	$result = $this->client->request($type, $url, compact('headers','body'));
        } catch (\Exception $e) {
        	return  ['status'=>false, 'data'=>['message'=>$e->getMessage()]];
        }
	        
        
        if ($result->getStatusCode() == 200 || $result->getStatusCode() == 201) {
            return array('status'=>true, 'data'=>json_decode($result->getBody()));
        }
        return array('status'=>false, 'data'=>json_decode($result->getBody()));
    	
    }
protected function doRequest($type, $endpoint, $params=[])
    {
    	$base = ($this->useSSL) ? "https" : "http";
    	$url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint;
	    
		if ($this->useBasicAuth)
            $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd);
        else
            $auth = $this->secret;
	    
    	$headers = array(
  			'Accept' => 'application/json',
  			'Authorization' => $auth,
            'Content-Type'=>'application/json'
  		);

        $body = json_encode($params);

        try {
        	$result = $this->client->request($type, $url, compact('headers','body'));
        } catch (\Exception $e) {
        	return  ['status'=>false, 'data'=>['message'=>$e->getMessage()]];
        }
	        
        
        if ($result->getStatusCode() == 200 || $result->getStatusCode() == 201) {
            return array('status'=>true, 'data'=>json_decode($result->getBody()));
        }
        return array('status'=>false, 'data'=>json_decode($result->getBody()));
    	
    }
protected function doRequest ( $ type , $ endpoint , $ params = [ ] ) { $ base = ( $ this -> useSSL ) ? "https" : "http" ; $ url = $ base . "://" . $ this -> host . ":" . $ this -> port . $ this -> plugin . $ endpoint ; if ( $ this -> useBasicAuth ) $ auth = 'Basic ' . base64_encode ( $ this -> basicUser . ':' . $ this -> basicPwd ) ; else $ auth = $ this -> secret ; $ headers = array ( 'Accept' => 'application/json' , 'Authorization' => $ auth , 'Content-Type' => 'application/json' ) ; $ body = json_encode ( $ params ) ; try { $ result = $ this -> client -> request ( $ type , $ url , compact ( 'headers' , 'body' ) ) ; } catch ( \ Exception $ e ) { return [ 'status' => false , 'data' => [ 'message' => $ e -> getMessage ( ) ] ] ; } if ( $ result -> getStatusCode ( ) == 200 || $ result -> getStatusCode ( ) == 201 ) { return array ( 'status' => true , 'data' => json_decode ( $ result -> getBody ( ) ) ) ; } return array ( 'status' => false , 'data' => json_decode ( $ result -> getBody ( ) ) ) ; }
Make the request and analyze the result

@param   string          $type           Request method
@param   string          $endpoint       Api request endpoint
@param   array           $params         Parameters
@return  array|false                     Array with data or error, or False when something went fully wrong
Make the request and analyze the result