Revision control

+ /**
+ * Qt Quick Demo - RESTful API client
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * Do not edit the class manually.
+ */
+
+ #include "OAIUsersApi.h"
+ #include "OAIServerConfiguration.h"
+
+ #include <QtCore/qanystringview.h>
+ #include <QtCore/qjsonarray.h>
+ #include <QtCore/qjsondocument.h>
+ #include <QtNetwork/qnetworkaccessmanager.h>
+ #include <QtNetwork/qnetworkreply.h>
+ #include <QtNetwork/qnetworkrequestfactory.h>
+ #include <QtNetwork/qrestaccessmanager.h>
+
+ using namespace Qt::StringLiterals;
+
+ namespace OpenAPI {
+
+ OAIUsersApi::OAIUsersApi(QObject *parent)
+ : OAIBaseApi(parent)
+ {
+ initializeServerConfigs();
+ }
+
+ OAIUsersApi::~OAIUsersApi()
+ {
+ }
+
+ void OAIUsersApi::initializeServerConfigs()
+ {
+ //Default server
+ QList<OAIServerConfiguration> defaultConf = QList<OAIServerConfiguration>();
+ //varying endpoint server
+ defaultConf.append(OAIServerConfiguration(
+ "Public REST API test service",
+ QMap<QString, OAIServerVariable>()));
+ defaultConf.append(OAIServerConfiguration(
+ "Qt-based REST API server",
+ QMap<QString, OAIServerVariable>()));
+ m_serverConfigs.insert("getUserById", defaultConf);
+ m_serverIndices.insert("getUserById", 0);
+ m_serverConfigs.insert("getUsersByPage", defaultConf);
+ m_serverIndices.insert("getUsersByPage", 0);
+ m_serverConfigs.insert("loginUser", defaultConf);
+ m_serverIndices.insert("loginUser", 0);
+ m_serverConfigs.insert("logoutUser", defaultConf);
+ m_serverIndices.insert("logoutUser", 0);
+ m_serverConfigs.insert("updateUser", defaultConf);
+ m_serverIndices.insert("updateUser", 0);
+ }
+
+ /**
+ * \fn virtual void OAIUsersApi::getUserById(const qint64 &id)
+ * 'getUserById' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] id qint64 [required]
+ */
+
+ /**
+ * \fn template < Functor, > void OAIUsersApi::getUserById(const qint64 &id, const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'getUserById' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+ *
+ * \attention Use the operation with following parameters in the callback:
+ * \code {c++}
+ * getUserById(id, this, [&](QRestReply &reply, OAIUser &summary) { if (reply.isSuccess()) ... });
+ * \endcode
+ * \note The template function can not be virtual in C++17.
+ * If you want to use 'makeOperationsVirtual' option for mocking API,
+ * please override virtual getUserByIdWithDataImpl() in derived class.
+ * The virtual getUserByIdWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] id qint64 [required]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void OAIUsersApi::getUserByIdCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by getUserByIdFinished() or
+ * being returned as a callback parameter of getUserById() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void OAIUsersApi::getUserByIdWithDataImpl(const qint64 &id, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the getUserById() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking getUserById() operation calls.
+
+ * @param[in] id qint64 [required]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void OAIUsersApi::getUserByIdWithDataImpl(const qint64 &id, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["getUserById"][m_serverIndices.value("getUserById")].serverUrl();
+ QString fullPath = "/users/{id}";
+ m_networkFactory->setBaseUrl(serverUrl);
+ QString idPathParam("{");
+ idPathParam.append("id").append("}");
+ QString pathPrefix, pathSuffix, pathDelimiter;
+ QString pathStyle = "simple";
+ if (pathStyle == "")
+ pathStyle = "simple";
+ pathPrefix = getParamStylePrefix(pathStyle);
+ pathSuffix = getParamStyleSuffix(pathStyle);
+ pathDelimiter = getParamStyleDelimiter(pathStyle, "id", false);
+
+ QString paramString = (pathStyle == "matrix") ? pathPrefix + "id" + pathSuffix : pathPrefix;
+ fullPath.replace(idPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(id)));
+
+ OAIHttpRequestInput input(fullPath, "GET");
+ QByteArray requestContent;
+ QNetworkRequest request
+ = OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, OAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ getUserByIdCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit getUserByIdErrorOccurred(reply->error(), reply->errorString());
+ OAICallerInfo callerInfo = m_callerData.take(reply);
+ if (callerInfo.slot) {
+ OAIUser empty;
+ QRestReply restRepl(reply);
+ void *argv[] = { nullptr, &restRepl, &empty };
+ QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ }
+ });
+ }
+ }
+
+ void OAIUsersApi::getUserByIdCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ disconnect(netReply, nullptr, nullptr, nullptr);
+ if (!reply.isSuccess())
+ return;
+
+ const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
+ OAIUser output(response);
+ // Check if callback is provided
+ OAICallerInfo callerInfo = m_callerData.take(netReply);
+ if (callerInfo.slot) {
+ void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
+ QObject *context = callerInfo.contextObject
+ ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ emit getUserByIdFinished(output);
+ }
+
+ /**
+ * \fn virtual void OAIUsersApi::getUsersByPage(const ::OpenAPI::OptionalParam<qint32> &page = ::OpenAPI::OptionalParam<qint32>())
+ * 'getUsersByPage' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] page qint32 [optional]
+ */
+
+ /**
+ * \fn template < Functor, > void OAIUsersApi::getUsersByPage(const ::OpenAPI::OptionalParam<qint32> &page = ::OpenAPI::OptionalParam<qint32>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'getUsersByPage' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+ *
+ * \attention Use the operation with following parameters in the callback:
+ * \code {c++}
+ * getUsersByPage(page, this, [&](QRestReply &reply, OAIUserPage &summary) { if (reply.isSuccess()) ... });
+ * \endcode
+ * \note The template function can not be virtual in C++17.
+ * If you want to use 'makeOperationsVirtual' option for mocking API,
+ * please override virtual getUsersByPageWithDataImpl() in derived class.
+ * The virtual getUsersByPageWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] page qint32 [optional]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void OAIUsersApi::getUsersByPageCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by getUsersByPageFinished() or
+ * being returned as a callback parameter of getUsersByPage() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void OAIUsersApi::getUsersByPageWithDataImpl(const ::OpenAPI::OptionalParam<qint32> &page, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the getUsersByPage() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking getUsersByPage() operation calls.
+
+ * @param[in] page qint32 [optional]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void OAIUsersApi::getUsersByPageWithDataImpl(const ::OpenAPI::OptionalParam<qint32> &page, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["getUsersByPage"][m_serverIndices.value("getUsersByPage")].serverUrl();
+ QString fullPath = "/users";
+ m_networkFactory->setBaseUrl(serverUrl);
+ QString queryPrefix, querySuffix, queryDelimiter, queryStyle;
+ queryStyle = "form";
+ if (queryStyle == "")
+ queryStyle = "form";
+ queryPrefix = getParamStylePrefix(queryStyle);
+ querySuffix = getParamStyleSuffix(queryStyle);
+ if (page.hasValue()) {
+ if (fullPath.indexOf("?") > 0)
+ fullPath.append(queryPrefix);
+ else
+ fullPath.append("?");
+ fullPath.append(QUrl::toPercentEncoding("page") + querySuffix + QUrl::toPercentEncoding(::OpenAPI::toStringValue(page.value())));
+
+ } else if (page.isNull()) {
+ if (fullPath.indexOf("?") > 0)
+ fullPath.append(queryPrefix);
+ else
+ fullPath.append("?");
+
+ fullPath.append(QUrl::toPercentEncoding("page")).append(querySuffix).append(QUrl::toPercentEncoding(QString("null")));
+ }
+ OAIHttpRequestInput input(fullPath, "GET");
+ QByteArray requestContent;
+ QNetworkRequest request
+ = OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, OAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ getUsersByPageCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit getUsersByPageErrorOccurred(reply->error(), reply->errorString());
+ OAICallerInfo callerInfo = m_callerData.take(reply);
+ if (callerInfo.slot) {
+ OAIUserPage empty;
+ QRestReply restRepl(reply);
+ void *argv[] = { nullptr, &restRepl, &empty };
+ QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ }
+ });
+ }
+ }
+
+ void OAIUsersApi::getUsersByPageCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ disconnect(netReply, nullptr, nullptr, nullptr);
+ if (!reply.isSuccess())
+ return;
+
+ const QByteArray &response = OAIHttpRequestWorker::parseResponse(reply, m_workingDirectory);
+ OAIUserPage output(response);
+ // Check if callback is provided
+ OAICallerInfo callerInfo = m_callerData.take(netReply);
+ if (callerInfo.slot) {
+ void *argv[] = { nullptr, const_cast<QRestReply*>(&reply), &output };
+ QObject *context = callerInfo.contextObject
+ ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ emit getUsersByPageFinished(output);
+ }
+
+ /**
+ * \fn virtual void OAIUsersApi::loginUser(const ::OpenAPI::OptionalParam<OAITestOperation_request> &oAITestOperationRequest = ::OpenAPI::OptionalParam<OAITestOperation_request>())
+ * 'loginUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] oAITestOperationRequest OAITestOperation_request [optional]
+ */
+
+ /**
+ * \fn template < Functor, > void OAIUsersApi::loginUser(const ::OpenAPI::OptionalParam<OAITestOperation_request> &oAITestOperationRequest = ::OpenAPI::OptionalParam<OAITestOperation_request>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'loginUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+ *
+ * \attention Use the operation with following parameters in the callback:
+ * \code {c++}
+ * loginUser(oAITestOperationRequest, this, [&](QRestReply &reply) { if (reply.isSuccess()) ... });
+ * \endcode
+ * \note The template function can not be virtual in C++17.
+ * If you want to use 'makeOperationsVirtual' option for mocking API,
+ * please override virtual loginUserWithDataImpl() in derived class.
+ * The virtual loginUserWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] oAITestOperationRequest OAITestOperation_request [optional]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void OAIUsersApi::loginUserCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by loginUserFinished() or
+ * being returned as a callback parameter of loginUser() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void OAIUsersApi::loginUserWithDataImpl(const ::OpenAPI::OptionalParam<OAITestOperation_request> &oAITestOperationRequest, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the loginUser() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking loginUser() operation calls.
+
+ * @param[in] oAITestOperationRequest OAITestOperation_request [optional]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void OAIUsersApi::loginUserWithDataImpl(const ::OpenAPI::OptionalParam<OAITestOperation_request> &oAITestOperationRequest, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["loginUser"][m_serverIndices.value("loginUser")].serverUrl();
+ QString fullPath = "/login";
+ m_networkFactory->setBaseUrl(serverUrl);
+
+ OAIHttpRequestInput input(fullPath, "POST");
+ if (oAITestOperationRequest.hasValue()) {
+
+ QByteArray output = oAITestOperationRequest.value().asJson().toUtf8();
+ input.m_requestBody.append(output);
+ } else if (oAITestOperationRequest.isNull()) {
+ input.m_requestBody.append("null");
+ }
+ QByteArray requestContent;
+ QNetworkRequest request
+ = OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, OAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ loginUserCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit loginUserErrorOccurred(reply->error(), reply->errorString());
+ OAICallerInfo callerInfo = m_callerData.take(reply);
+ if (callerInfo.slot) {
+ QRestReply restRepl(reply);
+ void *argv[] = { nullptr, &restRepl };
+ QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ }
+ });
+ }
+ }
+
+ void OAIUsersApi::loginUserCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ disconnect(netReply, nullptr, nullptr, nullptr);
+ if (!reply.isSuccess())
+ return;
+
+ // Check if callback is provided
+ OAICallerInfo callerInfo = m_callerData.take(netReply);
+ if (callerInfo.slot) {
+ void *argv[] = { nullptr, const_cast<QRestReply*>(&reply) };
+ QObject *context = callerInfo.contextObject
+ ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ emit loginUserFinished();
+ }
+
+ /**
+ * \fn virtual void OAIUsersApi::logoutUser()
+ * 'logoutUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ */
+
+ /**
+ * \fn template < Functor, > void OAIUsersApi::logoutUser(const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'logoutUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+ *
+ * \attention Use the operation with following parameters in the callback:
+ * \code {c++}
+ * logoutUser(this, [&](QRestReply &reply) { if (reply.isSuccess()) ... });
+ * \endcode
+ * \note The template function can not be virtual in C++17.
+ * If you want to use 'makeOperationsVirtual' option for mocking API,
+ * please override virtual logoutUserWithDataImpl() in derived class.
+ * The virtual logoutUserWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void OAIUsersApi::logoutUserCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by logoutUserFinished() or
+ * being returned as a callback parameter of logoutUser() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void OAIUsersApi::logoutUserWithDataImpl(const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the logoutUser() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking logoutUser() operation calls.
+
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void OAIUsersApi::logoutUserWithDataImpl(const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["logoutUser"][m_serverIndices.value("logoutUser")].serverUrl();
+ QString fullPath = "/logout";
+ m_networkFactory->setBaseUrl(serverUrl);
+
+ OAIHttpRequestInput input(fullPath, "POST");
+ QByteArray requestContent;
+ QNetworkRequest request
+ = OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, OAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ logoutUserCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit logoutUserErrorOccurred(reply->error(), reply->errorString());
+ OAICallerInfo callerInfo = m_callerData.take(reply);
+ if (callerInfo.slot) {
+ QRestReply restRepl(reply);
+ void *argv[] = { nullptr, &restRepl };
+ QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ }
+ });
+ }
+ }
+
+ void OAIUsersApi::logoutUserCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ disconnect(netReply, nullptr, nullptr, nullptr);
+ if (!reply.isSuccess())
+ return;
+
+ // Check if callback is provided
+ OAICallerInfo callerInfo = m_callerData.take(netReply);
+ if (callerInfo.slot) {
+ void *argv[] = { nullptr, const_cast<QRestReply*>(&reply) };
+ QObject *context = callerInfo.contextObject
+ ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ emit logoutUserFinished();
+ }
+
+ /**
+ * \fn virtual void OAIUsersApi::updateUser(const qint64 &id, const ::OpenAPI::OptionalParam<OAIUpdateUser_request> &oAIUpdateUserRequest = ::OpenAPI::OptionalParam<OAIUpdateUser_request>())
+ * 'updateUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+
+ * @param[in] id qint64 [required]
+ * @param[in] oAIUpdateUserRequest OAIUpdateUser_request [optional]
+ */
+
+ /**
+ * \fn template < Functor, > void OAIUsersApi::updateUser(const qint64 &id, const ::OpenAPI::OptionalParam<OAIUpdateUser_request> &oAIUpdateUserRequest = ::OpenAPI::OptionalParam<OAIUpdateUser_request>(), const ContextTypeForFunctor< Functor > *context = nullptr, Functor &&callback = (){})
+ * 'updateUser' operation sends the request to a server.
+ * The request parameters are defined by a specification file.
+ *
+ * \attention Use the operation with following parameters in the callback:
+ * \code {c++}
+ * updateUser(id, oAIUpdateUserRequest, this, [&](QRestReply &reply) { if (reply.isSuccess()) ... });
+ * \endcode
+ * \note The template function can not be virtual in C++17.
+ * If you want to use 'makeOperationsVirtual' option for mocking API,
+ * please override virtual updateUserWithDataImpl() in derived class.
+ * The virtual updateUserWithDataImpl() is being called by the template
+ * function.
+
+ * @param[in] id qint64 [required]
+ * @param[in] oAIUpdateUserRequest OAIUpdateUser_request [optional]
+ * @param[in] context const ContextTypeForFunctor< Functor > * [optional]
+ * @param[in] callback Functor && [optional]
+ */
+
+ /**
+ * \fn void OAIUsersApi::updateUserCallback(const QRestReply &reply)
+ * Processes a \a reply response from a server.
+ * The result of processed data is emitted by updateUserFinished() or
+ * being returned as a callback parameter of updateUser() request.
+ * @param[in] reply const QRestReply &
+ */
+
+ /**
+ * \fn virtual void OAIUsersApi::updateUserWithDataImpl(const qint64 &id, const ::OpenAPI::OptionalParam<OAIUpdateUser_request> &oAIUpdateUserRequest, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ * Implements the updateUser() operation request.
+ * \note If 'makeOperationsVirtual' option is true, this function is declared as virtual
+ * and can be overloaded for mocking updateUser() operation calls.
+
+ * @param[in] id qint64 [required]
+ * @param[in] oAIUpdateUserRequest OAIUpdateUser_request [optional]
+ * @param[in] context const QObject * [optional]
+ * @param[in] slot QtPrivate::QSlotObjectBase * [optional]
+ */
+ void OAIUsersApi::updateUserWithDataImpl(const qint64 &id, const ::OpenAPI::OptionalParam<OAIUpdateUser_request> &oAIUpdateUserRequest, const QObject *context, QtPrivate::QSlotObjectBase *slot)
+ {
+ const QUrl serverUrl = m_serverConfigs["updateUser"][m_serverIndices.value("updateUser")].serverUrl();
+ QString fullPath = "/users/{id}";
+ m_networkFactory->setBaseUrl(serverUrl);
+ QString idPathParam("{");
+ idPathParam.append("id").append("}");
+ QString pathPrefix, pathSuffix, pathDelimiter;
+ QString pathStyle = "simple";
+ if (pathStyle == "")
+ pathStyle = "simple";
+ pathPrefix = getParamStylePrefix(pathStyle);
+ pathSuffix = getParamStyleSuffix(pathStyle);
+ pathDelimiter = getParamStyleDelimiter(pathStyle, "id", false);
+
+ QString paramString = (pathStyle == "matrix") ? pathPrefix + "id" + pathSuffix : pathPrefix;
+ fullPath.replace(idPathParam, QUrl::toPercentEncoding(paramString + ::OpenAPI::toStringValue(id)));
+
+ OAIHttpRequestInput input(fullPath, "PATCH");
+ if (oAIUpdateUserRequest.hasValue()) {
+
+ QByteArray output = oAIUpdateUserRequest.value().asJson().toUtf8();
+ input.m_requestBody.append(output);
+ }
+ QByteArray requestContent;
+ QNetworkRequest request
+ = OAIHttpRequestWorker::getNetworkRequest(input, requestContent, m_networkFactory,
+ m_isResponseCompressionEnabled, m_isRequestCompressionEnabled);
+ QNetworkReply *reply = execute(input, request, requestContent);
+ if (reply != nullptr) {
+ reply->setParent(this);
+ m_callerData.insert(reply, OAICallerInfo{context, slot});
+ connect(reply, &QNetworkReply::finished, this, [this, reply] {
+ updateUserCallback(QRestReply(reply));
+ });
+ connect(reply, &QNetworkReply::errorOccurred, this, [this, reply] {
+ if (reply) {
+ emit updateUserErrorOccurred(reply->error(), reply->errorString());
+ OAICallerInfo callerInfo = m_callerData.take(reply);
+ if (callerInfo.slot) {
+ QRestReply restRepl(reply);
+ void *argv[] = { nullptr, &restRepl };
+ QObject *context = callerInfo.contextObject ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ }
+ });
+ }
+ }
+
+ void OAIUsersApi::updateUserCallback(const QRestReply &reply)
+ {
+ auto netReply = reply.networkReply();
+ if (netReply)
+ disconnect(netReply, nullptr, nullptr, nullptr);
+ if (!reply.isSuccess())
+ return;
+
+ // Check if callback is provided
+ OAICallerInfo callerInfo = m_callerData.take(netReply);
+ if (callerInfo.slot) {
+ void *argv[] = { nullptr, const_cast<QRestReply*>(&reply) };
+ QObject *context = callerInfo.contextObject
+ ? const_cast<QObject*>(callerInfo.contextObject) : nullptr;
+ callerInfo.slot->call(context, argv);
+ }
+ emit updateUserFinished();
+ }
+
+ } // namespace OpenAPI