magpie/API/requests/assets.cpp

19 lines
616 B
C++
Raw Normal View History

2024-01-20 21:17:21 +00:00
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#include "assets.h"
2024-01-20 21:17:21 +00:00
2024-01-21 19:22:56 +00:00
#include "utils/helpers.h"
2024-01-20 21:17:21 +00:00
Request::Assets::Assets (const QUrl& baseUrl):
Request(createUrl(baseUrl, "/assets")) {}
2024-01-20 21:17:21 +00:00
void Request::Assets::onSuccess (const QVariantMap& data) {
2024-01-20 21:17:21 +00:00
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();
}