Merge pull request #4 from wing328/qt-update-client

Qt update client
This commit is contained in:
William Cheng
2018-04-02 16:06:56 +08:00
committed by GitHub
9 changed files with 56 additions and 122 deletions

View File

@@ -1 +1 @@
2.4.0-SNAPSHOT
3.0.0-SNAPSHOT

View File

@@ -111,6 +111,9 @@ SWGOrder::asJsonObject() {
if(m_quantity_isSet){
obj.insert("quantity", QJsonValue(quantity));
}
if(ship_date != nullptr && *ship_date != QString("")){
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
if(ship_date != nullptr) {
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
@@ -192,7 +195,7 @@ SWGOrder::isSet(){
if(m_id_isSet){ isObjectUpdated = true; break;}
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
if(m_quantity_isSet){ isObjectUpdated = true; break;}
if(ship_date != nullptr && *ship_date != QString("")){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
if(m_complete_isSet){ isObjectUpdated = true; break;}
}while(false);

View File

@@ -39,7 +39,7 @@ void
SWGPet::init() {
id = 0L;
m_id_isSet = false;
category = new SWGCategory();
category = new SWG#/components/schemas/Category();
m_category_isSet = false;
name = new QString("");
m_name_isSet = false;

View File

@@ -30,7 +30,7 @@ SWGPetApi::SWGPetApi(QString host, QString basePath) {
}
void
SWGPetApi::addPet(SWGPet& body) {
SWGPetApi::addPet(SWGPet& pet) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet");
@@ -41,7 +41,7 @@ SWGPetApi::addPet(SWGPet& body) {
QString output = body.asJson();
QString output = pet.asJson();
input.request_body.append(output);
@@ -82,7 +82,7 @@ SWGPetApi::addPetCallback(SWGHttpRequestWorker * worker) {
}
void
SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
SWGPetApi::deletePet(qint32 pet_id, QString* api_key) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@@ -141,47 +141,13 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus");
if (status->size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach(QString* t, *status) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("status=").append(stringValue(t));
}
}
else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("status=");
qint32 count = 0;
foreach(QString* t, *status) {
if (count > 0) {
fullPath.append(" ");
}
fullPath.append(stringValue(t));
}
}
else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("status=");
qint32 count = 0;
foreach(QString* t, *status) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(stringValue(t));
}
}
}
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("status"))
.append("=")
.append(QUrl::toPercentEncoding(stringValue(status)));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
@@ -248,47 +214,13 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
fullPath.append(this->host).append(this->basePath).append("/pet/findByTags");
if (tags->size() > 0) {
if (QString("csv").indexOf("multi") == 0) {
foreach(QString* t, *tags) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("tags=").append(stringValue(t));
}
}
else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("tags=");
qint32 count = 0;
foreach(QString* t, *tags) {
if (count > 0) {
fullPath.append(" ");
}
fullPath.append(stringValue(t));
}
}
else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append("tags=");
qint32 count = 0;
foreach(QString* t, *tags) {
if (count > 0) {
fullPath.append("\t");
}
fullPath.append(stringValue(t));
}
}
}
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("tags"))
.append("=")
.append(QUrl::toPercentEncoding(stringValue(tags)));
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
@@ -350,7 +282,7 @@ SWGPetApi::findPetsByTagsCallback(SWGHttpRequestWorker * worker) {
}
void
SWGPetApi::getPetById(qint64 pet_id) {
SWGPetApi::getPetById(qint32 pet_id) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@@ -405,7 +337,7 @@ SWGPetApi::getPetByIdCallback(SWGHttpRequestWorker * worker) {
}
void
SWGPetApi::updatePet(SWGPet& body) {
SWGPetApi::updatePet(SWGPet& pet) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet");
@@ -416,7 +348,7 @@ SWGPetApi::updatePet(SWGPet& body) {
QString output = body.asJson();
QString output = pet.asJson();
input.request_body.append(output);
@@ -457,7 +389,7 @@ SWGPetApi::updatePetCallback(SWGHttpRequestWorker * worker) {
}
void
SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
SWGPetApi::updatePetWithForm(qint32 pet_id, QString* name, QString* status) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
@@ -514,7 +446,7 @@ SWGPetApi::updatePetWithFormCallback(SWGHttpRequestWorker * worker) {
}
void
SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file) {
SWGPetApi::uploadFile(qint32 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");
@@ -529,7 +461,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
input.add_var("additionalMetadata", *additional_metadata);
}
if (file != nullptr) {
input.add_file("file", (*file).local_filename, (*file).request_filename, (*file).mime_type);
input.add_var("file", *file);
}

View File

@@ -36,14 +36,14 @@ public:
QString basePath;
QMap<QString, QString> defaultHeaders;
void addPet(SWGPet& body);
void deletePet(qint64 pet_id, QString* api_key);
void addPet(SWGPet& pet);
void deletePet(qint32 pet_id, QString* api_key);
void findPetsByStatus(QList<QString*>* status);
void findPetsByTags(QList<QString*>* tags);
void getPetById(qint64 pet_id);
void updatePet(SWGPet& body);
void updatePetWithForm(qint64 pet_id, QString* name, QString* status);
void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
void getPetById(qint32 pet_id);
void updatePet(SWGPet& pet);
void updatePetWithForm(qint32 pet_id, QString* name, QString* status);
void uploadFile(qint32 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
private:
void addPetCallback (SWGHttpRequestWorker * worker);

View File

@@ -141,7 +141,7 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
}
void
SWGStoreApi::getOrderById(qint64 order_id) {
SWGStoreApi::getOrderById(qint32 order_id) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
@@ -196,7 +196,7 @@ SWGStoreApi::getOrderByIdCallback(SWGHttpRequestWorker * worker) {
}
void
SWGStoreApi::placeOrder(SWGOrder& body) {
SWGStoreApi::placeOrder(SWGOrder& order) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order");
@@ -207,7 +207,7 @@ SWGStoreApi::placeOrder(SWGOrder& body) {
QString output = body.asJson();
QString output = order.asJson();
input.request_body.append(output);

View File

@@ -37,8 +37,8 @@ public:
void deleteOrder(QString* order_id);
void getInventory();
void getOrderById(qint64 order_id);
void placeOrder(SWGOrder& body);
void getOrderById(qint32 order_id);
void placeOrder(SWGOrder& order);
private:
void deleteOrderCallback (SWGHttpRequestWorker * worker);

View File

@@ -30,7 +30,7 @@ SWGUserApi::SWGUserApi(QString host, QString basePath) {
}
void
SWGUserApi::createUser(SWGUser& body) {
SWGUserApi::createUser(SWGUser& user) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user");
@@ -41,7 +41,7 @@ SWGUserApi::createUser(SWGUser& body) {
QString output = body.asJson();
QString output = user.asJson();
input.request_body.append(output);
@@ -82,7 +82,7 @@ SWGUserApi::createUserCallback(SWGHttpRequestWorker * worker) {
}
void
SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>*& body) {
SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>*& swg_user) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithArray");
@@ -92,10 +92,10 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>*& body) {
SWGHttpRequestInput input(fullPath, "POST");
QJsonObject body_jobj;
toJsonArray((QList<void*>*)body, body_jobj, QString("body"), QString("SWGUser*"));
QJsonObject swg_user_jobj;
toJsonArray((QList<void*>*)swg_user, swg_user_jobj, QString("body"), QString("SWGUser*"));
QJsonDocument doc(body_jobj);
QJsonDocument doc(swg_user_jobj);
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
@@ -138,7 +138,7 @@ SWGUserApi::createUsersWithArrayInputCallback(SWGHttpRequestWorker * worker) {
}
void
SWGUserApi::createUsersWithListInput(QList<SWGUser*>*& body) {
SWGUserApi::createUsersWithListInput(QList<SWGUser*>*& swg_user) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithList");
@@ -148,10 +148,10 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>*& body) {
SWGHttpRequestInput input(fullPath, "POST");
QJsonObject body_jobj;
toJsonArray((QList<void*>*)body, body_jobj, QString("body"), QString("SWGUser*"));
QJsonObject swg_user_jobj;
toJsonArray((QList<void*>*)swg_user, swg_user_jobj, QString("body"), QString("SWGUser*"));
QJsonDocument doc(body_jobj);
QJsonDocument doc(swg_user_jobj);
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
@@ -418,7 +418,7 @@ SWGUserApi::logoutUserCallback(SWGHttpRequestWorker * worker) {
}
void
SWGUserApi::updateUser(QString* username, SWGUser& body) {
SWGUserApi::updateUser(QString* username, SWGUser& user) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
@@ -431,7 +431,7 @@ SWGUserApi::updateUser(QString* username, SWGUser& body) {
QString output = body.asJson();
QString output = user.asJson();
input.request_body.append(output);

View File

@@ -15,7 +15,6 @@
#include "SWGHttpRequest.h"
#include <QList>
#include <QString>
#include "SWGUser.h"
@@ -35,14 +34,14 @@ public:
QString basePath;
QMap<QString, QString> defaultHeaders;
void createUser(SWGUser& body);
void createUsersWithArrayInput(QList<SWGUser*>*& body);
void createUsersWithListInput(QList<SWGUser*>*& body);
void createUser(SWGUser& user);
void createUsersWithArrayInput(QList<SWGUser*>*& swg_user);
void createUsersWithListInput(QList<SWGUser*>*& swg_user);
void deleteUser(QString* username);
void getUserByName(QString* username);
void loginUser(QString* username, QString* password);
void logoutUser();
void updateUser(QString* username, SWGUser& body);
void updateUser(QString* username, SWGUser& user);
private:
void createUserCallback (SWGHttpRequestWorker * worker);