From e62ba9b35d965619e01a8f9e3b37943bd95c0918 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 16 Apr 2016 18:16:42 +0800 Subject: [PATCH] update qt5cpp and tizen sample --- .../petstore/qt5cpp/client/SWGCategory.cpp | 15 +- .../petstore/qt5cpp/client/SWGCategory.h | 6 +- .../petstore/qt5cpp/client/SWGModelFactory.h | 16 +- .../petstore/qt5cpp/client/SWGOrder.cpp | 50 ++- .../client/petstore/qt5cpp/client/SWGOrder.h | 22 +- .../client/petstore/qt5cpp/client/SWGPet.cpp | 55 ++- .../client/petstore/qt5cpp/client/SWGPet.h | 22 +- .../petstore/qt5cpp/client/SWGPetApi.cpp | 355 +++++------------- .../client/petstore/qt5cpp/client/SWGPetApi.h | 23 +- .../petstore/qt5cpp/client/SWGStoreApi.cpp | 322 +++++++--------- .../petstore/qt5cpp/client/SWGStoreApi.h | 20 +- .../client/petstore/qt5cpp/client/SWGTag.cpp | 15 +- .../client/petstore/qt5cpp/client/SWGTag.h | 6 +- .../client/petstore/qt5cpp/client/SWGUser.cpp | 78 ++-- .../client/petstore/qt5cpp/client/SWGUser.h | 30 +- .../petstore/qt5cpp/client/SWGUserApi.cpp | 243 +++++------- .../petstore/qt5cpp/client/SWGUserApi.h | 12 +- .../petstore/tizen/client/SamiCategory.cpp | 12 +- .../petstore/tizen/client/SamiCategory.h | 6 +- .../petstore/tizen/client/SamiModelFactory.h | 16 +- .../petstore/tizen/client/SamiOrder.cpp | 40 +- .../client/petstore/tizen/client/SamiOrder.h | 24 +- .../client/petstore/tizen/client/SamiPet.cpp | 40 +- .../client/petstore/tizen/client/SamiPet.h | 22 +- .../petstore/tizen/client/SamiPetApi.cpp | 260 ++++++------- .../client/petstore/tizen/client/SamiPetApi.h | 34 +- .../petstore/tizen/client/SamiStoreApi.cpp | 226 +++++------ .../petstore/tizen/client/SamiStoreApi.h | 20 +- .../client/petstore/tizen/client/SamiTag.cpp | 12 +- .../client/petstore/tizen/client/SamiTag.h | 6 +- .../client/petstore/tizen/client/SamiUser.cpp | 54 ++- .../client/petstore/tizen/client/SamiUser.h | 26 +- .../petstore/tizen/client/SamiUserApi.cpp | 269 ++++++------- .../petstore/tizen/client/SamiUserApi.h | 25 +- 34 files changed, 938 insertions(+), 1444 deletions(-) diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp index 9a5aaa14af7..c2f0a7e59b6 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp @@ -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; } diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.h b/samples/client/petstore/qt5cpp/client/SWGCategory.h index b1d5b65538f..248d0630ed7 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.h +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.h @@ -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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h index 588a7ad952b..18cc79911ab 100644 --- a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h +++ b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h @@ -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; diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp index 3e34f2669c7..2be083bbb3e 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp @@ -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; } diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.h b/samples/client/petstore/qt5cpp/client/SWGOrder.h index d17713afe78..fd3855000ea 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.h +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.h @@ -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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.cpp b/samples/client/petstore/qt5cpp/client/SWGPet.cpp index d0e5b8280e2..7152738ad8b 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPet.cpp @@ -27,41 +27,39 @@ SWGPet::~SWGPet() { void SWGPet::init() { id = 0L; - category = new SWGCategory(); - name = new QString(""); - photoUrls = new QList(); - tags = new QList(); - status = new QString(""); - +category = new SWGCategory(); +name = new QString(""); +photoUrls = new QList(); +tags = new QList(); +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* arr = photoUrls; foreach(QString* o, *arr) { delete o; } delete photoUrls; } - if(tags != NULL) { +if(tags != NULL) { QList* 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* photoUrlsList = photoUrls; QJsonArray photoUrlsJsonArray; @@ -118,8 +113,7 @@ SWGPet::asJsonObject() { obj->insert("photoUrls", photoUrlsJsonArray); - - + QList* tagsList = tags; QJsonArray tagsJsonArray; @@ -127,14 +121,11 @@ SWGPet::asJsonObject() { obj->insert("tags", tagsJsonArray); - - + toJsonValue(QString("status"), status, obj, QString("QString")); - - - + return obj; } diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index 7b96ffc03f3..a58e599d218 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -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* getPhotoUrls(); +QList* getPhotoUrls(); void setPhotoUrls(QList* photoUrls); - QList* getTags(); +QList* getTags(); void setTags(QList* tags); - QString* getStatus(); +QString* getStatus(); void setStatus(QString* status); - private: qint64 id; - SWGCategory* category; - QString* name; - QList* photoUrls; - QList* tags; - QString* status; - +SWGCategory* category; +QString* name; +QList* photoUrls; +QList* tags; +QString* status; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index a50c172d5bf..b5e383575be 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -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* 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* 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* 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* 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* 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* 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* 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* 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(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(create(json, QString("QString"))); - - + QString json(worker->response); + SWGApiResponse* output = static_cast(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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index 89055da3b3d..a18a6375555 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -5,6 +5,7 @@ #include "SWGPet.h" #include +#include "SWGApiResponse.h" #include "SWGHttpRequest.h" #include @@ -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* status); void findPetsByTags(QList* 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* summary); void findPetsByTagsSignal(QList* summary); void getPetByIdSignal(SWGPet* summary); + void updatePetSignal(); void updatePetWithFormSignal(); - void deletePetSignal(); - void uploadFileSignal(); - void getPetByIdWithByteArraySignal(QString* summary); - void addPetUsingByteArraySignal(); + void uploadFileSignal(SWGApiResponse* summary); }; } diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index be603573f62..968b89a4116 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -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* output = new QMap(); - - 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(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(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* output = new QMap(); + + 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(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(create(json, QString("SWGOrder"))); + + + worker->deleteLater(); + + emit placeOrderSignal(output); + +} } /* namespace Swagger */ diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h index 7bbe8e5f92a..a90a297499c 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h @@ -3,9 +3,9 @@ #include "SWGHttpRequest.h" +#include #include "QMap.h" #include "SWGOrder.h" -#include #include @@ -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* summary); - void placeOrderSignal(SWGOrder* summary); - void getOrderByIdSignal(SWGOrder* summary); void deleteOrderSignal(); + void getInventorySignal(QMap* summary); + void getOrderByIdSignal(SWGOrder* summary); + void placeOrderSignal(SWGOrder* summary); }; } diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.cpp b/samples/client/petstore/qt5cpp/client/SWGTag.cpp index bb4404de8df..0f10c5ceec7 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGTag.cpp @@ -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; } diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.h b/samples/client/petstore/qt5cpp/client/SWGTag.h index 067b200675b..15ab44f1ac1 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.h +++ b/samples/client/petstore/qt5cpp/client/SWGTag.h @@ -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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.cpp b/samples/client/petstore/qt5cpp/client/SWGUser.cpp index f0d58c7e97b..98704b8ac6a 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUser.cpp @@ -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; } diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.h b/samples/client/petstore/qt5cpp/client/SWGUser.h index eaa0e496c39..c9b0e0509ca 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.h +++ b/samples/client/petstore/qt5cpp/client/SWGUser.h @@ -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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp index 61b92fc5501..45bafbfdc32 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp @@ -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* 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*)body, bodyArray, QString("body"), QString("SWGUser*")); @@ -86,10 +74,8 @@ SWGUserApi::createUsersWithArrayInput(QList* body) { QByteArray bytes = doc.toJson(); input.request_body.append(bytes); - - - + connect(worker, &HttpRequestWorker::on_execution_finished, @@ -121,17 +107,12 @@ SWGUserApi::createUsersWithListInput(QList* 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*)body, bodyArray, QString("body"), QString("SWGUser*")); @@ -139,10 +120,8 @@ SWGUserApi::createUsersWithListInput(QList* 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(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(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(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 */ diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.h b/samples/client/petstore/qt5cpp/client/SWGUserApi.h index 2e3e119dc78..9a7577a4103 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.h @@ -25,31 +25,31 @@ public: void createUser(SWGUser body); void createUsersWithArrayInput(QList* body); void createUsersWithListInput(QList* 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(); }; } diff --git a/samples/client/petstore/tizen/client/SamiCategory.cpp b/samples/client/petstore/tizen/client/SamiCategory.cpp index 185b1f9d895..e0573f5a8f4 100644 --- a/samples/client/petstore/tizen/client/SamiCategory.cpp +++ b/samples/client/petstore/tizen/client/SamiCategory.cpp @@ -23,8 +23,7 @@ SamiCategory::~SamiCategory() { void SamiCategory::init() { pId = null; - pName = null; - +pName = null; } void @@ -34,12 +33,11 @@ SamiCategory::cleanup() { delete pId; pId = null; } - if(pName != null) { +if(pName != null) { delete pName; pName = null; } - } @@ -86,7 +84,7 @@ SamiCategory::fromJsonObject(IJsonValue* pJson) { jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pNameKey = new JsonString(L"name"); +JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { @@ -95,7 +93,6 @@ SamiCategory::fromJsonObject(IJsonValue* pJson) { jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - } } @@ -146,15 +143,12 @@ SamiCategory::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pNameKey = new JsonString(L"name"); pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - return pJsonObject; } diff --git a/samples/client/petstore/tizen/client/SamiCategory.h b/samples/client/petstore/tizen/client/SamiCategory.h index a361ea047fa..d647616809d 100644 --- a/samples/client/petstore/tizen/client/SamiCategory.h +++ b/samples/client/petstore/tizen/client/SamiCategory.h @@ -41,18 +41,14 @@ public: SamiCategory* fromJson(String* obj); - Long* getPId(); void setPId(Long* pId); - String* getPName(); void setPName(String* pName); - private: Long* pId; - String* pName; - +String* pName; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiModelFactory.h b/samples/client/petstore/tizen/client/SamiModelFactory.h index a2e1ab0e0de..29f0e691494 100644 --- a/samples/client/petstore/tizen/client/SamiModelFactory.h +++ b/samples/client/petstore/tizen/client/SamiModelFactory.h @@ -3,29 +3,33 @@ #include "SamiObject.h" -#include "SamiUser.h" +#include "SamiApiResponse.h" #include "SamiCategory.h" +#include "SamiOrder.h" #include "SamiPet.h" #include "SamiTag.h" -#include "SamiOrder.h" +#include "SamiUser.h" namespace Swagger { void* create(String type) { - if(type.Equals(L"SamiUser", true)) { - return new SamiUser(); + if(type.Equals(L"SamiApiResponse", true)) { + return new SamiApiResponse(); } if(type.Equals(L"SamiCategory", true)) { return new SamiCategory(); } + if(type.Equals(L"SamiOrder", true)) { + return new SamiOrder(); + } if(type.Equals(L"SamiPet", true)) { return new SamiPet(); } if(type.Equals(L"SamiTag", true)) { return new SamiTag(); } - if(type.Equals(L"SamiOrder", true)) { - return new SamiOrder(); + if(type.Equals(L"SamiUser", true)) { + return new SamiUser(); } if(type.Equals(L"String", true)) { diff --git a/samples/client/petstore/tizen/client/SamiOrder.cpp b/samples/client/petstore/tizen/client/SamiOrder.cpp index a319e88e616..c2ba4b2bfff 100644 --- a/samples/client/petstore/tizen/client/SamiOrder.cpp +++ b/samples/client/petstore/tizen/client/SamiOrder.cpp @@ -23,12 +23,11 @@ SamiOrder::~SamiOrder() { void SamiOrder::init() { pId = null; - pPetId = null; - pQuantity = null; - pShipDate = null; - pStatus = null; - pComplete = null; - +pPetId = null; +pQuantity = null; +pShipDate = null; +pStatus = null; +pComplete = null; } void @@ -38,32 +37,31 @@ SamiOrder::cleanup() { delete pId; pId = null; } - if(pPetId != null) { +if(pPetId != null) { delete pPetId; pPetId = null; } - if(pQuantity != null) { +if(pQuantity != null) { delete pQuantity; pQuantity = null; } - if(pShipDate != null) { +if(pShipDate != null) { delete pShipDate; pShipDate = null; } - if(pStatus != null) { +if(pStatus != null) { delete pStatus; pStatus = null; } - if(pComplete != null) { +if(pComplete != null) { delete pComplete; pComplete = null; } - } @@ -110,7 +108,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pPetIdKey = new JsonString(L"petId"); +JsonString* pPetIdKey = new JsonString(L"petId"); IJsonValue* pPetIdVal = null; pJsonObject->GetValue(pPetIdKey, pPetIdVal); if(pPetIdVal != null) { @@ -119,7 +117,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pPetId, pPetIdVal, L"Long", L"Long"); } delete pPetIdKey; - JsonString* pQuantityKey = new JsonString(L"quantity"); +JsonString* pQuantityKey = new JsonString(L"quantity"); IJsonValue* pQuantityVal = null; pJsonObject->GetValue(pQuantityKey, pQuantityVal); if(pQuantityVal != null) { @@ -128,7 +126,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pQuantity, pQuantityVal, L"Integer", L"Integer"); } delete pQuantityKey; - JsonString* pShipDateKey = new JsonString(L"shipDate"); +JsonString* pShipDateKey = new JsonString(L"shipDate"); IJsonValue* pShipDateVal = null; pJsonObject->GetValue(pShipDateKey, pShipDateVal); if(pShipDateVal != null) { @@ -137,7 +135,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pShipDate, pShipDateVal, L"DateTime", L"DateTime"); } delete pShipDateKey; - JsonString* pStatusKey = new JsonString(L"status"); +JsonString* pStatusKey = new JsonString(L"status"); IJsonValue* pStatusVal = null; pJsonObject->GetValue(pStatusKey, pStatusVal); if(pStatusVal != null) { @@ -146,7 +144,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pStatus, pStatusVal, L"String", L"String"); } delete pStatusKey; - JsonString* pCompleteKey = new JsonString(L"complete"); +JsonString* pCompleteKey = new JsonString(L"complete"); IJsonValue* pCompleteVal = null; pJsonObject->GetValue(pCompleteKey, pCompleteVal); if(pCompleteVal != null) { @@ -155,7 +153,6 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) { jsonToValue(pComplete, pCompleteVal, L"Boolean", L"Boolean"); } delete pCompleteKey; - } } @@ -206,31 +203,24 @@ SamiOrder::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pPetIdKey = new JsonString(L"petId"); pJsonObject->Add(pPetIdKey, toJson(getPPetId(), "Long", "")); - JsonString *pQuantityKey = new JsonString(L"quantity"); pJsonObject->Add(pQuantityKey, toJson(getPQuantity(), "Integer", "")); - JsonString *pShipDateKey = new JsonString(L"shipDate"); pJsonObject->Add(pShipDateKey, toJson(getPShipDate(), "DateTime", "")); - JsonString *pStatusKey = new JsonString(L"status"); pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); - JsonString *pCompleteKey = new JsonString(L"complete"); pJsonObject->Add(pCompleteKey, toJson(getPComplete(), "Boolean", "")); - return pJsonObject; } diff --git a/samples/client/petstore/tizen/client/SamiOrder.h b/samples/client/petstore/tizen/client/SamiOrder.h index 08b79cc195c..c8719ce14ee 100644 --- a/samples/client/petstore/tizen/client/SamiOrder.h +++ b/samples/client/petstore/tizen/client/SamiOrder.h @@ -17,11 +17,11 @@ using namespace Tizen::Web::Json; -using Tizen::Base::Long; -using Tizen::Base::DateTime; -using Tizen::Base::String; using Tizen::Base::Boolean; +using Tizen::Base::DateTime; using Tizen::Base::Integer; +using Tizen::Base::Long; +using Tizen::Base::String; namespace Swagger { @@ -44,34 +44,26 @@ public: SamiOrder* fromJson(String* obj); - Long* getPId(); void setPId(Long* pId); - Long* getPPetId(); void setPPetId(Long* pPetId); - Integer* getPQuantity(); void setPQuantity(Integer* pQuantity); - DateTime* getPShipDate(); void setPShipDate(DateTime* pShipDate); - String* getPStatus(); void setPStatus(String* pStatus); - Boolean* getPComplete(); void setPComplete(Boolean* pComplete); - private: Long* pId; - Long* pPetId; - Integer* pQuantity; - DateTime* pShipDate; - String* pStatus; - Boolean* pComplete; - +Long* pPetId; +Integer* pQuantity; +DateTime* pShipDate; +String* pStatus; +Boolean* pComplete; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiPet.cpp b/samples/client/petstore/tizen/client/SamiPet.cpp index ecf63f060a4..16417a43866 100644 --- a/samples/client/petstore/tizen/client/SamiPet.cpp +++ b/samples/client/petstore/tizen/client/SamiPet.cpp @@ -23,12 +23,11 @@ SamiPet::~SamiPet() { void SamiPet::init() { pId = null; - pCategory = null; - pName = null; - pPhotoUrls = null; - pTags = null; - pStatus = null; - +pCategory = null; +pName = null; +pPhotoUrls = null; +pTags = null; +pStatus = null; } void @@ -38,32 +37,31 @@ SamiPet::cleanup() { delete pId; pId = null; } - if(pCategory != null) { +if(pCategory != null) { delete pCategory; pCategory = null; } - if(pName != null) { +if(pName != null) { delete pName; pName = null; } - if(pPhotoUrls != null) { +if(pPhotoUrls != null) { pPhotoUrls->RemoveAll(true); delete pPhotoUrls; pPhotoUrls = null; } - if(pTags != null) { +if(pTags != null) { pTags->RemoveAll(true); delete pTags; pTags = null; } - if(pStatus != null) { +if(pStatus != null) { delete pStatus; pStatus = null; } - } @@ -110,7 +108,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pCategoryKey = new JsonString(L"category"); +JsonString* pCategoryKey = new JsonString(L"category"); IJsonValue* pCategoryVal = null; pJsonObject->GetValue(pCategoryKey, pCategoryVal); if(pCategoryVal != null) { @@ -119,7 +117,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pCategory, pCategoryVal, L"SamiCategory", L"SamiCategory"); } delete pCategoryKey; - JsonString* pNameKey = new JsonString(L"name"); +JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { @@ -128,7 +126,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls"); +JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls"); IJsonValue* pPhotoUrlsVal = null; pJsonObject->GetValue(pPhotoUrlsKey, pPhotoUrlsVal); if(pPhotoUrlsVal != null) { @@ -137,7 +135,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pPhotoUrls, pPhotoUrlsVal, L"IList", L"String"); } delete pPhotoUrlsKey; - JsonString* pTagsKey = new JsonString(L"tags"); +JsonString* pTagsKey = new JsonString(L"tags"); IJsonValue* pTagsVal = null; pJsonObject->GetValue(pTagsKey, pTagsVal); if(pTagsVal != null) { @@ -146,7 +144,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pTags, pTagsVal, L"IList", L"SamiTag"); } delete pTagsKey; - JsonString* pStatusKey = new JsonString(L"status"); +JsonString* pStatusKey = new JsonString(L"status"); IJsonValue* pStatusVal = null; pJsonObject->GetValue(pStatusKey, pStatusVal); if(pStatusVal != null) { @@ -155,7 +153,6 @@ SamiPet::fromJsonObject(IJsonValue* pJson) { jsonToValue(pStatus, pStatusVal, L"String", L"String"); } delete pStatusKey; - } } @@ -206,31 +203,24 @@ SamiPet::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pCategoryKey = new JsonString(L"category"); pJsonObject->Add(pCategoryKey, toJson(getPCategory(), "SamiCategory", "")); - JsonString *pNameKey = new JsonString(L"name"); pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls"); pJsonObject->Add(pPhotoUrlsKey, toJson(getPPhotoUrls(), "String", "array")); - JsonString *pTagsKey = new JsonString(L"tags"); pJsonObject->Add(pTagsKey, toJson(getPTags(), "SamiTag", "array")); - JsonString *pStatusKey = new JsonString(L"status"); pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); - return pJsonObject; } diff --git a/samples/client/petstore/tizen/client/SamiPet.h b/samples/client/petstore/tizen/client/SamiPet.h index a1658248436..3a22ea3a58d 100644 --- a/samples/client/petstore/tizen/client/SamiPet.h +++ b/samples/client/petstore/tizen/client/SamiPet.h @@ -18,10 +18,10 @@ using namespace Tizen::Web::Json; #include "SamiCategory.h" -using Tizen::Base::Long; -using Tizen::Base::String; #include "SamiTag.h" using Tizen::Base::Collection::IList; +using Tizen::Base::Long; +using Tizen::Base::String; namespace Swagger { @@ -44,34 +44,26 @@ public: SamiPet* fromJson(String* obj); - Long* getPId(); void setPId(Long* pId); - SamiCategory* getPCategory(); void setPCategory(SamiCategory* pCategory); - String* getPName(); void setPName(String* pName); - IList* getPPhotoUrls(); void setPPhotoUrls(IList* pPhotoUrls); - IList* getPTags(); void setPTags(IList* pTags); - String* getPStatus(); void setPStatus(String* pStatus); - private: Long* pId; - SamiCategory* pCategory; - String* pName; - IList* pPhotoUrls; - IList* pTags; - String* pStatus; - +SamiCategory* pCategory; +String* pName; +IList* pPhotoUrls; +IList* pTags; +String* pStatus; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiPetApi.cpp b/samples/client/petstore/tizen/client/SamiPetApi.cpp index 787e79964c2..9f1b330ce83 100644 --- a/samples/client/petstore/tizen/client/SamiPetApi.cpp +++ b/samples/client/petstore/tizen/client/SamiPetApi.cpp @@ -16,55 +16,6 @@ SamiPetApi::~SamiPetApi() { } -void -updatePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiPetApi::updatePetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&updatePetProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - - String url(L"/pet"); - - - - client->execute(SamiPetApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - void addPetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); @@ -88,29 +39,64 @@ SamiPetApi::addPetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { headerParams->Construct(); + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + String* mBody = null; + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + String url(L"/pet"); + + + client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + +} + +void +deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } +} + +void +SamiPetApi::deletePetWithCompletion(Long* petId, String* apiKey, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + headerParams->Add(new String("api_key"), apiKey); HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - - - if(body != null) { - mBody = new String(body->asJson()); - headerParams->Add(new String("Content-Type"), new String("application/json")); - } - - - String url(L"/pet"); + String url(L"/pet/{petId}"); - + String s_petId(L"{"); + s_petId.Append(L"petId"); + s_petId.Append(L"}"); + url.Replace(s_petId, stringify(petId, L"Long*")); - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + client->execute(SamiPetApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); } @@ -158,7 +144,6 @@ SamiPetApi::findPetsByStatusWithCompletion(IList* status, void (* success)(IList headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); @@ -169,15 +154,11 @@ SamiPetApi::findPetsByStatusWithCompletion(IList* status, void (* success)(IList queryParams->Add(new String("status"), new String(itemAt)); } - - String* mBody = null; - String url(L"/pet/findByStatus"); - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; @@ -227,7 +208,6 @@ SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, S headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); @@ -238,15 +218,11 @@ SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, S queryParams->Add(new String("tags"), new String(itemAt)); } - - String* mBody = null; - String url(L"/pet/findByTags"); - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; @@ -296,29 +272,65 @@ SamiPetApi::getPetByIdWithCompletion(Long* petId, void (* success)(SamiPet*, Sam headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - String url(L"/pet/{petId}"); - String s_petId(L"{"); s_petId.Append(L"petId"); s_petId.Append(L"}"); url.Replace(s_petId, stringify(petId, L"Long*")); - client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; } +void +updatePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } +} + +void +SamiPetApi::updatePetWithCompletion(SamiPet* body, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&updatePetProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + String* mBody = null; + + if(body != null) { + mBody = new String(body->asJson()); + headerParams->Add(new String("Content-Type"), new String("application/json")); + } + + String url(L"/pet"); + + + client->execute(SamiPetApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + +} + void updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); @@ -334,7 +346,7 @@ updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, } void -SamiPetApi::updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(*success)(SamiError*)) { +SamiPetApi::updatePetWithFormWithCompletion(Long* petId, String* name, String* status, void(*success)(SamiError*)) { client = new SamiApiClient(); client->success(&updatePetWithFormProcessor, (void(*)(void*, SamiError*))success); @@ -342,75 +354,21 @@ SamiPetApi::updatePetWithFormWithCompletion(String* petId, String* name, String* headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - String url(L"/pet/{petId}"); - - String s_petId(L"{"); - s_petId.Append(L"petId"); - s_petId.Append(L"}"); - url.Replace(s_petId, stringify(petId, L"String*")); - - - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - -void -deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiPetApi::deletePetWithCompletion(Long* petId, String* apiKey, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - headerParams->Add(new String("api_key"), apiKey); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/pet/{petId}"); - - String s_petId(L"{"); s_petId.Append(L"petId"); s_petId.Append(L"}"); url.Replace(s_petId, stringify(petId, L"Long*")); - - client->execute(SamiPetApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); } @@ -419,17 +377,38 @@ uploadFileProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiErr int code = pHttpResponse->GetHttpStatusCode(); if(code >= 200 && code < 300) { - handler(null, null); + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + SamiApiResponse* out = new SamiApiResponse(); + jsonToValue(out, pJson, L"SamiApiResponse*", L"SamiApiResponse"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + } else { SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); - handler(error, null); } } -void -SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(*success)(SamiError*)) { +SamiApiResponse* +SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void (* success)(SamiApiResponse*, SamiError*)) { client = new SamiApiClient(); client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success); @@ -437,27 +416,22 @@ SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, Sa headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - String url(L"/pet/{petId}/uploadImage"); - String s_petId(L"{"); s_petId.Append(L"petId"); s_petId.Append(L"}"); url.Replace(s_petId, stringify(petId, L"Long*")); - client->execute(SamiPetApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - + return null; } diff --git a/samples/client/petstore/tizen/client/SamiPetApi.h b/samples/client/petstore/tizen/client/SamiPetApi.h index a0fc01f08f5..0b5fae406a7 100644 --- a/samples/client/petstore/tizen/client/SamiPetApi.h +++ b/samples/client/petstore/tizen/client/SamiPetApi.h @@ -6,9 +6,10 @@ #include "SamiError.h" #include "SamiPet.h" -using Tizen::Base::String; using Tizen::Base::Long; +using Tizen::Base::String; #include "SamiFile.h" +#include "SamiApiResponse.h" using namespace Tizen::Net::Http; @@ -19,31 +20,22 @@ public: SamiPetApi(); virtual ~SamiPetApi(); - - void - updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - void addPetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); - - IList* - findPetsByStatusWithCompletion(IList* status, void (* handler)(IList*, SamiError*)); - - IList* - findPetsByTagsWithCompletion(IList* tags, void (* handler)(IList*, SamiError*)); - - SamiPet* - getPetByIdWithCompletion(Long* petId, void (* handler)(SamiPet*, SamiError*)); - - void - updatePetWithFormWithCompletion(String* petId, String* name, String* status, void(* handler)(SamiError*)); - void deletePetWithCompletion(Long* petId, String* apiKey, void(* handler)(SamiError*)); - + IList* + findPetsByStatusWithCompletion(IList* status, void (* handler)(IList*, SamiError*)); + IList* + findPetsByTagsWithCompletion(IList* tags, void (* handler)(IList*, SamiError*)); + SamiPet* + getPetByIdWithCompletion(Long* petId, void (* handler)(SamiPet*, SamiError*)); void - uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(* handler)(SamiError*)); - + updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); + void + updatePetWithFormWithCompletion(Long* petId, String* name, String* status, void(* handler)(SamiError*)); + SamiApiResponse* + uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void (* handler)(SamiApiResponse*, SamiError*)); static String getBasePath() { return L"http://petstore.swagger.io/v2"; } diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.cpp b/samples/client/petstore/tizen/client/SamiStoreApi.cpp index c567896c48d..47ed2ec0196 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.cpp +++ b/samples/client/petstore/tizen/client/SamiStoreApi.cpp @@ -16,6 +16,47 @@ SamiStoreApi::~SamiStoreApi() { } +void +deleteOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } +} + +void +SamiStoreApi::deleteOrderWithCompletion(String* orderId, void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&deleteOrderProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + String* mBody = null; + + + String url(L"/store/order/{orderId}"); + + String s_orderId(L"{"); + s_orderId.Append(L"orderId"); + s_orderId.Append(L"}"); + url.Replace(s_orderId, stringify(orderId, L"String*")); + + client->execute(SamiStoreApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + +} + void getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); @@ -60,19 +101,77 @@ SamiStoreApi::getInventoryWithCompletion( void (* success)(HashMap*, SamiError*) headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - String url(L"/store/inventory"); + + client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; +} + +void +getOrderByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + SamiOrder* out = new SamiOrder(); + jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } +} + +SamiOrder* +SamiStoreApi::getOrderByIdWithCompletion(Long* orderId, void (* success)(SamiOrder*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&getOrderByIdProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + String* mBody = null; + + + String url(L"/store/order/{orderId}"); + + String s_orderId(L"{"); + s_orderId.Append(L"orderId"); + s_orderId.Append(L"}"); + url.Replace(s_orderId, stringify(orderId, L"Long*")); client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; @@ -122,144 +221,23 @@ SamiStoreApi::placeOrderWithCompletion(SamiOrder* body, void (* success)(SamiOrd headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - - if(body != null) { mBody = new String(body->asJson()); headerParams->Add(new String("Content-Type"), new String("application/json")); } - - String url(L"/store/order"); - client->execute(SamiStoreApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; } -void -getOrderByIdProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - SamiOrder* out = new SamiOrder(); - jsonToValue(out, pJson, L"SamiOrder*", L"SamiOrder"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); - - } -} - -SamiOrder* -SamiStoreApi::getOrderByIdWithCompletion(String* orderId, void (* success)(SamiOrder*, SamiError*)) { - client = new SamiApiClient(); - - client->success(&getOrderByIdProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/store/order/{orderId}"); - - - String s_orderId(L"{"); - s_orderId.Append(L"orderId"); - s_orderId.Append(L"}"); - url.Replace(s_orderId, stringify(orderId, L"String*")); - - - client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} - -void -deleteOrderProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiStoreApi::deleteOrderWithCompletion(String* orderId, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&deleteOrderProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/store/order/{orderId}"); - - - String s_orderId(L"{"); - s_orderId.Append(L"orderId"); - s_orderId.Append(L"}"); - url.Replace(s_orderId, stringify(orderId, L"String*")); - - - client->execute(SamiStoreApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiStoreApi.h b/samples/client/petstore/tizen/client/SamiStoreApi.h index a36f4ba6ee9..574207a0b88 100644 --- a/samples/client/petstore/tizen/client/SamiStoreApi.h +++ b/samples/client/petstore/tizen/client/SamiStoreApi.h @@ -5,9 +5,10 @@ #include "SamiApiClient.h" #include "SamiError.h" +using Tizen::Base::String; using Tizen::Base::Integer; #include "SamiOrder.h" -using Tizen::Base::String; +using Tizen::Base::Long; using namespace Tizen::Net::Http; @@ -18,19 +19,14 @@ public: SamiStoreApi(); virtual ~SamiStoreApi(); - - HashMap* - getInventoryWithCompletion( void (* handler)(HashMap*, SamiError*)); - - SamiOrder* - placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder*, SamiError*)); - - SamiOrder* - getOrderByIdWithCompletion(String* orderId, void (* handler)(SamiOrder*, SamiError*)); - void deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*)); - + HashMap* + getInventoryWithCompletion( void (* handler)(HashMap*, SamiError*)); + SamiOrder* + getOrderByIdWithCompletion(Long* orderId, void (* handler)(SamiOrder*, SamiError*)); + SamiOrder* + placeOrderWithCompletion(SamiOrder* body, void (* handler)(SamiOrder*, SamiError*)); static String getBasePath() { return L"http://petstore.swagger.io/v2"; } diff --git a/samples/client/petstore/tizen/client/SamiTag.cpp b/samples/client/petstore/tizen/client/SamiTag.cpp index d07b64a531d..d31e52cfebd 100644 --- a/samples/client/petstore/tizen/client/SamiTag.cpp +++ b/samples/client/petstore/tizen/client/SamiTag.cpp @@ -23,8 +23,7 @@ SamiTag::~SamiTag() { void SamiTag::init() { pId = null; - pName = null; - +pName = null; } void @@ -34,12 +33,11 @@ SamiTag::cleanup() { delete pId; pId = null; } - if(pName != null) { +if(pName != null) { delete pName; pName = null; } - } @@ -86,7 +84,7 @@ SamiTag::fromJsonObject(IJsonValue* pJson) { jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pNameKey = new JsonString(L"name"); +JsonString* pNameKey = new JsonString(L"name"); IJsonValue* pNameVal = null; pJsonObject->GetValue(pNameKey, pNameVal); if(pNameVal != null) { @@ -95,7 +93,6 @@ SamiTag::fromJsonObject(IJsonValue* pJson) { jsonToValue(pName, pNameVal, L"String", L"String"); } delete pNameKey; - } } @@ -146,15 +143,12 @@ SamiTag::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pNameKey = new JsonString(L"name"); pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); - return pJsonObject; } diff --git a/samples/client/petstore/tizen/client/SamiTag.h b/samples/client/petstore/tizen/client/SamiTag.h index 6521b0a6bed..d248df55cba 100644 --- a/samples/client/petstore/tizen/client/SamiTag.h +++ b/samples/client/petstore/tizen/client/SamiTag.h @@ -41,18 +41,14 @@ public: SamiTag* fromJson(String* obj); - Long* getPId(); void setPId(Long* pId); - String* getPName(); void setPName(String* pName); - private: Long* pId; - String* pName; - +String* pName; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiUser.cpp b/samples/client/petstore/tizen/client/SamiUser.cpp index 916bec83d5a..3544b624f3e 100644 --- a/samples/client/petstore/tizen/client/SamiUser.cpp +++ b/samples/client/petstore/tizen/client/SamiUser.cpp @@ -23,14 +23,13 @@ SamiUser::~SamiUser() { void SamiUser::init() { pId = null; - pUsername = null; - pFirstName = null; - pLastName = null; - pEmail = null; - pPassword = null; - pPhone = null; - pUserStatus = null; - +pUsername = null; +pFirstName = null; +pLastName = null; +pEmail = null; +pPassword = null; +pPhone = null; +pUserStatus = null; } void @@ -40,42 +39,41 @@ SamiUser::cleanup() { delete pId; pId = null; } - if(pUsername != null) { +if(pUsername != null) { delete pUsername; pUsername = null; } - if(pFirstName != null) { +if(pFirstName != null) { delete pFirstName; pFirstName = null; } - if(pLastName != null) { +if(pLastName != null) { delete pLastName; pLastName = null; } - if(pEmail != null) { +if(pEmail != null) { delete pEmail; pEmail = null; } - if(pPassword != null) { +if(pPassword != null) { delete pPassword; pPassword = null; } - if(pPhone != null) { +if(pPhone != null) { delete pPhone; pPhone = null; } - if(pUserStatus != null) { +if(pUserStatus != null) { delete pUserStatus; pUserStatus = null; } - } @@ -122,7 +120,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pId, pIdVal, L"Long", L"Long"); } delete pIdKey; - JsonString* pUsernameKey = new JsonString(L"username"); +JsonString* pUsernameKey = new JsonString(L"username"); IJsonValue* pUsernameVal = null; pJsonObject->GetValue(pUsernameKey, pUsernameVal); if(pUsernameVal != null) { @@ -131,7 +129,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pUsername, pUsernameVal, L"String", L"String"); } delete pUsernameKey; - JsonString* pFirstNameKey = new JsonString(L"firstName"); +JsonString* pFirstNameKey = new JsonString(L"firstName"); IJsonValue* pFirstNameVal = null; pJsonObject->GetValue(pFirstNameKey, pFirstNameVal); if(pFirstNameVal != null) { @@ -140,7 +138,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pFirstName, pFirstNameVal, L"String", L"String"); } delete pFirstNameKey; - JsonString* pLastNameKey = new JsonString(L"lastName"); +JsonString* pLastNameKey = new JsonString(L"lastName"); IJsonValue* pLastNameVal = null; pJsonObject->GetValue(pLastNameKey, pLastNameVal); if(pLastNameVal != null) { @@ -149,7 +147,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pLastName, pLastNameVal, L"String", L"String"); } delete pLastNameKey; - JsonString* pEmailKey = new JsonString(L"email"); +JsonString* pEmailKey = new JsonString(L"email"); IJsonValue* pEmailVal = null; pJsonObject->GetValue(pEmailKey, pEmailVal); if(pEmailVal != null) { @@ -158,7 +156,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pEmail, pEmailVal, L"String", L"String"); } delete pEmailKey; - JsonString* pPasswordKey = new JsonString(L"password"); +JsonString* pPasswordKey = new JsonString(L"password"); IJsonValue* pPasswordVal = null; pJsonObject->GetValue(pPasswordKey, pPasswordVal); if(pPasswordVal != null) { @@ -167,7 +165,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pPassword, pPasswordVal, L"String", L"String"); } delete pPasswordKey; - JsonString* pPhoneKey = new JsonString(L"phone"); +JsonString* pPhoneKey = new JsonString(L"phone"); IJsonValue* pPhoneVal = null; pJsonObject->GetValue(pPhoneKey, pPhoneVal); if(pPhoneVal != null) { @@ -176,7 +174,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pPhone, pPhoneVal, L"String", L"String"); } delete pPhoneKey; - JsonString* pUserStatusKey = new JsonString(L"userStatus"); +JsonString* pUserStatusKey = new JsonString(L"userStatus"); IJsonValue* pUserStatusVal = null; pJsonObject->GetValue(pUserStatusKey, pUserStatusVal); if(pUserStatusVal != null) { @@ -185,7 +183,6 @@ SamiUser::fromJsonObject(IJsonValue* pJson) { jsonToValue(pUserStatus, pUserStatusVal, L"Integer", L"Integer"); } delete pUserStatusKey; - } } @@ -236,39 +233,30 @@ SamiUser::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); - JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); - JsonString *pUsernameKey = new JsonString(L"username"); pJsonObject->Add(pUsernameKey, toJson(getPUsername(), "String", "")); - JsonString *pFirstNameKey = new JsonString(L"firstName"); pJsonObject->Add(pFirstNameKey, toJson(getPFirstName(), "String", "")); - JsonString *pLastNameKey = new JsonString(L"lastName"); pJsonObject->Add(pLastNameKey, toJson(getPLastName(), "String", "")); - JsonString *pEmailKey = new JsonString(L"email"); pJsonObject->Add(pEmailKey, toJson(getPEmail(), "String", "")); - JsonString *pPasswordKey = new JsonString(L"password"); pJsonObject->Add(pPasswordKey, toJson(getPPassword(), "String", "")); - JsonString *pPhoneKey = new JsonString(L"phone"); pJsonObject->Add(pPhoneKey, toJson(getPPhone(), "String", "")); - JsonString *pUserStatusKey = new JsonString(L"userStatus"); pJsonObject->Add(pUserStatusKey, toJson(getPUserStatus(), "Integer", "")); - return pJsonObject; } diff --git a/samples/client/petstore/tizen/client/SamiUser.h b/samples/client/petstore/tizen/client/SamiUser.h index a874f9c6245..6c456ae1fa1 100644 --- a/samples/client/petstore/tizen/client/SamiUser.h +++ b/samples/client/petstore/tizen/client/SamiUser.h @@ -17,9 +17,9 @@ using namespace Tizen::Web::Json; +using Tizen::Base::Integer; using Tizen::Base::Long; using Tizen::Base::String; -using Tizen::Base::Integer; namespace Swagger { @@ -42,42 +42,32 @@ public: SamiUser* fromJson(String* obj); - Long* getPId(); void setPId(Long* pId); - String* getPUsername(); void setPUsername(String* pUsername); - String* getPFirstName(); void setPFirstName(String* pFirstName); - String* getPLastName(); void setPLastName(String* pLastName); - String* getPEmail(); void setPEmail(String* pEmail); - String* getPPassword(); void setPPassword(String* pPassword); - String* getPPhone(); void setPPhone(String* pPhone); - Integer* getPUserStatus(); void setPUserStatus(Integer* pUserStatus); - private: Long* pId; - String* pUsername; - String* pFirstName; - String* pLastName; - String* pEmail; - String* pPassword; - String* pPhone; - Integer* pUserStatus; - +String* pUsername; +String* pFirstName; +String* pLastName; +String* pEmail; +String* pPassword; +String* pPhone; +Integer* pUserStatus; }; } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiUserApi.cpp b/samples/client/petstore/tizen/client/SamiUserApi.cpp index 7010ed6bac7..9ebb2b02fe6 100644 --- a/samples/client/petstore/tizen/client/SamiUserApi.cpp +++ b/samples/client/petstore/tizen/client/SamiUserApi.cpp @@ -39,27 +39,19 @@ SamiUserApi::createUserWithCompletion(SamiUser* body, void(*success)(SamiError*) headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - - if(body != null) { mBody = new String(body->asJson()); headerParams->Add(new String("Content-Type"), new String("application/json")); } - - String url(L"/user"); - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); @@ -88,16 +80,12 @@ SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success) headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - if(body != null) { mBody = new String(""); int sz = body->GetCount(); @@ -111,13 +99,9 @@ SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success) mBody->Append("]"); headerParams->Add(new String("Content-Type"), new String("application/json")); } - - - String url(L"/user/createWithArray"); - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); @@ -146,16 +130,12 @@ SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)( headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - if(body != null) { mBody = new String(""); int sz = body->GetCount(); @@ -169,88 +149,16 @@ SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)( mBody->Append("]"); headerParams->Add(new String("Content-Type"), new String("application/json")); } - - - String url(L"/user/createWithList"); - client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); } void -loginUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); - IJsonValue* pJson = JsonParser::ParseN(*pBuffer); - - String* out = new String(); - jsonToValue(out, pJson, L"String*", L"String"); - - if (pJson) { - if (pJson->GetType() == JSON_TYPE_OBJECT) { - JsonObject* pObject = static_cast< JsonObject* >(pJson); - pObject->RemoveAll(true); - } - else if (pJson->GetType() == JSON_TYPE_ARRAY) { - JsonArray* pArray = static_cast< JsonArray* >(pJson); - pArray->RemoveAll(true); - } - handler(out, null); - } - else { - SamiError* error = new SamiError(0, new String(L"No parsable response received")); - handler(null, error); - } - - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - handler(null, error); - - } -} - -String* -SamiUserApi::loginUserWithCompletion(String* username, String* password, void (* success)(String*, SamiError*)) { - client = new SamiApiClient(); - - client->success(&loginUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - queryParams->Add(new String("username"), username); - - - queryParams->Add(new String("password"), password); - - - - String* mBody = null; - - - - String url(L"/user/login"); - - - - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - return null; -} - -void -logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { +deleteUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); if(code >= 200 && code < 300) { @@ -264,29 +172,29 @@ logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiErr } void -SamiUserApi::logoutUserWithCompletion( void(*success)(SamiError*)) { +SamiUserApi::deleteUserWithCompletion(String* username, void(*success)(SamiError*)) { client = new SamiApiClient(); - client->success(&logoutUserProcessor, (void(*)(void*, SamiError*))success); + client->success(&deleteUserProcessor, (void(*)(void*, SamiError*))success); HashMap* headerParams = new HashMap(SingleObjectDeleter); headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - String url(L"/user/logout"); + String url(L"/user/{username}"); - + String s_username(L"{"); + s_username.Append(L"username"); + s_username.Append(L"}"); + url.Replace(s_username, stringify(username, L"String*")); - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + client->execute(SamiUserApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); } @@ -334,29 +242,123 @@ SamiUserApi::getUserByNameWithCompletion(String* username, void (* success)(Sami headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - String url(L"/user/{username}"); - String s_username(L"{"); s_username.Append(L"username"); s_username.Append(L"}"); url.Replace(s_username, stringify(username, L"String*")); - client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); return null; } +void +loginUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + ByteBuffer* pBuffer = pHttpResponse->ReadBodyN(); + IJsonValue* pJson = JsonParser::ParseN(*pBuffer); + + String* out = new String(); + jsonToValue(out, pJson, L"String*", L"String"); + + if (pJson) { + if (pJson->GetType() == JSON_TYPE_OBJECT) { + JsonObject* pObject = static_cast< JsonObject* >(pJson); + pObject->RemoveAll(true); + } + else if (pJson->GetType() == JSON_TYPE_ARRAY) { + JsonArray* pArray = static_cast< JsonArray* >(pJson); + pArray->RemoveAll(true); + } + handler(out, null); + } + else { + SamiError* error = new SamiError(0, new String(L"No parsable response received")); + handler(null, error); + } + + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + handler(null, error); + + } +} + +String* +SamiUserApi::loginUserWithCompletion(String* username, String* password, void (* success)(String*, SamiError*)) { + client = new SamiApiClient(); + + client->success(&loginUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + queryParams->Add(new String("username"), username); + + queryParams->Add(new String("password"), password); + + String* mBody = null; + + + String url(L"/user/login"); + + + client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + return null; +} + +void +logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { + int code = pHttpResponse->GetHttpStatusCode(); + + if(code >= 200 && code < 300) { + handler(null, null); + } + else { + SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); + + handler(error, null); + } +} + +void +SamiUserApi::logoutUserWithCompletion( void(*success)(SamiError*)) { + client = new SamiApiClient(); + + client->success(&logoutUserProcessor, (void(*)(void*, SamiError*))success); + HashMap* headerParams = new HashMap(SingleObjectDeleter); + headerParams->Construct(); + + + HashMap* queryParams = new HashMap(SingleObjectDeleter); + queryParams->Construct(); + + + String* mBody = null; + + + String url(L"/user/logout"); + + + client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); + +} + void updateUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { int code = pHttpResponse->GetHttpStatusCode(); @@ -380,82 +382,27 @@ SamiUserApi::updateUserWithCompletion(String* username, SamiUser* body, void(*su headerParams->Construct(); - HashMap* queryParams = new HashMap(SingleObjectDeleter); queryParams->Construct(); - String* mBody = null; - - - if(body != null) { mBody = new String(body->asJson()); headerParams->Add(new String("Content-Type"), new String("application/json")); } - - String url(L"/user/{username}"); - String s_username(L"{"); s_username.Append(L"username"); s_username.Append(L"}"); url.Replace(s_username, stringify(username, L"String*")); - client->execute(SamiUserApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); } -void -deleteUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { - int code = pHttpResponse->GetHttpStatusCode(); - - if(code >= 200 && code < 300) { - handler(null, null); - } - else { - SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); - - handler(error, null); - } -} - -void -SamiUserApi::deleteUserWithCompletion(String* username, void(*success)(SamiError*)) { - client = new SamiApiClient(); - - client->success(&deleteUserProcessor, (void(*)(void*, SamiError*))success); - HashMap* headerParams = new HashMap(SingleObjectDeleter); - headerParams->Construct(); - - - - HashMap* queryParams = new HashMap(SingleObjectDeleter); - queryParams->Construct(); - - - - String* mBody = null; - - - - String url(L"/user/{username}"); - - - String s_username(L"{"); - s_username.Append(L"username"); - s_username.Append(L"}"); - url.Replace(s_username, stringify(username, L"String*")); - - - client->execute(SamiUserApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); - -} - } /* namespace Swagger */ diff --git a/samples/client/petstore/tizen/client/SamiUserApi.h b/samples/client/petstore/tizen/client/SamiUserApi.h index 1b42e3bc3b1..2851cb91419 100644 --- a/samples/client/petstore/tizen/client/SamiUserApi.h +++ b/samples/client/petstore/tizen/client/SamiUserApi.h @@ -18,31 +18,22 @@ public: SamiUserApi(); virtual ~SamiUserApi(); - void createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*)); - void createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*)); - void createUsersWithListInputWithCompletion(IList* body, void(* handler)(SamiError*)); - - String* - loginUserWithCompletion(String* username, String* password, void (* handler)(String*, SamiError*)); - - void - logoutUserWithCompletion( void(* handler)(SamiError*)); - - SamiUser* - getUserByNameWithCompletion(String* username, void (* handler)(SamiUser*, SamiError*)); - - void - updateUserWithCompletion(String* username, SamiUser* body, void(* handler)(SamiError*)); - void deleteUserWithCompletion(String* username, void(* handler)(SamiError*)); - + SamiUser* + getUserByNameWithCompletion(String* username, void (* handler)(SamiUser*, SamiError*)); + String* + loginUserWithCompletion(String* username, String* password, void (* handler)(String*, SamiError*)); + void + logoutUserWithCompletion( void(* handler)(SamiError*)); + void + updateUserWithCompletion(String* username, SamiUser* body, void(* handler)(SamiError*)); static String getBasePath() { return L"http://petstore.swagger.io/v2"; }