public function requestJson($method, $url, $data = null)
    {
        $response = $this->request($method, $url, $data);

        $json = json_decode($response, true);
        if ($json === null) {
            throw new Error('API responded with invalid JSON');
        }

        return $json;
    }