Fetching current biddings from server menu. No extracting biddings from the response and merging into the model yet.
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include <QRestReply>
|
||||
|
||||
#include "../genericcore.h"
|
||||
#include "../structs.h"
|
||||
#include "apiroutes.h"
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
@ -19,6 +20,7 @@ ServerCommunicator::ServerCommunicator(GenericCore* core)
|
||||
|
||||
connect(m_core, &GenericCore::sendGetRequest, this,
|
||||
&ServerCommunicator::onSendGetRequestTriggered);
|
||||
connect(this, &ServerCommunicator::biddingsChanged, m_core, &GenericCore::onBiddingsChanged);
|
||||
}
|
||||
|
||||
bool ServerCommunicator::sslSupported() const {
|
||||
@ -126,6 +128,10 @@ void ServerCommunicator::onSendGetRequestTriggered(const GetRequestTypes type) {
|
||||
case StopCurrentBiddingRound:
|
||||
path = ROUTE_STOP_BIDDINGROUND;
|
||||
break;
|
||||
// case GetBiddingsOfSpecificRound:
|
||||
case GetBiddingsOfHighestRound:
|
||||
path = ROUTE_GET_BIDDINGS_OF_HIGHEST_ROUND;
|
||||
break;
|
||||
default:
|
||||
qWarning() << "No route found for GetRequestType:" << type;
|
||||
break;
|
||||
@ -166,6 +172,9 @@ void ServerCommunicator::onGetReplySuccessful(const GetRequestTypes type, const
|
||||
case StopCurrentBiddingRound:
|
||||
currentBiddingRoundChangedReply(doc);
|
||||
break;
|
||||
case GetBiddingsOfHighestRound:
|
||||
currentBiddingsReply(doc);
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Can't match request type:" << type;
|
||||
break;
|
||||
@ -185,5 +194,22 @@ void ServerCommunicator::currentBiddingRoundChangedReply(const QJsonDocument jso
|
||||
const bool stopped = rootObject["stopped"].toBool();
|
||||
const bool isActive = !stopped;
|
||||
|
||||
// NOTE ?use ServerCommunicator::currentBiddingRoundChanged signal instead of emiting a signal of
|
||||
// the core directly?
|
||||
emit m_core->currentBiddingRoundChanged(roundNumber, isActive);
|
||||
}
|
||||
|
||||
void ServerCommunicator::currentBiddingsReply(const QJsonDocument jsonDoc) {
|
||||
qCritical() << "currentBiddingsReply:" << jsonDoc;
|
||||
|
||||
// NEXT extract biddings from jsonDoc
|
||||
const int roundNumber = 0;
|
||||
const bidding dummyBidding{.userId = QUuid(),
|
||||
.biddingRound = 0,
|
||||
.amount = 123,
|
||||
.depotWishOne = "one",
|
||||
.depotWishTwo = "two"};
|
||||
const QList<bidding> biddings{dummyBidding};
|
||||
|
||||
emit biddingsChanged(roundNumber, biddings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user