private function makeRequest($method, $request, $params = [], $headers = [])
    {
        $url = $this->getEndpoint() . '/' . $method;

        if ($params && ($request == self::METHOD_GET || $request == self::METHOD_DELETE)) {
            $url .= '?' . http_build_query($params);
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, 'WhenIWork-PHP/' . static::VERSION);

        $headers += $this->getHeaders();

        $headers['Content-Type'] = 'application/json';
        if ($this->api_token) {
            $headers['W-Token'] = $this->api_token;
        }

        $headers_data = [];
        foreach ($headers as $k => $v) {
            $headers_data[] = $k . ': ' . $v;
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_data);

        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($request));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);

        if (in_array($request, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH])) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
        }

        $result = curl_exec($ch);
        curl_close($ch);

        return $result ? json_decode($result) : false;
    }
private function makeRequest($method, $request, $params = [], $headers = [])
    {
        $url = $this->getEndpoint() . '/' . $method;

        if ($params && ($request == self::METHOD_GET || $request == self::METHOD_DELETE)) {
            $url .= '?' . http_build_query($params);
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, 'WhenIWork-PHP/' . static::VERSION);

        $headers += $this->getHeaders();

        $headers['Content-Type'] = 'application/json';
        if ($this->api_token) {
            $headers['W-Token'] = $this->api_token;
        }

        $headers_data = [];
        foreach ($headers as $k => $v) {
            $headers_data[] = $k . ': ' . $v;
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_data);

        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($request));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);

        if (in_array($request, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH])) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
        }

        $result = curl_exec($ch);
        curl_close($ch);

        return $result ? json_decode($result) : false;
    }
private function makeRequest ( $ method , $ request , $ params = [ ] , $ headers = [ ] ) { $ url = $ this -> getEndpoint ( ) . '/' . $ method ; if ( $ params && ( $ request == self :: METHOD_GET || $ request == self :: METHOD_DELETE ) ) { $ url .= '?' . http_build_query ( $ params ) ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , 'WhenIWork-PHP/' . static :: VERSION ) ; $ headers += $ this -> getHeaders ( ) ; $ headers [ 'Content-Type' ] = 'application/json' ; if ( $ this -> api_token ) { $ headers [ 'W-Token' ] = $ this -> api_token ; } $ headers_data = [ ] ; foreach ( $ headers as $ k => $ v ) { $ headers_data [ ] = $ k . ': ' . $ v ; } curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers_data ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , strtoupper ( $ request ) ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , false ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , 10 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> verify_ssl ) ; if ( in_array ( $ request , [ self :: METHOD_POST , self :: METHOD_PUT , self :: METHOD_PATCH ] ) ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , json_encode ( $ params ) ) ; } $ result = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ result ? json_decode ( $ result ) : false ; }
Performs the underlying HTTP request. Exciting stuff happening here. Not really.

@param  string $method The API method to be called
@param  string $request The type of request
@param  array $params Assoc array of parameters to be passed
@param  array $headers Assoc array of custom headers to be passed
@return array           Assoc array of decoded result
Performs the underlying HTTP request . Exciting stuff happening here . Not really .