Routing the received biddings to the model. Just debug outputs there yet.
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "../model/metadata.h"
|
||||
#include "../structs.h"
|
||||
|
||||
QList<ModelItemValues> JsonParser::toItemValuesList(const QByteArray& jsonData,
|
||||
const QString& rootValueName) {
|
||||
@ -106,6 +107,29 @@ ModelItemValues JsonParser::serverUserCredentialsToItemValues(const QJsonDocumen
|
||||
return values;
|
||||
}
|
||||
|
||||
QList<bidding> JsonParser::extractBiddings(const QJsonDocument& jsonDoc) {
|
||||
QList<bidding> result;
|
||||
|
||||
if (jsonDoc.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
QJsonArray itemArray = JsonParser::extractItemArray(jsonDoc, "data");
|
||||
|
||||
foreach (QJsonValue value, itemArray) {
|
||||
// REFACTOR implement & use "JsonParser::parseServerResponse(const QJsonObject& object,
|
||||
// QHash<QString, int> entries)"
|
||||
QJsonObject itemJsonObject = value.toObject();
|
||||
bidding values{.userId = QUuid(itemJsonObject.value("user_id").toString()),
|
||||
.biddingRound = itemJsonObject.value("bidding_round").toInt(),
|
||||
.amount = itemJsonObject.value("amount").toInt(),
|
||||
.depotWishOne = itemJsonObject.value("depot_wish_one").toString(),
|
||||
.depotWishTwo = itemJsonObject.value("depot_wish_two").toString()};
|
||||
result.append(values);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QJsonArray JsonParser::extractItemArray(const QJsonDocument& doc, const QString& objectName) {
|
||||
QJsonArray itemArray;
|
||||
if (objectName.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user