magpie/API/requests/listassets.cpp

19 lines
634 B
C++

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#include "listassets.h"
#include "API/helpers.h"
Request::ListAssets::ListAssets (const QUrl& baseUrl):
Request(createUrl(baseUrl, "/listAssets")) {}
void Request::ListAssets::onSuccess (const QVariantMap& data) {
QVariantMap::ConstIterator itr = data.find("assets");
if (itr == data.constEnd() || !itr->canConvert<QVariantList>())
return Request::onError("Error receiving assets: assets are missing or not in an array", std::nullopt);
emit success(qast<QVariantList>(itr.value()));
emit done();
}