6 #ifndef SWIFT_CORE_AFV_CONNECTION_APISERVERCONNECTION_H
7 #define SWIFT_CORE_AFV_CONNECTION_APISERVERCONNECTION_H
10 #include <QJsonDocument>
11 #include <QNetworkAccessManager>
12 #include <QNetworkReply>
13 #include <QNetworkRequest>
24 namespace swift::core::afv::connection
86 template <
typename TResponse>
87 TResponse postNoRequest(
const QString &resource)
89 if (!this->sendToNetworkIfAuthenticated())
97 QUrl url(m_addressUrl);
98 url.setPath(resource);
100 request.setRawHeader(
"Authorization",
"Bearer " + m_jwt);
102 const QByteArray receivedData = this->postWithResponse(request);
104 const TResponse response = TResponse::fromJson(doc.
object());
109 template <
typename TResponse>
112 if (!this->sendToNetworkIfAuthenticated())
120 QUrl url(m_addressUrl);
121 url.setPath(resource);
123 request.setRawHeader(
"Authorization",
"Bearer " + m_jwt);
125 const QByteArray receivedData = this->getWithResponse(request);
131 for (
const auto &o : rootArray)
134 const TResponse dto = TResponse::fromJson(d);
151 void deleteResource(
const QString &resource);
166 bool sendToNetworkIfAuthenticated()
const;
169 static bool isShuttingDown();
175 QUuid m_networkVersion;
178 qint64 m_serverToUserOffsetMs;
179 bool m_isAuthenticated =
false;
const QString & getPassword() const
User data.
static const QStringList & getLogCategories()
Categories.
void removeCallsign(const QString &callsign)
Remove callsign from network.
PostCallsignResponseDto addCallsign(const QString &callsign)
Add callsign to network.
const QString & getClient() const
User data.
void forceDisconnect()
Force disconnect from network.
bool isAuthenticated() const
User authenticated?
ServerError
Server errors.
const QString & getUserName() const
User data.
QVector< StationDto > getAllAliasedStations()
All aliased stations.
void connectTo(const QString &username, const QString &password, const QString &client, const QUuid &networkVersion, ConnectionCallback callback)
Connect to network.
void updateTransceivers(const QString &callsign, const QVector< TransceiverDto > &transceivers)
Update transceivers.
const QString & getUrl() const
Get the URL.
const QUuid & getNetworkVersion() const
User data.
bool setUrl(const QString &url)
Set the URL.
CApiServerConnection(const QString &address, QObject *parent=nullptr)
Constructor.
Callable wrapper for a member function with function signature F.
QJsonArray array() const const
QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error)
bool isArray() const const
QJsonObject object() const const
void push_back(QList< T >::parameter_type value)
QObject * parent() const const