mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 21:32:44 +00:00
update qt5cpp and tizen sample
This commit is contained in:
@@ -27,17 +27,15 @@ SWGCategory::~SWGCategory() {
|
||||
void
|
||||
SWGCategory::init() {
|
||||
id = 0L;
|
||||
name = new QString("");
|
||||
|
||||
name = new QString("");
|
||||
}
|
||||
|
||||
void
|
||||
SWGCategory::cleanup() {
|
||||
|
||||
if(name != NULL) {
|
||||
if(name != NULL) {
|
||||
delete name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWGCategory*
|
||||
@@ -52,8 +50,7 @@ SWGCategory::fromJson(QString &json) {
|
||||
void
|
||||
SWGCategory::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -70,13 +67,11 @@ QJsonObject*
|
||||
SWGCategory::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,12 @@ public:
|
||||
|
||||
qint64 getId();
|
||||
void setId(qint64 id);
|
||||
QString* getName();
|
||||
QString* getName();
|
||||
void setName(QString* name);
|
||||
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
QString* name;
|
||||
|
||||
QString* name;
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -2,28 +2,32 @@
|
||||
#define ModelFactory_H_
|
||||
|
||||
|
||||
#include "SWGUser.h"
|
||||
#include "SWGApiResponse.h"
|
||||
#include "SWGCategory.h"
|
||||
#include "SWGOrder.h"
|
||||
#include "SWGPet.h"
|
||||
#include "SWGTag.h"
|
||||
#include "SWGOrder.h"
|
||||
#include "SWGUser.h"
|
||||
|
||||
namespace Swagger {
|
||||
inline void* create(QString type) {
|
||||
if(QString("SWGUser").compare(type) == 0) {
|
||||
return new SWGUser();
|
||||
if(QString("SWGApiResponse").compare(type) == 0) {
|
||||
return new SWGApiResponse();
|
||||
}
|
||||
if(QString("SWGCategory").compare(type) == 0) {
|
||||
return new SWGCategory();
|
||||
}
|
||||
if(QString("SWGOrder").compare(type) == 0) {
|
||||
return new SWGOrder();
|
||||
}
|
||||
if(QString("SWGPet").compare(type) == 0) {
|
||||
return new SWGPet();
|
||||
}
|
||||
if(QString("SWGTag").compare(type) == 0) {
|
||||
return new SWGTag();
|
||||
}
|
||||
if(QString("SWGOrder").compare(type) == 0) {
|
||||
return new SWGOrder();
|
||||
if(QString("SWGUser").compare(type) == 0) {
|
||||
return new SWGUser();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -27,27 +27,25 @@ SWGOrder::~SWGOrder() {
|
||||
void
|
||||
SWGOrder::init() {
|
||||
id = 0L;
|
||||
petId = 0L;
|
||||
quantity = 0;
|
||||
shipDate = NULL;
|
||||
status = new QString("");
|
||||
complete = false;
|
||||
|
||||
petId = 0L;
|
||||
quantity = 0;
|
||||
shipDate = NULL;
|
||||
status = new QString("");
|
||||
complete = false;
|
||||
}
|
||||
|
||||
void
|
||||
SWGOrder::cleanup() {
|
||||
|
||||
|
||||
|
||||
if(shipDate != NULL) {
|
||||
|
||||
|
||||
if(shipDate != NULL) {
|
||||
delete shipDate;
|
||||
}
|
||||
if(status != NULL) {
|
||||
if(status != NULL) {
|
||||
delete status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWGOrder*
|
||||
@@ -62,12 +60,11 @@ SWGOrder::fromJson(QString &json) {
|
||||
void
|
||||
SWGOrder::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&petId, pJson["petId"], "qint64", "");
|
||||
setValue(&quantity, pJson["quantity"], "qint32", "");
|
||||
setValue(&shipDate, pJson["shipDate"], "QDateTime", "QDateTime");
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
setValue(&complete, pJson["complete"], "bool", "");
|
||||
|
||||
setValue(&petId, pJson["petId"], "qint64", "");
|
||||
setValue(&quantity, pJson["quantity"], "qint32", "");
|
||||
setValue(&shipDate, pJson["shipDate"], "QDateTime", "QDateTime");
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
setValue(&complete, pJson["complete"], "bool", "");
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -84,22 +81,19 @@ QJsonObject*
|
||||
SWGOrder::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
obj->insert("petId", QJsonValue(petId));
|
||||
obj->insert("quantity", QJsonValue(quantity));
|
||||
|
||||
obj->insert("petId", QJsonValue(petId));
|
||||
obj->insert("quantity", QJsonValue(quantity));
|
||||
|
||||
|
||||
toJsonValue(QString("shipDate"), shipDate, obj, QString("QDateTime"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("status"), status, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
obj->insert("complete", QJsonValue(complete));
|
||||
|
||||
|
||||
obj->insert("complete", QJsonValue(complete));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -33,26 +33,24 @@ public:
|
||||
|
||||
qint64 getId();
|
||||
void setId(qint64 id);
|
||||
qint64 getPetId();
|
||||
qint64 getPetId();
|
||||
void setPetId(qint64 petId);
|
||||
qint32 getQuantity();
|
||||
qint32 getQuantity();
|
||||
void setQuantity(qint32 quantity);
|
||||
QDateTime* getShipDate();
|
||||
QDateTime* getShipDate();
|
||||
void setShipDate(QDateTime* shipDate);
|
||||
QString* getStatus();
|
||||
QString* getStatus();
|
||||
void setStatus(QString* status);
|
||||
bool getComplete();
|
||||
bool getComplete();
|
||||
void setComplete(bool complete);
|
||||
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
qint64 petId;
|
||||
qint32 quantity;
|
||||
QDateTime* shipDate;
|
||||
QString* status;
|
||||
bool complete;
|
||||
|
||||
qint64 petId;
|
||||
qint32 quantity;
|
||||
QDateTime* shipDate;
|
||||
QString* status;
|
||||
bool complete;
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -27,41 +27,39 @@ SWGPet::~SWGPet() {
|
||||
void
|
||||
SWGPet::init() {
|
||||
id = 0L;
|
||||
category = new SWGCategory();
|
||||
name = new QString("");
|
||||
photoUrls = new QList<QString*>();
|
||||
tags = new QList<SWGTag*>();
|
||||
status = new QString("");
|
||||
|
||||
category = new SWGCategory();
|
||||
name = new QString("");
|
||||
photoUrls = new QList<QString*>();
|
||||
tags = new QList<SWGTag*>();
|
||||
status = new QString("");
|
||||
}
|
||||
|
||||
void
|
||||
SWGPet::cleanup() {
|
||||
|
||||
if(category != NULL) {
|
||||
if(category != NULL) {
|
||||
delete category;
|
||||
}
|
||||
if(name != NULL) {
|
||||
if(name != NULL) {
|
||||
delete name;
|
||||
}
|
||||
if(photoUrls != NULL) {
|
||||
if(photoUrls != NULL) {
|
||||
QList<QString*>* arr = photoUrls;
|
||||
foreach(QString* o, *arr) {
|
||||
delete o;
|
||||
}
|
||||
delete photoUrls;
|
||||
}
|
||||
if(tags != NULL) {
|
||||
if(tags != NULL) {
|
||||
QList<SWGTag*>* arr = tags;
|
||||
foreach(SWGTag* o, *arr) {
|
||||
delete o;
|
||||
}
|
||||
delete tags;
|
||||
}
|
||||
if(status != NULL) {
|
||||
if(status != NULL) {
|
||||
delete status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWGPet*
|
||||
@@ -76,12 +74,11 @@ SWGPet::fromJson(QString &json) {
|
||||
void
|
||||
SWGPet::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
setValue(&photoUrls, pJson["photoUrls"], "QList", "QString");
|
||||
setValue(&tags, pJson["tags"], "QList", "SWGTag");
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
|
||||
setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
setValue(&photoUrls, pJson["photoUrls"], "QList", "QString");
|
||||
setValue(&tags, pJson["tags"], "QList", "SWGTag");
|
||||
setValue(&status, pJson["status"], "QString", "QString");
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -98,19 +95,17 @@ QJsonObject*
|
||||
SWGPet::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QList<QString*>* photoUrlsList = photoUrls;
|
||||
QJsonArray photoUrlsJsonArray;
|
||||
@@ -118,8 +113,7 @@ SWGPet::asJsonObject() {
|
||||
|
||||
obj->insert("photoUrls", photoUrlsJsonArray);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QList<SWGTag*>* tagsList = tags;
|
||||
QJsonArray tagsJsonArray;
|
||||
@@ -127,14 +121,11 @@ SWGPet::asJsonObject() {
|
||||
|
||||
obj->insert("tags", tagsJsonArray);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("status"), status, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -35,26 +35,24 @@ public:
|
||||
|
||||
qint64 getId();
|
||||
void setId(qint64 id);
|
||||
SWGCategory* getCategory();
|
||||
SWGCategory* getCategory();
|
||||
void setCategory(SWGCategory* category);
|
||||
QString* getName();
|
||||
QString* getName();
|
||||
void setName(QString* name);
|
||||
QList<QString*>* getPhotoUrls();
|
||||
QList<QString*>* getPhotoUrls();
|
||||
void setPhotoUrls(QList<QString*>* photoUrls);
|
||||
QList<SWGTag*>* getTags();
|
||||
QList<SWGTag*>* getTags();
|
||||
void setTags(QList<SWGTag*>* tags);
|
||||
QString* getStatus();
|
||||
QString* getStatus();
|
||||
void setStatus(QString* status);
|
||||
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
SWGCategory* category;
|
||||
QString* name;
|
||||
QList<QString*>* photoUrls;
|
||||
QList<SWGTag*>* tags;
|
||||
QString* status;
|
||||
|
||||
SWGCategory* category;
|
||||
QString* name;
|
||||
QList<QString*>* photoUrls;
|
||||
QList<SWGTag*>* tags;
|
||||
QString* status;
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -15,76 +15,21 @@ SWGPetApi::SWGPetApi(QString host, QString basePath) {
|
||||
this->basePath = basePath;
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePet(SWGPet body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::updatePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit updatePetSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::addPet(SWGPet body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -112,19 +57,57 @@ SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
|
||||
emit addPetSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::deletePet(qint64 petId, QString* apiKey) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: add header support
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::deletePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit deletePetSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (status->size() > 0) {
|
||||
if (QString("multi").indexOf("multi") == 0) {
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach(QString* t, *status) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
@@ -133,7 +116,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
fullPath.append("status=").append(stringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("multi").indexOf("ssv") == 0) {
|
||||
else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -147,7 +130,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
fullPath.append(stringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("multi").indexOf("tsv") == 0) {
|
||||
else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -163,17 +146,13 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -207,7 +186,6 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
|
||||
o->fromJsonObject(*ptr);
|
||||
output->append(o);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -221,15 +199,11 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/findByTags");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (tags->size() > 0) {
|
||||
if (QString("multi").indexOf("multi") == 0) {
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach(QString* t, *tags) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
@@ -238,7 +212,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
fullPath.append("tags=").append(stringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("multi").indexOf("ssv") == 0) {
|
||||
else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -252,7 +226,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
fullPath.append(stringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("multi").indexOf("tsv") == 0) {
|
||||
else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -268,17 +242,13 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -312,7 +282,6 @@ SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
|
||||
o->fromJsonObject(*ptr);
|
||||
output->append(o);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -326,21 +295,16 @@ SWGPetApi::getPetById(qint64 petId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -361,15 +325,9 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
QString json(worker->response);
|
||||
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
@@ -377,16 +335,54 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
||||
|
||||
}
|
||||
void
|
||||
SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
|
||||
SWGPetApi::updatePet(SWGPet body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet");
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::updatePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit updatePetSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::updatePetWithForm(qint64 petId, QString* name, QString* status) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
@@ -394,14 +390,12 @@ SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
|
||||
if (name != NULL) {
|
||||
input.add_var("name", *name);
|
||||
}
|
||||
if (status != NULL) {
|
||||
if (status != NULL) {
|
||||
input.add_var("status", *status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -429,64 +423,13 @@ SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
|
||||
emit updatePetWithFormSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::deletePet(qint64 petId, QString* apiKey) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
|
||||
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: add header support
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::deletePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit deletePetSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");
|
||||
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
@@ -494,14 +437,12 @@ SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestI
|
||||
if (additionalMetadata != NULL) {
|
||||
input.add_var("additionalMetadata", *additionalMetadata);
|
||||
}
|
||||
if (file != NULL) {
|
||||
if (file != NULL) {
|
||||
input.add_file("file", *file.local_filename, *file.request_filename, *file.mime_type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -522,113 +463,13 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit uploadFileSignal();
|
||||
}
|
||||
void
|
||||
SWGPetApi::getPetByIdWithByteArray(qint64 petId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}?testing_byte_array=true");
|
||||
|
||||
|
||||
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
|
||||
fullPath.replace(petIdPathParam, stringValue(petId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::getPetByIdWithByteArrayCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::getPetByIdWithByteArrayCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getPetByIdWithByteArraySignal(output);
|
||||
emit uploadFileSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGPetApi::addPetUsingByteArray(QString* body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/pet?testing_byte_array=true");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGPetApi::addPetUsingByteArrayCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGPetApi::addPetUsingByteArrayCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit addPetUsingByteArraySignal();
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "SWGPet.h"
|
||||
#include <QString>
|
||||
#include "SWGApiResponse.h"
|
||||
#include "SWGHttpRequest.h"
|
||||
|
||||
#include <QObject>
|
||||
@@ -22,40 +23,34 @@ public:
|
||||
QString host;
|
||||
QString basePath;
|
||||
|
||||
void updatePet(SWGPet body);
|
||||
void addPet(SWGPet body);
|
||||
void deletePet(qint64 petId, QString* apiKey);
|
||||
void findPetsByStatus(QList<QString*>* status);
|
||||
void findPetsByTags(QList<QString*>* tags);
|
||||
void getPetById(qint64 petId);
|
||||
void updatePetWithForm(QString* petId, QString* name, QString* status);
|
||||
void deletePet(qint64 petId, QString* apiKey);
|
||||
void updatePet(SWGPet body);
|
||||
void updatePetWithForm(qint64 petId, QString* name, QString* status);
|
||||
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
|
||||
void getPetByIdWithByteArray(qint64 petId);
|
||||
void addPetUsingByteArray(QString* body);
|
||||
|
||||
private:
|
||||
void updatePetCallback (HttpRequestWorker * worker);
|
||||
void addPetCallback (HttpRequestWorker * worker);
|
||||
void deletePetCallback (HttpRequestWorker * worker);
|
||||
void findPetsByStatusCallback (HttpRequestWorker * worker);
|
||||
void findPetsByTagsCallback (HttpRequestWorker * worker);
|
||||
void getPetByIdCallback (HttpRequestWorker * worker);
|
||||
void updatePetCallback (HttpRequestWorker * worker);
|
||||
void updatePetWithFormCallback (HttpRequestWorker * worker);
|
||||
void deletePetCallback (HttpRequestWorker * worker);
|
||||
void uploadFileCallback (HttpRequestWorker * worker);
|
||||
void getPetByIdWithByteArrayCallback (HttpRequestWorker * worker);
|
||||
void addPetUsingByteArrayCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
void updatePetSignal();
|
||||
void addPetSignal();
|
||||
void deletePetSignal();
|
||||
void findPetsByStatusSignal(QList<SWGPet*>* summary);
|
||||
void findPetsByTagsSignal(QList<SWGPet*>* summary);
|
||||
void getPetByIdSignal(SWGPet* summary);
|
||||
void updatePetSignal();
|
||||
void updatePetWithFormSignal();
|
||||
void deletePetSignal();
|
||||
void uploadFileSignal();
|
||||
void getPetByIdWithByteArraySignal(QString* summary);
|
||||
void addPetUsingByteArraySignal();
|
||||
void uploadFileSignal(SWGApiResponse* summary);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,201 +15,21 @@ SWGStoreApi::SWGStoreApi(QString host, QString basePath) {
|
||||
this->basePath = basePath;
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getInventory() {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/inventory");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::getInventoryCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QMap<QString, qint32>* output = new QMap<QString, qint32>();
|
||||
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject obj = doc.object();
|
||||
|
||||
foreach(QString key, obj.keys()) {
|
||||
qint32* val;
|
||||
setValue(&val, obj[key], "QMap", "");
|
||||
output->insert(key, *val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getInventorySignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGStoreApi::placeOrder(SWGOrder body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::placeOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit placeOrderSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGStoreApi::getOrderById(QString* orderId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
|
||||
|
||||
|
||||
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
|
||||
fullPath.replace(orderIdPathParam, stringValue(orderId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::getOrderByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getOrderByIdSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGStoreApi::deleteOrder(QString* orderId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
|
||||
|
||||
|
||||
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
|
||||
fullPath.replace(orderIdPathParam, stringValue(orderId));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -236,4 +56,146 @@ SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
|
||||
|
||||
emit deleteOrderSignal();
|
||||
}
|
||||
void
|
||||
SWGStoreApi::getInventory() {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/inventory");
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::getInventoryCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, qint32>* output = new QMap<QString, qint32>();
|
||||
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject obj = doc.object();
|
||||
|
||||
foreach(QString key, obj.keys()) {
|
||||
qint32* val;
|
||||
setValue(&val, obj[key], "QMap", "");
|
||||
output->insert(key, *val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getInventorySignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGStoreApi::getOrderById(qint64 orderId) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
|
||||
|
||||
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
|
||||
fullPath.replace(orderIdPathParam, stringValue(orderId));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::getOrderByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getOrderByIdSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGStoreApi::placeOrder(SWGOrder body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/store/order");
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGStoreApi::placeOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit placeOrderSignal(output);
|
||||
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
#include "SWGHttpRequest.h"
|
||||
|
||||
#include <QString>
|
||||
#include "QMap.h"
|
||||
#include "SWGOrder.h"
|
||||
#include <QString>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -22,22 +22,22 @@ public:
|
||||
QString host;
|
||||
QString basePath;
|
||||
|
||||
void getInventory();
|
||||
void placeOrder(SWGOrder body);
|
||||
void getOrderById(QString* orderId);
|
||||
void deleteOrder(QString* orderId);
|
||||
void getInventory();
|
||||
void getOrderById(qint64 orderId);
|
||||
void placeOrder(SWGOrder body);
|
||||
|
||||
private:
|
||||
void getInventoryCallback (HttpRequestWorker * worker);
|
||||
void placeOrderCallback (HttpRequestWorker * worker);
|
||||
void getOrderByIdCallback (HttpRequestWorker * worker);
|
||||
void deleteOrderCallback (HttpRequestWorker * worker);
|
||||
void getInventoryCallback (HttpRequestWorker * worker);
|
||||
void getOrderByIdCallback (HttpRequestWorker * worker);
|
||||
void placeOrderCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
void getInventorySignal(QMap<QString, qint32>* summary);
|
||||
void placeOrderSignal(SWGOrder* summary);
|
||||
void getOrderByIdSignal(SWGOrder* summary);
|
||||
void deleteOrderSignal();
|
||||
void getInventorySignal(QMap<QString, qint32>* summary);
|
||||
void getOrderByIdSignal(SWGOrder* summary);
|
||||
void placeOrderSignal(SWGOrder* summary);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,17 +27,15 @@ SWGTag::~SWGTag() {
|
||||
void
|
||||
SWGTag::init() {
|
||||
id = 0L;
|
||||
name = new QString("");
|
||||
|
||||
name = new QString("");
|
||||
}
|
||||
|
||||
void
|
||||
SWGTag::cleanup() {
|
||||
|
||||
if(name != NULL) {
|
||||
if(name != NULL) {
|
||||
delete name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWGTag*
|
||||
@@ -52,8 +50,7 @@ SWGTag::fromJson(QString &json) {
|
||||
void
|
||||
SWGTag::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
|
||||
setValue(&name, pJson["name"], "QString", "QString");
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -70,13 +67,11 @@ QJsonObject*
|
||||
SWGTag::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,12 @@ public:
|
||||
|
||||
qint64 getId();
|
||||
void setId(qint64 id);
|
||||
QString* getName();
|
||||
QString* getName();
|
||||
void setName(QString* name);
|
||||
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
QString* name;
|
||||
|
||||
QString* name;
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -27,39 +27,37 @@ SWGUser::~SWGUser() {
|
||||
void
|
||||
SWGUser::init() {
|
||||
id = 0L;
|
||||
username = new QString("");
|
||||
firstName = new QString("");
|
||||
lastName = new QString("");
|
||||
email = new QString("");
|
||||
password = new QString("");
|
||||
phone = new QString("");
|
||||
userStatus = 0;
|
||||
|
||||
username = new QString("");
|
||||
firstName = new QString("");
|
||||
lastName = new QString("");
|
||||
email = new QString("");
|
||||
password = new QString("");
|
||||
phone = new QString("");
|
||||
userStatus = 0;
|
||||
}
|
||||
|
||||
void
|
||||
SWGUser::cleanup() {
|
||||
|
||||
if(username != NULL) {
|
||||
if(username != NULL) {
|
||||
delete username;
|
||||
}
|
||||
if(firstName != NULL) {
|
||||
if(firstName != NULL) {
|
||||
delete firstName;
|
||||
}
|
||||
if(lastName != NULL) {
|
||||
if(lastName != NULL) {
|
||||
delete lastName;
|
||||
}
|
||||
if(email != NULL) {
|
||||
if(email != NULL) {
|
||||
delete email;
|
||||
}
|
||||
if(password != NULL) {
|
||||
if(password != NULL) {
|
||||
delete password;
|
||||
}
|
||||
if(phone != NULL) {
|
||||
if(phone != NULL) {
|
||||
delete phone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWGUser*
|
||||
@@ -74,14 +72,13 @@ SWGUser::fromJson(QString &json) {
|
||||
void
|
||||
SWGUser::fromJsonObject(QJsonObject &pJson) {
|
||||
setValue(&id, pJson["id"], "qint64", "");
|
||||
setValue(&username, pJson["username"], "QString", "QString");
|
||||
setValue(&firstName, pJson["firstName"], "QString", "QString");
|
||||
setValue(&lastName, pJson["lastName"], "QString", "QString");
|
||||
setValue(&email, pJson["email"], "QString", "QString");
|
||||
setValue(&password, pJson["password"], "QString", "QString");
|
||||
setValue(&phone, pJson["phone"], "QString", "QString");
|
||||
setValue(&userStatus, pJson["userStatus"], "qint32", "");
|
||||
|
||||
setValue(&username, pJson["username"], "QString", "QString");
|
||||
setValue(&firstName, pJson["firstName"], "QString", "QString");
|
||||
setValue(&lastName, pJson["lastName"], "QString", "QString");
|
||||
setValue(&email, pJson["email"], "QString", "QString");
|
||||
setValue(&password, pJson["password"], "QString", "QString");
|
||||
setValue(&phone, pJson["phone"], "QString", "QString");
|
||||
setValue(&userStatus, pJson["userStatus"], "qint32", "");
|
||||
}
|
||||
|
||||
QString
|
||||
@@ -98,44 +95,37 @@ QJsonObject*
|
||||
SWGUser::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
obj->insert("id", QJsonValue(id));
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("username"), username, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("firstName"), firstName, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("lastName"), lastName, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("email"), email, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("password"), password, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
toJsonValue(QString("phone"), phone, obj, QString("QString"));
|
||||
|
||||
|
||||
|
||||
obj->insert("userStatus", QJsonValue(userStatus));
|
||||
|
||||
|
||||
obj->insert("userStatus", QJsonValue(userStatus));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -32,32 +32,30 @@ public:
|
||||
|
||||
qint64 getId();
|
||||
void setId(qint64 id);
|
||||
QString* getUsername();
|
||||
QString* getUsername();
|
||||
void setUsername(QString* username);
|
||||
QString* getFirstName();
|
||||
QString* getFirstName();
|
||||
void setFirstName(QString* firstName);
|
||||
QString* getLastName();
|
||||
QString* getLastName();
|
||||
void setLastName(QString* lastName);
|
||||
QString* getEmail();
|
||||
QString* getEmail();
|
||||
void setEmail(QString* email);
|
||||
QString* getPassword();
|
||||
QString* getPassword();
|
||||
void setPassword(QString* password);
|
||||
QString* getPhone();
|
||||
QString* getPhone();
|
||||
void setPhone(QString* phone);
|
||||
qint32 getUserStatus();
|
||||
qint32 getUserStatus();
|
||||
void setUserStatus(qint32 userStatus);
|
||||
|
||||
|
||||
private:
|
||||
qint64 id;
|
||||
QString* username;
|
||||
QString* firstName;
|
||||
QString* lastName;
|
||||
QString* email;
|
||||
QString* password;
|
||||
QString* phone;
|
||||
qint32 userStatus;
|
||||
|
||||
QString* username;
|
||||
QString* firstName;
|
||||
QString* lastName;
|
||||
QString* email;
|
||||
QString* password;
|
||||
QString* phone;
|
||||
qint32 userStatus;
|
||||
};
|
||||
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -20,23 +20,16 @@ SWGUserApi::createUser(SWGUser body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -68,17 +61,12 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/createWithArray");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QJsonArray* bodyArray = new QJsonArray();
|
||||
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
|
||||
@@ -86,10 +74,8 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
||||
QByteArray bytes = doc.toJson();
|
||||
|
||||
input.request_body.append(bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -121,17 +107,12 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/createWithList");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QJsonArray* bodyArray = new QJsonArray();
|
||||
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
|
||||
|
||||
@@ -139,10 +120,8 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
||||
QByteArray bytes = doc.toJson();
|
||||
|
||||
input.request_body.append(bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -170,14 +149,96 @@ SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
|
||||
emit createUsersWithListInputSignal();
|
||||
}
|
||||
void
|
||||
SWGUserApi::deleteUser(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, stringValue(username));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGUserApi::deleteUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit deleteUserSignal();
|
||||
}
|
||||
void
|
||||
SWGUserApi::getUserByName(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, stringValue(username));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGUserApi::getUserByNameCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getUserByNameSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGUserApi::loginUser(QString* username, QString* password) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/login");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -185,11 +246,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
||||
fullPath.append(QUrl::toPercentEncoding("username"))
|
||||
.append("=")
|
||||
.append(QUrl::toPercentEncoding(stringValue(username)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
@@ -197,19 +254,14 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
||||
fullPath.append(QUrl::toPercentEncoding("password"))
|
||||
.append("=")
|
||||
.append(QUrl::toPercentEncoding(stringValue(password)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -230,15 +282,9 @@ SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
QString json(worker->response);
|
||||
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
@@ -250,18 +296,14 @@ SWGUserApi::logoutUser() {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/logout");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -289,85 +331,22 @@ SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
|
||||
emit logoutUserSignal();
|
||||
}
|
||||
void
|
||||
SWGUserApi::getUserByName(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
|
||||
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, stringValue(username));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGUserApi::getUserByNameCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
|
||||
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit getUserByNameSignal(output);
|
||||
|
||||
}
|
||||
void
|
||||
SWGUserApi::updateUser(QString* username, SWGUser body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
|
||||
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, stringValue(username));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
@@ -394,50 +373,4 @@ SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
|
||||
|
||||
emit updateUserSignal();
|
||||
}
|
||||
void
|
||||
SWGUserApi::deleteUser(QString* username) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
|
||||
|
||||
|
||||
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, stringValue(username));
|
||||
|
||||
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGUserApi::deleteUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
|
||||
emit deleteUserSignal();
|
||||
}
|
||||
} /* namespace Swagger */
|
||||
|
||||
@@ -25,31 +25,31 @@ public:
|
||||
void createUser(SWGUser body);
|
||||
void createUsersWithArrayInput(QList<SWGUser*>* body);
|
||||
void createUsersWithListInput(QList<SWGUser*>* body);
|
||||
void deleteUser(QString* username);
|
||||
void getUserByName(QString* username);
|
||||
void loginUser(QString* username, QString* password);
|
||||
void logoutUser();
|
||||
void getUserByName(QString* username);
|
||||
void updateUser(QString* username, SWGUser body);
|
||||
void deleteUser(QString* username);
|
||||
|
||||
private:
|
||||
void createUserCallback (HttpRequestWorker * worker);
|
||||
void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
|
||||
void createUsersWithListInputCallback (HttpRequestWorker * worker);
|
||||
void deleteUserCallback (HttpRequestWorker * worker);
|
||||
void getUserByNameCallback (HttpRequestWorker * worker);
|
||||
void loginUserCallback (HttpRequestWorker * worker);
|
||||
void logoutUserCallback (HttpRequestWorker * worker);
|
||||
void getUserByNameCallback (HttpRequestWorker * worker);
|
||||
void updateUserCallback (HttpRequestWorker * worker);
|
||||
void deleteUserCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
void createUserSignal();
|
||||
void createUsersWithArrayInputSignal();
|
||||
void createUsersWithListInputSignal();
|
||||
void deleteUserSignal();
|
||||
void getUserByNameSignal(SWGUser* summary);
|
||||
void loginUserSignal(QString* summary);
|
||||
void logoutUserSignal();
|
||||
void getUserByNameSignal(SWGUser* summary);
|
||||
void updateUserSignal();
|
||||
void deleteUserSignal();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user