magpie/API/requests/currencies.cpp

19 lines
648 B
C++
Raw Normal View History

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