public function sendRequest($method, $endPoint, $data = '')
    {
        $data = json_encode($data);

        $headers = [
            'Authorization: Bearer ' . $this->ionicAPIToken,
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data),
        ];

        $curlHandler = curl_init();

        curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
        curl_setopt($curlHandler, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
        curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curlHandler, CURLOPT_HEADER, false);

        switch ($method) {
            case self::METHOD_POST:
                curl_setopt($curlHandler, CURLOPT_POST, true);
                break;

            case self::METHOD_GET:
            case self::METHOD_DELETE:
            case self::METHOD_PATCH:
                curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
                break;
        }

        if (!empty($data)) {
            curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $data);
        }

        curl_setopt($curlHandler, CURLINFO_HEADER_OUT, true);
        curl_setopt($curlHandler, CURLOPT_URL, self::$ionicBaseURL . $endPoint);

        $response = curl_exec($curlHandler);

        $statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);

        curl_close($curlHandler);

        $response = json_decode($response);

        if (!$this->isSuccessResponse($statusCode)) {
            $this->throwRequestException($statusCode, $response);
        }

        // Return response.
        return $response;
    }