Debugged changing of the assets
This commit is contained in:
parent
aa815a5bd7
commit
4ed280a550
6 changed files with 51 additions and 3 deletions
13
API/api.cpp
13
API/api.cpp
|
@ -15,6 +15,7 @@
|
|||
#include "requests/currencies.h"
|
||||
#include "requests/addasset.h"
|
||||
#include "requests/deleteasset.h"
|
||||
#include "requests/updateasset.h"
|
||||
|
||||
API::API (Models::Magpie& magpie, QObject* parent):
|
||||
QObject(parent),
|
||||
|
@ -136,7 +137,17 @@ API::RequestId API::updateAsset (
|
|||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QJSValue& finished
|
||||
) {}
|
||||
) {
|
||||
qDebug() << "Updating asset...";
|
||||
if (magpie.getState() != Models::Magpie::Authenticated)
|
||||
return callCallback(finished, "Can not update assets in current state"), 0;
|
||||
|
||||
auto update = std::make_unique<Request::UpdateAsset>(id, title, icon, color, currency, magpie.getAddress());
|
||||
update->setAuthorizationToken(magpie.getAccessToken());
|
||||
connect(update.get(), &Request::UpdateAsset::success, std::bind(&API::callCallback, this, finished, QString(), QJSValueList{QJSValue(true)}));
|
||||
connect(update.get(), &Request::UpdateAsset::error, std::bind(&API::callCallback, this, finished, std::placeholders::_1, QJSValueList{QJSValue(false)}));
|
||||
return registerAndSend(std::move(update));
|
||||
}
|
||||
|
||||
API::RequestId API::deleteAsset (unsigned int id, const QJSValue& finished) {
|
||||
qDebug() << "Deleting asset...";
|
||||
|
|
|
@ -47,6 +47,14 @@ public slots:
|
|||
Models::Currency::ID currency,
|
||||
const QJSValue& finished = QJSValue()
|
||||
);
|
||||
RequestId updateAsset(
|
||||
Models::Asset::ID id,
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QJSValue& finished = QJSValue()
|
||||
);
|
||||
RequestId deleteAsset(unsigned int id, const QJSValue& finished = QJSValue());
|
||||
|
||||
private slots:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue