debugging adding an asset
This commit is contained in:
parent
1597bd9522
commit
6e16292f06
6 changed files with 169 additions and 9 deletions
10
API/api.cpp
10
API/api.cpp
|
@ -281,11 +281,13 @@ void API::addAsset(const QString& title, const QString& icon, const QJSValue &fi
|
|||
|
||||
QUrlQuery params({
|
||||
{"title", title},
|
||||
{"icon", icon}
|
||||
{"icon", icon},
|
||||
{"currency", "1"}
|
||||
});
|
||||
|
||||
QNetworkRequest request(createUrl("/addAsset"));
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, urlEncoded);
|
||||
request.setRawHeader("Authorization", "Bearer " + accessToken.toUtf8());
|
||||
QNetworkReply* reply = network.post(request, params.toString(QUrl::FullyEncoded).toUtf8());
|
||||
connect(reply, &QNetworkReply::finished,
|
||||
std::bind(&API::onAssetAdded, this, reply, finished)
|
||||
|
@ -295,8 +297,8 @@ void API::addAsset(const QString& title, const QString& icon, const QJSValue &fi
|
|||
void API::onAssetAdded(QNetworkReply *reply, const QJSValue &finished) {
|
||||
std::unique_ptr<QNetworkReply, NetworkReplyDeleter> rpl(reply);
|
||||
QNetworkReply::NetworkError error = reply->error();
|
||||
std::optional<QVariantMap> data = readResult(reply);
|
||||
|
||||
qDebug() << error;
|
||||
if (error != QNetworkReply::NoError)
|
||||
return callCallback(finished, reply->errorString());
|
||||
|
||||
|
@ -332,6 +334,8 @@ void API::onPollFinished() {
|
|||
Codes::Poll code = Codes::Poll::unknownError;
|
||||
if (validateResponse(data, resultStructure))
|
||||
code = Codes::convertPoll(data->value("result").toInt());
|
||||
else
|
||||
qDebug() << "";
|
||||
|
||||
QString detail = Codes::description(code);
|
||||
|
||||
|
@ -457,7 +461,7 @@ void API::responseAssets(QNetworkReply *reply) {
|
|||
}
|
||||
|
||||
QVariantMap::ConstIterator itr = data->find("assets");
|
||||
if (itr == data->end() || !itr->canConvert<QVariantList>()) {
|
||||
if (itr == data->constEnd() || !itr->canConvert<QVariantList>()) {
|
||||
qDebug() << "Error receiving assets: assets are missing or not in an array";
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue