public function generateSignature($data, $key = null)
    {
        if ($key === null) {
            $key = $this->getApiKey();
            if ($key === null || empty($key)) {
                throw new \InvalidArgumentException('Invalid API key!');
            }
        }

        $query = http_build_query($data);
        $query = utf8_encode(str_replace('%3A', ':', $query));

        $hash = preg_replace(
            '/\+/', '%2B',
            // base64_encode(hash_hmac('sha1', http_build_query($data), $key, true))
            base64_encode(hash_hmac('sha1', $query, $key, true))
        );
        return $hash;
    }