protected function prepareRequest()
    {
        // Set data for GET queries
        if ($this->method === static::GET && !empty($this->data)) {
            $url = trim($this->url, '/') . '?';
            $url .= http_build_query($this->data);
        } else {
            $url = $this->url;
        }

        // Set options
        $options = array(
            CURLOPT_URL => $url,
            CURLOPT_POST => $this->method === static::POST,
            CURLOPT_HEADER => true,
            CURLOPT_NOBODY => $this->method === static::HEAD,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_USERAGENT => $this->userAgent,
            CURLOPT_SSL_VERIFYPEER => false
        );

        if (!in_array($this->method, [static::GET, static::HEAD, static::POST])) {
            $options[CURLOPT_CUSTOMREQUEST] = $this->method;
        }

        // Set data for not GET queries
        if (!empty($this->data) && $this->method !== static::GET) {
            $options[CURLOPT_POSTFIELDS] = http_build_query($this->data);
        }

        // Set headers if needed
        if (!empty($this->headers)) {
            $headersToSend = [];
            foreach ($this->headers as $key => $value) {
                $headersToSend[] = "{$key}: {$value}";
            }
            $options[CURLOPT_HTTPHEADER] = $headersToSend;
        }

        // Set cookies if needed
        if (!empty($this->cookies)) {
            $cookiesToSend = [];
            foreach ($this->cookies as $key => $value) {
                $cookiesToSend[] = "{$key}={$value}";
            }
            $options[CURLOPT_COOKIE] = implode('; ', $cookiesToSend);
        }

        curl_setopt_array($this->resource, $options);
    }