protected function setOptions($url, $method, $params, $vars) {
    if(!empty($params)) {
      $url = $url . "?" . http_build_query($params);
    }

    curl_setopt($this->request, CURLOPT_URL, $url);
    curl_setopt($this->request, CURLOPT_HEADER, true);
    curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, true);

    if (in_array($method, array('POST', 'PUT')) || ($method == 'GET' && !empty($vars))) {
      $this->setJSONPayload($vars);
    }

    $headers = array();
    foreach ($this->headers as $key => $value) {
      $headers[] = $key . ':' . $value;
    }

    curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
  }