tested currencies retrieval, now assets display the currency
This commit is contained in:
parent
45f924a4cf
commit
cf2f387f58
14 changed files with 137 additions and 27 deletions
|
@ -8,7 +8,8 @@ set(HEADERS
|
|||
register.h
|
||||
login.h
|
||||
poll.h
|
||||
listassets.h
|
||||
assets.h
|
||||
currencies.h
|
||||
addasset.h
|
||||
deleteasset.h
|
||||
)
|
||||
|
@ -20,7 +21,8 @@ set(SOURCES
|
|||
register.cpp
|
||||
login.cpp
|
||||
poll.cpp
|
||||
listassets.cpp
|
||||
assets.cpp
|
||||
currencies.cpp
|
||||
addasset.cpp
|
||||
deleteasset.cpp
|
||||
)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
||||
//SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "listassets.h"
|
||||
#include "assets.h"
|
||||
|
||||
#include "utils/helpers.h"
|
||||
|
||||
Request::ListAssets::ListAssets (const QUrl& baseUrl):
|
||||
Request(createUrl(baseUrl, "/listAssets")) {}
|
||||
Request::Assets::Assets (const QUrl& baseUrl):
|
||||
Request(createUrl(baseUrl, "/assets")) {}
|
||||
|
||||
void Request::ListAssets::onSuccess (const QVariantMap& data) {
|
||||
void Request::Assets::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);
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
namespace Request {
|
||||
|
||||
class ListAssets : public Request {
|
||||
class Assets : public Request {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ListAssets (const QUrl& baseUrl);
|
||||
Assets (const QUrl& baseUrl);
|
||||
|
||||
signals:
|
||||
void success(const QVariantList& assets);
|
18
API/requests/currencies.cpp
Normal file
18
API/requests/currencies.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
//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();
|
||||
}
|
24
API/requests/currencies.h
Normal file
24
API/requests/currencies.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
||||
//SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "request.h"
|
||||
|
||||
namespace Request {
|
||||
|
||||
class Currencies : public Request::Request {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Currencies (const QUrl& baseUrl);
|
||||
|
||||
signals:
|
||||
void success(const QVariantList& assets);
|
||||
|
||||
protected:
|
||||
void onSuccess (const QVariantMap& data) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue