update qt5cpp and tizen sample

This commit is contained in:
wing328 2016-04-16 18:16:42 +08:00
parent 1d5a0e5b33
commit e62ba9b35d
34 changed files with 938 additions and 1444 deletions

View File

@ -27,17 +27,15 @@ SWGCategory::~SWGCategory() {
void void
SWGCategory::init() { SWGCategory::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
SWGCategory::cleanup() { SWGCategory::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGCategory* SWGCategory*
@ -52,8 +50,7 @@ SWGCategory::fromJson(QString &json) {
void void
SWGCategory::fromJsonObject(QJsonObject &pJson) { SWGCategory::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
} }
QString QString
@ -70,13 +67,11 @@ QJsonObject*
SWGCategory::asJsonObject() { SWGCategory::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
toJsonValue(QString("name"), name, obj, QString("QString")); toJsonValue(QString("name"), name, obj, QString("QString"));
return obj; return obj;
} }

View File

@ -32,14 +32,12 @@ public:
qint64 getId(); qint64 getId();
void setId(qint64 id); void setId(qint64 id);
QString* getName(); QString* getName();
void setName(QString* name); void setName(QString* name);
private: private:
qint64 id; qint64 id;
QString* name; QString* name;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -2,28 +2,32 @@
#define ModelFactory_H_ #define ModelFactory_H_
#include "SWGUser.h" #include "SWGApiResponse.h"
#include "SWGCategory.h" #include "SWGCategory.h"
#include "SWGOrder.h"
#include "SWGPet.h" #include "SWGPet.h"
#include "SWGTag.h" #include "SWGTag.h"
#include "SWGOrder.h" #include "SWGUser.h"
namespace Swagger { namespace Swagger {
inline void* create(QString type) { inline void* create(QString type) {
if(QString("SWGUser").compare(type) == 0) { if(QString("SWGApiResponse").compare(type) == 0) {
return new SWGUser(); return new SWGApiResponse();
} }
if(QString("SWGCategory").compare(type) == 0) { if(QString("SWGCategory").compare(type) == 0) {
return new SWGCategory(); return new SWGCategory();
} }
if(QString("SWGOrder").compare(type) == 0) {
return new SWGOrder();
}
if(QString("SWGPet").compare(type) == 0) { if(QString("SWGPet").compare(type) == 0) {
return new SWGPet(); return new SWGPet();
} }
if(QString("SWGTag").compare(type) == 0) { if(QString("SWGTag").compare(type) == 0) {
return new SWGTag(); return new SWGTag();
} }
if(QString("SWGOrder").compare(type) == 0) { if(QString("SWGUser").compare(type) == 0) {
return new SWGOrder(); return new SWGUser();
} }
return NULL; return NULL;

View File

@ -27,27 +27,25 @@ SWGOrder::~SWGOrder() {
void void
SWGOrder::init() { SWGOrder::init() {
id = 0L; id = 0L;
petId = 0L; petId = 0L;
quantity = 0; quantity = 0;
shipDate = NULL; shipDate = NULL;
status = new QString(""); status = new QString("");
complete = false; complete = false;
} }
void void
SWGOrder::cleanup() { SWGOrder::cleanup() {
if(shipDate != NULL) { if(shipDate != NULL) {
delete shipDate; delete shipDate;
} }
if(status != NULL) { if(status != NULL) {
delete status; delete status;
} }
} }
SWGOrder* SWGOrder*
@ -62,12 +60,11 @@ SWGOrder::fromJson(QString &json) {
void void
SWGOrder::fromJsonObject(QJsonObject &pJson) { SWGOrder::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&petId, pJson["petId"], "qint64", ""); setValue(&petId, pJson["petId"], "qint64", "");
setValue(&quantity, pJson["quantity"], "qint32", ""); setValue(&quantity, pJson["quantity"], "qint32", "");
setValue(&shipDate, pJson["shipDate"], "QDateTime", "QDateTime"); setValue(&shipDate, pJson["shipDate"], "QDateTime", "QDateTime");
setValue(&status, pJson["status"], "QString", "QString"); setValue(&status, pJson["status"], "QString", "QString");
setValue(&complete, pJson["complete"], "bool", ""); setValue(&complete, pJson["complete"], "bool", "");
} }
QString QString
@ -84,22 +81,19 @@ QJsonObject*
SWGOrder::asJsonObject() { SWGOrder::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
obj->insert("petId", QJsonValue(petId)); obj->insert("petId", QJsonValue(petId));
obj->insert("quantity", QJsonValue(quantity)); obj->insert("quantity", QJsonValue(quantity));
toJsonValue(QString("shipDate"), shipDate, obj, QString("QDateTime")); toJsonValue(QString("shipDate"), shipDate, obj, QString("QDateTime"));
toJsonValue(QString("status"), status, obj, QString("QString")); toJsonValue(QString("status"), status, obj, QString("QString"));
obj->insert("complete", QJsonValue(complete));
obj->insert("complete", QJsonValue(complete));
return obj; return obj;
} }

View File

@ -33,26 +33,24 @@ public:
qint64 getId(); qint64 getId();
void setId(qint64 id); void setId(qint64 id);
qint64 getPetId(); qint64 getPetId();
void setPetId(qint64 petId); void setPetId(qint64 petId);
qint32 getQuantity(); qint32 getQuantity();
void setQuantity(qint32 quantity); void setQuantity(qint32 quantity);
QDateTime* getShipDate(); QDateTime* getShipDate();
void setShipDate(QDateTime* shipDate); void setShipDate(QDateTime* shipDate);
QString* getStatus(); QString* getStatus();
void setStatus(QString* status); void setStatus(QString* status);
bool getComplete(); bool getComplete();
void setComplete(bool complete); void setComplete(bool complete);
private: private:
qint64 id; qint64 id;
qint64 petId; qint64 petId;
qint32 quantity; qint32 quantity;
QDateTime* shipDate; QDateTime* shipDate;
QString* status; QString* status;
bool complete; bool complete;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -27,41 +27,39 @@ SWGPet::~SWGPet() {
void void
SWGPet::init() { SWGPet::init() {
id = 0L; id = 0L;
category = new SWGCategory(); category = new SWGCategory();
name = new QString(""); name = new QString("");
photoUrls = new QList<QString*>(); photoUrls = new QList<QString*>();
tags = new QList<SWGTag*>(); tags = new QList<SWGTag*>();
status = new QString(""); status = new QString("");
} }
void void
SWGPet::cleanup() { SWGPet::cleanup() {
if(category != NULL) { if(category != NULL) {
delete category; delete category;
} }
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
if(photoUrls != NULL) { if(photoUrls != NULL) {
QList<QString*>* arr = photoUrls; QList<QString*>* arr = photoUrls;
foreach(QString* o, *arr) { foreach(QString* o, *arr) {
delete o; delete o;
} }
delete photoUrls; delete photoUrls;
} }
if(tags != NULL) { if(tags != NULL) {
QList<SWGTag*>* arr = tags; QList<SWGTag*>* arr = tags;
foreach(SWGTag* o, *arr) { foreach(SWGTag* o, *arr) {
delete o; delete o;
} }
delete tags; delete tags;
} }
if(status != NULL) { if(status != NULL) {
delete status; delete status;
} }
} }
SWGPet* SWGPet*
@ -76,12 +74,11 @@ SWGPet::fromJson(QString &json) {
void void
SWGPet::fromJsonObject(QJsonObject &pJson) { SWGPet::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&category, pJson["category"], "SWGCategory", "SWGCategory"); setValue(&category, pJson["category"], "SWGCategory", "SWGCategory");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
setValue(&photoUrls, pJson["photoUrls"], "QList", "QString"); setValue(&photoUrls, pJson["photoUrls"], "QList", "QString");
setValue(&tags, pJson["tags"], "QList", "SWGTag"); setValue(&tags, pJson["tags"], "QList", "SWGTag");
setValue(&status, pJson["status"], "QString", "QString"); setValue(&status, pJson["status"], "QString", "QString");
} }
QString QString
@ -98,19 +95,17 @@ QJsonObject*
SWGPet::asJsonObject() { SWGPet::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
toJsonValue(QString("category"), category, obj, QString("SWGCategory")); toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
toJsonValue(QString("name"), name, obj, QString("QString")); toJsonValue(QString("name"), name, obj, QString("QString"));
QList<QString*>* photoUrlsList = photoUrls; QList<QString*>* photoUrlsList = photoUrls;
QJsonArray photoUrlsJsonArray; QJsonArray photoUrlsJsonArray;
@ -118,8 +113,7 @@ SWGPet::asJsonObject() {
obj->insert("photoUrls", photoUrlsJsonArray); obj->insert("photoUrls", photoUrlsJsonArray);
QList<SWGTag*>* tagsList = tags; QList<SWGTag*>* tagsList = tags;
QJsonArray tagsJsonArray; QJsonArray tagsJsonArray;
@ -127,14 +121,11 @@ SWGPet::asJsonObject() {
obj->insert("tags", tagsJsonArray); obj->insert("tags", tagsJsonArray);
toJsonValue(QString("status"), status, obj, QString("QString")); toJsonValue(QString("status"), status, obj, QString("QString"));
return obj; return obj;
} }

View File

@ -35,26 +35,24 @@ public:
qint64 getId(); qint64 getId();
void setId(qint64 id); void setId(qint64 id);
SWGCategory* getCategory(); SWGCategory* getCategory();
void setCategory(SWGCategory* category); void setCategory(SWGCategory* category);
QString* getName(); QString* getName();
void setName(QString* name); void setName(QString* name);
QList<QString*>* getPhotoUrls(); QList<QString*>* getPhotoUrls();
void setPhotoUrls(QList<QString*>* photoUrls); void setPhotoUrls(QList<QString*>* photoUrls);
QList<SWGTag*>* getTags(); QList<SWGTag*>* getTags();
void setTags(QList<SWGTag*>* tags); void setTags(QList<SWGTag*>* tags);
QString* getStatus(); QString* getStatus();
void setStatus(QString* status); void setStatus(QString* status);
private: private:
qint64 id; qint64 id;
SWGCategory* category; SWGCategory* category;
QString* name; QString* name;
QList<QString*>* photoUrls; QList<QString*>* photoUrls;
QList<SWGTag*>* tags; QList<SWGTag*>* tags;
QString* status; QString* status;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -15,76 +15,21 @@ SWGPetApi::SWGPetApi(QString host, QString basePath) {
this->basePath = 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 void
SWGPetApi::addPet(SWGPet body) { SWGPetApi::addPet(SWGPet body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet"); fullPath.append(this->host).append(this->basePath).append("/pet");
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
QString output = body.asJson(); QString output = body.asJson();
input.request_body.append(output); input.request_body.append(output);
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -112,19 +57,57 @@ SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
emit addPetSignal(); emit addPetSignal();
} }
void void
SWGPetApi::deletePet(qint64 petId, QString* apiKey) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE");
// TODO: add header support
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::deletePetCallback);
worker->execute(&input);
}
void
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
worker->deleteLater();
emit deletePetSignal();
}
void
SWGPetApi::findPetsByStatus(QList<QString*>* status) { SWGPetApi::findPetsByStatus(QList<QString*>* status) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus");
if (status->size() > 0) { if (status->size() > 0) {
if (QString("multi").indexOf("multi") == 0) { if (QString("csv").indexOf("multi") == 0) {
foreach(QString* t, *status) { foreach(QString* t, *status) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
@ -133,7 +116,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
fullPath.append("status=").append(stringValue(t)); fullPath.append("status=").append(stringValue(t));
} }
} }
else if (QString("multi").indexOf("ssv") == 0) { else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -147,7 +130,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
fullPath.append(stringValue(t)); fullPath.append(stringValue(t));
} }
} }
else if (QString("multi").indexOf("tsv") == 0) { else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -163,17 +146,13 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
} }
} }
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -207,7 +186,6 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
o->fromJsonObject(*ptr); o->fromJsonObject(*ptr);
output->append(o); output->append(o);
} }
@ -221,15 +199,11 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); fullPath.append(this->host).append(this->basePath).append("/pet/findByTags");
if (tags->size() > 0) { if (tags->size() > 0) {
if (QString("multi").indexOf("multi") == 0) { if (QString("csv").indexOf("multi") == 0) {
foreach(QString* t, *tags) { foreach(QString* t, *tags) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
@ -238,7 +212,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
fullPath.append("tags=").append(stringValue(t)); fullPath.append("tags=").append(stringValue(t));
} }
} }
else if (QString("multi").indexOf("ssv") == 0) { else if (QString("csv").indexOf("ssv") == 0) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -252,7 +226,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
fullPath.append(stringValue(t)); fullPath.append(stringValue(t));
} }
} }
else if (QString("multi").indexOf("tsv") == 0) { else if (QString("csv").indexOf("tsv") == 0) {
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -268,17 +242,13 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
} }
} }
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -312,7 +282,6 @@ SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
o->fromJsonObject(*ptr); o->fromJsonObject(*ptr);
output->append(o); output->append(o);
} }
@ -326,21 +295,16 @@ SWGPetApi::getPetById(qint64 petId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId)); fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -361,15 +325,9 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
} }
QString json(worker->response);
QString json(worker->response);
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet"))); SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
worker->deleteLater(); worker->deleteLater();
@ -377,16 +335,54 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
} }
void 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; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId)); fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
@ -394,14 +390,12 @@ SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
if (name != NULL) { if (name != NULL) {
input.add_var("name", *name); input.add_var("name", *name);
} }
if (status != NULL) { if (status != NULL) {
input.add_var("status", *status); input.add_var("status", *status);
} }
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -429,64 +423,13 @@ SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
emit updatePetWithFormSignal(); emit updatePetWithFormSignal();
} }
void 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) { SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId)); fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
@ -494,14 +437,12 @@ SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestI
if (additionalMetadata != NULL) { if (additionalMetadata != NULL) {
input.add_var("additionalMetadata", *additionalMetadata); input.add_var("additionalMetadata", *additionalMetadata);
} }
if (file != NULL) { if (file != NULL) {
input.add_file("file", *file.local_filename, *file.request_filename, *file.mime_type); input.add_file("file", *file.local_filename, *file.request_filename, *file.mime_type);
} }
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -522,113 +463,13 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
} }
QString json(worker->response);
worker->deleteLater(); SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
emit uploadFileSignal();
}
void
SWGPetApi::getPetByIdWithByteArray(qint64 petId) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}?testing_byte_array=true");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::getPetByIdWithByteArrayCallback);
worker->execute(&input);
}
void
SWGPetApi::getPetByIdWithByteArrayCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
QString* output = static_cast<QString*>(create(json, QString("QString")));
worker->deleteLater(); 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 */ } /* namespace Swagger */

View File

@ -5,6 +5,7 @@
#include "SWGPet.h" #include "SWGPet.h"
#include <QString> #include <QString>
#include "SWGApiResponse.h"
#include "SWGHttpRequest.h" #include "SWGHttpRequest.h"
#include <QObject> #include <QObject>
@ -22,40 +23,34 @@ public:
QString host; QString host;
QString basePath; QString basePath;
void updatePet(SWGPet body);
void addPet(SWGPet body); void addPet(SWGPet body);
void deletePet(qint64 petId, QString* apiKey);
void findPetsByStatus(QList<QString*>* status); void findPetsByStatus(QList<QString*>* status);
void findPetsByTags(QList<QString*>* tags); void findPetsByTags(QList<QString*>* tags);
void getPetById(qint64 petId); void getPetById(qint64 petId);
void updatePetWithForm(QString* petId, QString* name, QString* status); void updatePet(SWGPet body);
void deletePet(qint64 petId, QString* apiKey); void updatePetWithForm(qint64 petId, QString* name, QString* status);
void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file); void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file);
void getPetByIdWithByteArray(qint64 petId);
void addPetUsingByteArray(QString* body);
private: private:
void updatePetCallback (HttpRequestWorker * worker);
void addPetCallback (HttpRequestWorker * worker); void addPetCallback (HttpRequestWorker * worker);
void deletePetCallback (HttpRequestWorker * worker);
void findPetsByStatusCallback (HttpRequestWorker * worker); void findPetsByStatusCallback (HttpRequestWorker * worker);
void findPetsByTagsCallback (HttpRequestWorker * worker); void findPetsByTagsCallback (HttpRequestWorker * worker);
void getPetByIdCallback (HttpRequestWorker * worker); void getPetByIdCallback (HttpRequestWorker * worker);
void updatePetCallback (HttpRequestWorker * worker);
void updatePetWithFormCallback (HttpRequestWorker * worker); void updatePetWithFormCallback (HttpRequestWorker * worker);
void deletePetCallback (HttpRequestWorker * worker);
void uploadFileCallback (HttpRequestWorker * worker); void uploadFileCallback (HttpRequestWorker * worker);
void getPetByIdWithByteArrayCallback (HttpRequestWorker * worker);
void addPetUsingByteArrayCallback (HttpRequestWorker * worker);
signals: signals:
void updatePetSignal();
void addPetSignal(); void addPetSignal();
void deletePetSignal();
void findPetsByStatusSignal(QList<SWGPet*>* summary); void findPetsByStatusSignal(QList<SWGPet*>* summary);
void findPetsByTagsSignal(QList<SWGPet*>* summary); void findPetsByTagsSignal(QList<SWGPet*>* summary);
void getPetByIdSignal(SWGPet* summary); void getPetByIdSignal(SWGPet* summary);
void updatePetSignal();
void updatePetWithFormSignal(); void updatePetWithFormSignal();
void deletePetSignal(); void uploadFileSignal(SWGApiResponse* summary);
void uploadFileSignal();
void getPetByIdWithByteArraySignal(QString* summary);
void addPetUsingByteArraySignal();
}; };
} }

View File

@ -15,201 +15,21 @@ SWGStoreApi::SWGStoreApi(QString host, QString basePath) {
this->basePath = basePath; this->basePath = basePath;
} }
void
SWGStoreApi::getInventory() {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/inventory");
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getInventoryCallback);
worker->execute(&input);
}
void
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QMap<QString, qint32>* output = new QMap<QString, qint32>();
QString json(worker->response);
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject obj = doc.object();
foreach(QString key, obj.keys()) {
qint32* val;
setValue(&val, obj[key], "QMap", "");
output->insert(key, *val);
}
worker->deleteLater();
emit getInventorySignal(output);
}
void
SWGStoreApi::placeOrder(SWGOrder body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order");
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::placeOrderCallback);
worker->execute(&input);
}
void
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();
emit placeOrderSignal(output);
}
void
SWGStoreApi::getOrderById(QString* orderId) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
fullPath.replace(orderIdPathParam, stringValue(orderId));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getOrderByIdCallback);
worker->execute(&input);
}
void
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();
emit getOrderByIdSignal(output);
}
void void
SWGStoreApi::deleteOrder(QString* orderId) { SWGStoreApi::deleteOrder(QString* orderId) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
fullPath.replace(orderIdPathParam, stringValue(orderId)); fullPath.replace(orderIdPathParam, stringValue(orderId));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE"); HttpRequestInput input(fullPath, "DELETE");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -236,4 +56,146 @@ SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
emit deleteOrderSignal(); emit deleteOrderSignal();
} }
void
SWGStoreApi::getInventory() {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/inventory");
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getInventoryCallback);
worker->execute(&input);
}
void
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QMap<QString, qint32>* output = new QMap<QString, qint32>();
QString json(worker->response);
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject obj = doc.object();
foreach(QString key, obj.keys()) {
qint32* val;
setValue(&val, obj[key], "QMap", "");
output->insert(key, *val);
}
worker->deleteLater();
emit getInventorySignal(output);
}
void
SWGStoreApi::getOrderById(qint64 orderId) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");
QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}");
fullPath.replace(orderIdPathParam, stringValue(orderId));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getOrderByIdCallback);
worker->execute(&input);
}
void
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();
emit getOrderByIdSignal(output);
}
void
SWGStoreApi::placeOrder(SWGOrder body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order");
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::placeOrderCallback);
worker->execute(&input);
}
void
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();
emit placeOrderSignal(output);
}
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -3,9 +3,9 @@
#include "SWGHttpRequest.h" #include "SWGHttpRequest.h"
#include <QString>
#include "QMap.h" #include "QMap.h"
#include "SWGOrder.h" #include "SWGOrder.h"
#include <QString>
#include <QObject> #include <QObject>
@ -22,22 +22,22 @@ public:
QString host; QString host;
QString basePath; QString basePath;
void getInventory();
void placeOrder(SWGOrder body);
void getOrderById(QString* orderId);
void deleteOrder(QString* orderId); void deleteOrder(QString* orderId);
void getInventory();
void getOrderById(qint64 orderId);
void placeOrder(SWGOrder body);
private: private:
void getInventoryCallback (HttpRequestWorker * worker);
void placeOrderCallback (HttpRequestWorker * worker);
void getOrderByIdCallback (HttpRequestWorker * worker);
void deleteOrderCallback (HttpRequestWorker * worker); void deleteOrderCallback (HttpRequestWorker * worker);
void getInventoryCallback (HttpRequestWorker * worker);
void getOrderByIdCallback (HttpRequestWorker * worker);
void placeOrderCallback (HttpRequestWorker * worker);
signals: signals:
void getInventorySignal(QMap<QString, qint32>* summary);
void placeOrderSignal(SWGOrder* summary);
void getOrderByIdSignal(SWGOrder* summary);
void deleteOrderSignal(); void deleteOrderSignal();
void getInventorySignal(QMap<QString, qint32>* summary);
void getOrderByIdSignal(SWGOrder* summary);
void placeOrderSignal(SWGOrder* summary);
}; };
} }

View File

@ -27,17 +27,15 @@ SWGTag::~SWGTag() {
void void
SWGTag::init() { SWGTag::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
SWGTag::cleanup() { SWGTag::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGTag* SWGTag*
@ -52,8 +50,7 @@ SWGTag::fromJson(QString &json) {
void void
SWGTag::fromJsonObject(QJsonObject &pJson) { SWGTag::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&name, pJson["name"], "QString", "QString"); setValue(&name, pJson["name"], "QString", "QString");
} }
QString QString
@ -70,13 +67,11 @@ QJsonObject*
SWGTag::asJsonObject() { SWGTag::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
toJsonValue(QString("name"), name, obj, QString("QString")); toJsonValue(QString("name"), name, obj, QString("QString"));
return obj; return obj;
} }

View File

@ -32,14 +32,12 @@ public:
qint64 getId(); qint64 getId();
void setId(qint64 id); void setId(qint64 id);
QString* getName(); QString* getName();
void setName(QString* name); void setName(QString* name);
private: private:
qint64 id; qint64 id;
QString* name; QString* name;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -27,39 +27,37 @@ SWGUser::~SWGUser() {
void void
SWGUser::init() { SWGUser::init() {
id = 0L; id = 0L;
username = new QString(""); username = new QString("");
firstName = new QString(""); firstName = new QString("");
lastName = new QString(""); lastName = new QString("");
email = new QString(""); email = new QString("");
password = new QString(""); password = new QString("");
phone = new QString(""); phone = new QString("");
userStatus = 0; userStatus = 0;
} }
void void
SWGUser::cleanup() { SWGUser::cleanup() {
if(username != NULL) { if(username != NULL) {
delete username; delete username;
} }
if(firstName != NULL) { if(firstName != NULL) {
delete firstName; delete firstName;
} }
if(lastName != NULL) { if(lastName != NULL) {
delete lastName; delete lastName;
} }
if(email != NULL) { if(email != NULL) {
delete email; delete email;
} }
if(password != NULL) { if(password != NULL) {
delete password; delete password;
} }
if(phone != NULL) { if(phone != NULL) {
delete phone; delete phone;
} }
} }
SWGUser* SWGUser*
@ -74,14 +72,13 @@ SWGUser::fromJson(QString &json) {
void void
SWGUser::fromJsonObject(QJsonObject &pJson) { SWGUser::fromJsonObject(QJsonObject &pJson) {
setValue(&id, pJson["id"], "qint64", ""); setValue(&id, pJson["id"], "qint64", "");
setValue(&username, pJson["username"], "QString", "QString"); setValue(&username, pJson["username"], "QString", "QString");
setValue(&firstName, pJson["firstName"], "QString", "QString"); setValue(&firstName, pJson["firstName"], "QString", "QString");
setValue(&lastName, pJson["lastName"], "QString", "QString"); setValue(&lastName, pJson["lastName"], "QString", "QString");
setValue(&email, pJson["email"], "QString", "QString"); setValue(&email, pJson["email"], "QString", "QString");
setValue(&password, pJson["password"], "QString", "QString"); setValue(&password, pJson["password"], "QString", "QString");
setValue(&phone, pJson["phone"], "QString", "QString"); setValue(&phone, pJson["phone"], "QString", "QString");
setValue(&userStatus, pJson["userStatus"], "qint32", ""); setValue(&userStatus, pJson["userStatus"], "qint32", "");
} }
QString QString
@ -98,44 +95,37 @@ QJsonObject*
SWGUser::asJsonObject() { SWGUser::asJsonObject() {
QJsonObject* obj = new QJsonObject(); QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id)); obj->insert("id", QJsonValue(id));
toJsonValue(QString("username"), username, obj, QString("QString")); toJsonValue(QString("username"), username, obj, QString("QString"));
toJsonValue(QString("firstName"), firstName, obj, QString("QString")); toJsonValue(QString("firstName"), firstName, obj, QString("QString"));
toJsonValue(QString("lastName"), lastName, obj, QString("QString")); toJsonValue(QString("lastName"), lastName, obj, QString("QString"));
toJsonValue(QString("email"), email, obj, QString("QString")); toJsonValue(QString("email"), email, obj, QString("QString"));
toJsonValue(QString("password"), password, obj, QString("QString")); toJsonValue(QString("password"), password, obj, QString("QString"));
toJsonValue(QString("phone"), phone, obj, QString("QString")); toJsonValue(QString("phone"), phone, obj, QString("QString"));
obj->insert("userStatus", QJsonValue(userStatus));
obj->insert("userStatus", QJsonValue(userStatus));
return obj; return obj;
} }

View File

@ -32,32 +32,30 @@ public:
qint64 getId(); qint64 getId();
void setId(qint64 id); void setId(qint64 id);
QString* getUsername(); QString* getUsername();
void setUsername(QString* username); void setUsername(QString* username);
QString* getFirstName(); QString* getFirstName();
void setFirstName(QString* firstName); void setFirstName(QString* firstName);
QString* getLastName(); QString* getLastName();
void setLastName(QString* lastName); void setLastName(QString* lastName);
QString* getEmail(); QString* getEmail();
void setEmail(QString* email); void setEmail(QString* email);
QString* getPassword(); QString* getPassword();
void setPassword(QString* password); void setPassword(QString* password);
QString* getPhone(); QString* getPhone();
void setPhone(QString* phone); void setPhone(QString* phone);
qint32 getUserStatus(); qint32 getUserStatus();
void setUserStatus(qint32 userStatus); void setUserStatus(qint32 userStatus);
private: private:
qint64 id; qint64 id;
QString* username; QString* username;
QString* firstName; QString* firstName;
QString* lastName; QString* lastName;
QString* email; QString* email;
QString* password; QString* password;
QString* phone; QString* phone;
qint32 userStatus; qint32 userStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -20,23 +20,16 @@ SWGUserApi::createUser(SWGUser body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user"); fullPath.append(this->host).append(this->basePath).append("/user");
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
QString output = body.asJson(); QString output = body.asJson();
input.request_body.append(output); input.request_body.append(output);
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -68,17 +61,12 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); fullPath.append(this->host).append(this->basePath).append("/user/createWithArray");
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
QJsonArray* bodyArray = new QJsonArray(); QJsonArray* bodyArray = new QJsonArray();
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*")); toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
@ -86,10 +74,8 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
input.request_body.append(bytes); input.request_body.append(bytes);
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -121,17 +107,12 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); fullPath.append(this->host).append(this->basePath).append("/user/createWithList");
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST"); HttpRequestInput input(fullPath, "POST");
QJsonArray* bodyArray = new QJsonArray(); QJsonArray* bodyArray = new QJsonArray();
toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*")); toJsonArray((QList<void*>*)body, bodyArray, QString("body"), QString("SWGUser*"));
@ -139,10 +120,8 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
QByteArray bytes = doc.toJson(); QByteArray bytes = doc.toJson();
input.request_body.append(bytes); input.request_body.append(bytes);
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -170,14 +149,96 @@ SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
emit createUsersWithListInputSignal(); emit createUsersWithListInputSignal();
} }
void void
SWGUserApi::deleteUser(QString* username) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::deleteUserCallback);
worker->execute(&input);
}
void
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
worker->deleteLater();
emit deleteUserSignal();
}
void
SWGUserApi::getUserByName(QString* username) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::getUserByNameCallback);
worker->execute(&input);
}
void
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
worker->deleteLater();
emit getUserByNameSignal(output);
}
void
SWGUserApi::loginUser(QString* username, QString* password) { SWGUserApi::loginUser(QString* username, QString* password) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/login"); fullPath.append(this->host).append(this->basePath).append("/user/login");
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -185,11 +246,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
fullPath.append(QUrl::toPercentEncoding("username")) fullPath.append(QUrl::toPercentEncoding("username"))
.append("=") .append("=")
.append(QUrl::toPercentEncoding(stringValue(username))); .append(QUrl::toPercentEncoding(stringValue(username)));
if (fullPath.indexOf("?") > 0) if (fullPath.indexOf("?") > 0)
fullPath.append("&"); fullPath.append("&");
else else
@ -197,19 +254,14 @@ SWGUserApi::loginUser(QString* username, QString* password) {
fullPath.append(QUrl::toPercentEncoding("password")) fullPath.append(QUrl::toPercentEncoding("password"))
.append("=") .append("=")
.append(QUrl::toPercentEncoding(stringValue(password))); .append(QUrl::toPercentEncoding(stringValue(password)));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -230,15 +282,9 @@ SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
} }
QString json(worker->response);
QString json(worker->response);
QString* output = static_cast<QString*>(create(json, QString("QString"))); QString* output = static_cast<QString*>(create(json, QString("QString")));
worker->deleteLater(); worker->deleteLater();
@ -250,18 +296,14 @@ SWGUserApi::logoutUser() {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/logout"); fullPath.append(this->host).append(this->basePath).append("/user/logout");
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -289,85 +331,22 @@ SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
emit logoutUserSignal(); emit logoutUserSignal();
} }
void void
SWGUserApi::getUserByName(QString* username) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}");
QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::getUserByNameCallback);
worker->execute(&input);
}
void
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response);
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
worker->deleteLater();
emit getUserByNameSignal(output);
}
void
SWGUserApi::updateUser(QString* username, SWGUser body) { SWGUserApi::updateUser(QString* username, SWGUser body) {
QString fullPath; QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/user/{username}"); fullPath.append(this->host).append(this->basePath).append("/user/{username}");
QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); QString usernamePathParam("{"); usernamePathParam.append("username").append("}");
fullPath.replace(usernamePathParam, stringValue(username)); fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "PUT"); HttpRequestInput input(fullPath, "PUT");
QString output = body.asJson(); QString output = body.asJson();
input.request_body.append(output); input.request_body.append(output);
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
@ -394,50 +373,4 @@ SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
emit updateUserSignal(); 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 */ } /* namespace Swagger */

View File

@ -25,31 +25,31 @@ public:
void createUser(SWGUser body); void createUser(SWGUser body);
void createUsersWithArrayInput(QList<SWGUser*>* body); void createUsersWithArrayInput(QList<SWGUser*>* body);
void createUsersWithListInput(QList<SWGUser*>* body); void createUsersWithListInput(QList<SWGUser*>* body);
void deleteUser(QString* username);
void getUserByName(QString* username);
void loginUser(QString* username, QString* password); void loginUser(QString* username, QString* password);
void logoutUser(); void logoutUser();
void getUserByName(QString* username);
void updateUser(QString* username, SWGUser body); void updateUser(QString* username, SWGUser body);
void deleteUser(QString* username);
private: private:
void createUserCallback (HttpRequestWorker * worker); void createUserCallback (HttpRequestWorker * worker);
void createUsersWithArrayInputCallback (HttpRequestWorker * worker); void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
void createUsersWithListInputCallback (HttpRequestWorker * worker); void createUsersWithListInputCallback (HttpRequestWorker * worker);
void deleteUserCallback (HttpRequestWorker * worker);
void getUserByNameCallback (HttpRequestWorker * worker);
void loginUserCallback (HttpRequestWorker * worker); void loginUserCallback (HttpRequestWorker * worker);
void logoutUserCallback (HttpRequestWorker * worker); void logoutUserCallback (HttpRequestWorker * worker);
void getUserByNameCallback (HttpRequestWorker * worker);
void updateUserCallback (HttpRequestWorker * worker); void updateUserCallback (HttpRequestWorker * worker);
void deleteUserCallback (HttpRequestWorker * worker);
signals: signals:
void createUserSignal(); void createUserSignal();
void createUsersWithArrayInputSignal(); void createUsersWithArrayInputSignal();
void createUsersWithListInputSignal(); void createUsersWithListInputSignal();
void deleteUserSignal();
void getUserByNameSignal(SWGUser* summary);
void loginUserSignal(QString* summary); void loginUserSignal(QString* summary);
void logoutUserSignal(); void logoutUserSignal();
void getUserByNameSignal(SWGUser* summary);
void updateUserSignal(); void updateUserSignal();
void deleteUserSignal();
}; };
} }

View File

@ -23,8 +23,7 @@ SamiCategory::~SamiCategory() {
void void
SamiCategory::init() { SamiCategory::init() {
pId = null; pId = null;
pName = null; pName = null;
} }
void void
@ -34,12 +33,11 @@ SamiCategory::cleanup() {
delete pId; delete pId;
pId = null; pId = null;
} }
if(pName != null) { if(pName != null) {
delete pName; delete pName;
pName = null; pName = null;
} }
} }
@ -86,7 +84,7 @@ SamiCategory::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pId, pIdVal, L"Long", L"Long"); jsonToValue(pId, pIdVal, L"Long", L"Long");
} }
delete pIdKey; delete pIdKey;
JsonString* pNameKey = new JsonString(L"name"); JsonString* pNameKey = new JsonString(L"name");
IJsonValue* pNameVal = null; IJsonValue* pNameVal = null;
pJsonObject->GetValue(pNameKey, pNameVal); pJsonObject->GetValue(pNameKey, pNameVal);
if(pNameVal != null) { if(pNameVal != null) {
@ -95,7 +93,6 @@ SamiCategory::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pName, pNameVal, L"String", L"String"); jsonToValue(pName, pNameVal, L"String", L"String");
} }
delete pNameKey; delete pNameKey;
} }
} }
@ -146,15 +143,12 @@ SamiCategory::asJsonObject() {
JsonObject *pJsonObject = new JsonObject(); JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct(); pJsonObject->Construct();
JsonString *pIdKey = new JsonString(L"id"); JsonString *pIdKey = new JsonString(L"id");
pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", ""));
JsonString *pNameKey = new JsonString(L"name"); JsonString *pNameKey = new JsonString(L"name");
pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); pJsonObject->Add(pNameKey, toJson(getPName(), "String", ""));
return pJsonObject; return pJsonObject;
} }

View File

@ -41,18 +41,14 @@ public:
SamiCategory* fromJson(String* obj); SamiCategory* fromJson(String* obj);
Long* getPId(); Long* getPId();
void setPId(Long* pId); void setPId(Long* pId);
String* getPName(); String* getPName();
void setPName(String* pName); void setPName(String* pName);
private: private:
Long* pId; Long* pId;
String* pName; String* pName;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -3,29 +3,33 @@
#include "SamiObject.h" #include "SamiObject.h"
#include "SamiUser.h" #include "SamiApiResponse.h"
#include "SamiCategory.h" #include "SamiCategory.h"
#include "SamiOrder.h"
#include "SamiPet.h" #include "SamiPet.h"
#include "SamiTag.h" #include "SamiTag.h"
#include "SamiOrder.h" #include "SamiUser.h"
namespace Swagger { namespace Swagger {
void* void*
create(String type) { create(String type) {
if(type.Equals(L"SamiUser", true)) { if(type.Equals(L"SamiApiResponse", true)) {
return new SamiUser(); return new SamiApiResponse();
} }
if(type.Equals(L"SamiCategory", true)) { if(type.Equals(L"SamiCategory", true)) {
return new SamiCategory(); return new SamiCategory();
} }
if(type.Equals(L"SamiOrder", true)) {
return new SamiOrder();
}
if(type.Equals(L"SamiPet", true)) { if(type.Equals(L"SamiPet", true)) {
return new SamiPet(); return new SamiPet();
} }
if(type.Equals(L"SamiTag", true)) { if(type.Equals(L"SamiTag", true)) {
return new SamiTag(); return new SamiTag();
} }
if(type.Equals(L"SamiOrder", true)) { if(type.Equals(L"SamiUser", true)) {
return new SamiOrder(); return new SamiUser();
} }
if(type.Equals(L"String", true)) { if(type.Equals(L"String", true)) {

View File

@ -23,12 +23,11 @@ SamiOrder::~SamiOrder() {
void void
SamiOrder::init() { SamiOrder::init() {
pId = null; pId = null;
pPetId = null; pPetId = null;
pQuantity = null; pQuantity = null;
pShipDate = null; pShipDate = null;
pStatus = null; pStatus = null;
pComplete = null; pComplete = null;
} }
void void
@ -38,32 +37,31 @@ SamiOrder::cleanup() {
delete pId; delete pId;
pId = null; pId = null;
} }
if(pPetId != null) { if(pPetId != null) {
delete pPetId; delete pPetId;
pPetId = null; pPetId = null;
} }
if(pQuantity != null) { if(pQuantity != null) {
delete pQuantity; delete pQuantity;
pQuantity = null; pQuantity = null;
} }
if(pShipDate != null) { if(pShipDate != null) {
delete pShipDate; delete pShipDate;
pShipDate = null; pShipDate = null;
} }
if(pStatus != null) { if(pStatus != null) {
delete pStatus; delete pStatus;
pStatus = null; pStatus = null;
} }
if(pComplete != null) { if(pComplete != null) {
delete pComplete; delete pComplete;
pComplete = null; pComplete = null;
} }
} }
@ -110,7 +108,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pId, pIdVal, L"Long", L"Long"); jsonToValue(pId, pIdVal, L"Long", L"Long");
} }
delete pIdKey; delete pIdKey;
JsonString* pPetIdKey = new JsonString(L"petId"); JsonString* pPetIdKey = new JsonString(L"petId");
IJsonValue* pPetIdVal = null; IJsonValue* pPetIdVal = null;
pJsonObject->GetValue(pPetIdKey, pPetIdVal); pJsonObject->GetValue(pPetIdKey, pPetIdVal);
if(pPetIdVal != null) { if(pPetIdVal != null) {
@ -119,7 +117,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pPetId, pPetIdVal, L"Long", L"Long"); jsonToValue(pPetId, pPetIdVal, L"Long", L"Long");
} }
delete pPetIdKey; delete pPetIdKey;
JsonString* pQuantityKey = new JsonString(L"quantity"); JsonString* pQuantityKey = new JsonString(L"quantity");
IJsonValue* pQuantityVal = null; IJsonValue* pQuantityVal = null;
pJsonObject->GetValue(pQuantityKey, pQuantityVal); pJsonObject->GetValue(pQuantityKey, pQuantityVal);
if(pQuantityVal != null) { if(pQuantityVal != null) {
@ -128,7 +126,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pQuantity, pQuantityVal, L"Integer", L"Integer"); jsonToValue(pQuantity, pQuantityVal, L"Integer", L"Integer");
} }
delete pQuantityKey; delete pQuantityKey;
JsonString* pShipDateKey = new JsonString(L"shipDate"); JsonString* pShipDateKey = new JsonString(L"shipDate");
IJsonValue* pShipDateVal = null; IJsonValue* pShipDateVal = null;
pJsonObject->GetValue(pShipDateKey, pShipDateVal); pJsonObject->GetValue(pShipDateKey, pShipDateVal);
if(pShipDateVal != null) { if(pShipDateVal != null) {
@ -137,7 +135,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pShipDate, pShipDateVal, L"DateTime", L"DateTime"); jsonToValue(pShipDate, pShipDateVal, L"DateTime", L"DateTime");
} }
delete pShipDateKey; delete pShipDateKey;
JsonString* pStatusKey = new JsonString(L"status"); JsonString* pStatusKey = new JsonString(L"status");
IJsonValue* pStatusVal = null; IJsonValue* pStatusVal = null;
pJsonObject->GetValue(pStatusKey, pStatusVal); pJsonObject->GetValue(pStatusKey, pStatusVal);
if(pStatusVal != null) { if(pStatusVal != null) {
@ -146,7 +144,7 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pStatus, pStatusVal, L"String", L"String"); jsonToValue(pStatus, pStatusVal, L"String", L"String");
} }
delete pStatusKey; delete pStatusKey;
JsonString* pCompleteKey = new JsonString(L"complete"); JsonString* pCompleteKey = new JsonString(L"complete");
IJsonValue* pCompleteVal = null; IJsonValue* pCompleteVal = null;
pJsonObject->GetValue(pCompleteKey, pCompleteVal); pJsonObject->GetValue(pCompleteKey, pCompleteVal);
if(pCompleteVal != null) { if(pCompleteVal != null) {
@ -155,7 +153,6 @@ SamiOrder::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pComplete, pCompleteVal, L"Boolean", L"Boolean"); jsonToValue(pComplete, pCompleteVal, L"Boolean", L"Boolean");
} }
delete pCompleteKey; delete pCompleteKey;
} }
} }
@ -206,31 +203,24 @@ SamiOrder::asJsonObject() {
JsonObject *pJsonObject = new JsonObject(); JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct(); pJsonObject->Construct();
JsonString *pIdKey = new JsonString(L"id"); JsonString *pIdKey = new JsonString(L"id");
pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", ""));
JsonString *pPetIdKey = new JsonString(L"petId"); JsonString *pPetIdKey = new JsonString(L"petId");
pJsonObject->Add(pPetIdKey, toJson(getPPetId(), "Long", "")); pJsonObject->Add(pPetIdKey, toJson(getPPetId(), "Long", ""));
JsonString *pQuantityKey = new JsonString(L"quantity"); JsonString *pQuantityKey = new JsonString(L"quantity");
pJsonObject->Add(pQuantityKey, toJson(getPQuantity(), "Integer", "")); pJsonObject->Add(pQuantityKey, toJson(getPQuantity(), "Integer", ""));
JsonString *pShipDateKey = new JsonString(L"shipDate"); JsonString *pShipDateKey = new JsonString(L"shipDate");
pJsonObject->Add(pShipDateKey, toJson(getPShipDate(), "DateTime", "")); pJsonObject->Add(pShipDateKey, toJson(getPShipDate(), "DateTime", ""));
JsonString *pStatusKey = new JsonString(L"status"); JsonString *pStatusKey = new JsonString(L"status");
pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", ""));
JsonString *pCompleteKey = new JsonString(L"complete"); JsonString *pCompleteKey = new JsonString(L"complete");
pJsonObject->Add(pCompleteKey, toJson(getPComplete(), "Boolean", "")); pJsonObject->Add(pCompleteKey, toJson(getPComplete(), "Boolean", ""));
return pJsonObject; return pJsonObject;
} }

View File

@ -17,11 +17,11 @@
using namespace Tizen::Web::Json; using namespace Tizen::Web::Json;
using Tizen::Base::Long;
using Tizen::Base::DateTime;
using Tizen::Base::String;
using Tizen::Base::Boolean; using Tizen::Base::Boolean;
using Tizen::Base::DateTime;
using Tizen::Base::Integer; using Tizen::Base::Integer;
using Tizen::Base::Long;
using Tizen::Base::String;
namespace Swagger { namespace Swagger {
@ -44,34 +44,26 @@ public:
SamiOrder* fromJson(String* obj); SamiOrder* fromJson(String* obj);
Long* getPId(); Long* getPId();
void setPId(Long* pId); void setPId(Long* pId);
Long* getPPetId(); Long* getPPetId();
void setPPetId(Long* pPetId); void setPPetId(Long* pPetId);
Integer* getPQuantity(); Integer* getPQuantity();
void setPQuantity(Integer* pQuantity); void setPQuantity(Integer* pQuantity);
DateTime* getPShipDate(); DateTime* getPShipDate();
void setPShipDate(DateTime* pShipDate); void setPShipDate(DateTime* pShipDate);
String* getPStatus(); String* getPStatus();
void setPStatus(String* pStatus); void setPStatus(String* pStatus);
Boolean* getPComplete(); Boolean* getPComplete();
void setPComplete(Boolean* pComplete); void setPComplete(Boolean* pComplete);
private: private:
Long* pId; Long* pId;
Long* pPetId; Long* pPetId;
Integer* pQuantity; Integer* pQuantity;
DateTime* pShipDate; DateTime* pShipDate;
String* pStatus; String* pStatus;
Boolean* pComplete; Boolean* pComplete;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -23,12 +23,11 @@ SamiPet::~SamiPet() {
void void
SamiPet::init() { SamiPet::init() {
pId = null; pId = null;
pCategory = null; pCategory = null;
pName = null; pName = null;
pPhotoUrls = null; pPhotoUrls = null;
pTags = null; pTags = null;
pStatus = null; pStatus = null;
} }
void void
@ -38,32 +37,31 @@ SamiPet::cleanup() {
delete pId; delete pId;
pId = null; pId = null;
} }
if(pCategory != null) { if(pCategory != null) {
delete pCategory; delete pCategory;
pCategory = null; pCategory = null;
} }
if(pName != null) { if(pName != null) {
delete pName; delete pName;
pName = null; pName = null;
} }
if(pPhotoUrls != null) { if(pPhotoUrls != null) {
pPhotoUrls->RemoveAll(true); pPhotoUrls->RemoveAll(true);
delete pPhotoUrls; delete pPhotoUrls;
pPhotoUrls = null; pPhotoUrls = null;
} }
if(pTags != null) { if(pTags != null) {
pTags->RemoveAll(true); pTags->RemoveAll(true);
delete pTags; delete pTags;
pTags = null; pTags = null;
} }
if(pStatus != null) { if(pStatus != null) {
delete pStatus; delete pStatus;
pStatus = null; pStatus = null;
} }
} }
@ -110,7 +108,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pId, pIdVal, L"Long", L"Long"); jsonToValue(pId, pIdVal, L"Long", L"Long");
} }
delete pIdKey; delete pIdKey;
JsonString* pCategoryKey = new JsonString(L"category"); JsonString* pCategoryKey = new JsonString(L"category");
IJsonValue* pCategoryVal = null; IJsonValue* pCategoryVal = null;
pJsonObject->GetValue(pCategoryKey, pCategoryVal); pJsonObject->GetValue(pCategoryKey, pCategoryVal);
if(pCategoryVal != null) { if(pCategoryVal != null) {
@ -119,7 +117,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pCategory, pCategoryVal, L"SamiCategory", L"SamiCategory"); jsonToValue(pCategory, pCategoryVal, L"SamiCategory", L"SamiCategory");
} }
delete pCategoryKey; delete pCategoryKey;
JsonString* pNameKey = new JsonString(L"name"); JsonString* pNameKey = new JsonString(L"name");
IJsonValue* pNameVal = null; IJsonValue* pNameVal = null;
pJsonObject->GetValue(pNameKey, pNameVal); pJsonObject->GetValue(pNameKey, pNameVal);
if(pNameVal != null) { if(pNameVal != null) {
@ -128,7 +126,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pName, pNameVal, L"String", L"String"); jsonToValue(pName, pNameVal, L"String", L"String");
} }
delete pNameKey; delete pNameKey;
JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls"); JsonString* pPhotoUrlsKey = new JsonString(L"photoUrls");
IJsonValue* pPhotoUrlsVal = null; IJsonValue* pPhotoUrlsVal = null;
pJsonObject->GetValue(pPhotoUrlsKey, pPhotoUrlsVal); pJsonObject->GetValue(pPhotoUrlsKey, pPhotoUrlsVal);
if(pPhotoUrlsVal != null) { if(pPhotoUrlsVal != null) {
@ -137,7 +135,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pPhotoUrls, pPhotoUrlsVal, L"IList", L"String"); jsonToValue(pPhotoUrls, pPhotoUrlsVal, L"IList", L"String");
} }
delete pPhotoUrlsKey; delete pPhotoUrlsKey;
JsonString* pTagsKey = new JsonString(L"tags"); JsonString* pTagsKey = new JsonString(L"tags");
IJsonValue* pTagsVal = null; IJsonValue* pTagsVal = null;
pJsonObject->GetValue(pTagsKey, pTagsVal); pJsonObject->GetValue(pTagsKey, pTagsVal);
if(pTagsVal != null) { if(pTagsVal != null) {
@ -146,7 +144,7 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pTags, pTagsVal, L"IList", L"SamiTag"); jsonToValue(pTags, pTagsVal, L"IList", L"SamiTag");
} }
delete pTagsKey; delete pTagsKey;
JsonString* pStatusKey = new JsonString(L"status"); JsonString* pStatusKey = new JsonString(L"status");
IJsonValue* pStatusVal = null; IJsonValue* pStatusVal = null;
pJsonObject->GetValue(pStatusKey, pStatusVal); pJsonObject->GetValue(pStatusKey, pStatusVal);
if(pStatusVal != null) { if(pStatusVal != null) {
@ -155,7 +153,6 @@ SamiPet::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pStatus, pStatusVal, L"String", L"String"); jsonToValue(pStatus, pStatusVal, L"String", L"String");
} }
delete pStatusKey; delete pStatusKey;
} }
} }
@ -206,31 +203,24 @@ SamiPet::asJsonObject() {
JsonObject *pJsonObject = new JsonObject(); JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct(); pJsonObject->Construct();
JsonString *pIdKey = new JsonString(L"id"); JsonString *pIdKey = new JsonString(L"id");
pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", ""));
JsonString *pCategoryKey = new JsonString(L"category"); JsonString *pCategoryKey = new JsonString(L"category");
pJsonObject->Add(pCategoryKey, toJson(getPCategory(), "SamiCategory", "")); pJsonObject->Add(pCategoryKey, toJson(getPCategory(), "SamiCategory", ""));
JsonString *pNameKey = new JsonString(L"name"); JsonString *pNameKey = new JsonString(L"name");
pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); pJsonObject->Add(pNameKey, toJson(getPName(), "String", ""));
JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls"); JsonString *pPhotoUrlsKey = new JsonString(L"photoUrls");
pJsonObject->Add(pPhotoUrlsKey, toJson(getPPhotoUrls(), "String", "array")); pJsonObject->Add(pPhotoUrlsKey, toJson(getPPhotoUrls(), "String", "array"));
JsonString *pTagsKey = new JsonString(L"tags"); JsonString *pTagsKey = new JsonString(L"tags");
pJsonObject->Add(pTagsKey, toJson(getPTags(), "SamiTag", "array")); pJsonObject->Add(pTagsKey, toJson(getPTags(), "SamiTag", "array"));
JsonString *pStatusKey = new JsonString(L"status"); JsonString *pStatusKey = new JsonString(L"status");
pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", "")); pJsonObject->Add(pStatusKey, toJson(getPStatus(), "String", ""));
return pJsonObject; return pJsonObject;
} }

View File

@ -18,10 +18,10 @@ using namespace Tizen::Web::Json;
#include "SamiCategory.h" #include "SamiCategory.h"
using Tizen::Base::Long;
using Tizen::Base::String;
#include "SamiTag.h" #include "SamiTag.h"
using Tizen::Base::Collection::IList; using Tizen::Base::Collection::IList;
using Tizen::Base::Long;
using Tizen::Base::String;
namespace Swagger { namespace Swagger {
@ -44,34 +44,26 @@ public:
SamiPet* fromJson(String* obj); SamiPet* fromJson(String* obj);
Long* getPId(); Long* getPId();
void setPId(Long* pId); void setPId(Long* pId);
SamiCategory* getPCategory(); SamiCategory* getPCategory();
void setPCategory(SamiCategory* pCategory); void setPCategory(SamiCategory* pCategory);
String* getPName(); String* getPName();
void setPName(String* pName); void setPName(String* pName);
IList* getPPhotoUrls(); IList* getPPhotoUrls();
void setPPhotoUrls(IList* pPhotoUrls); void setPPhotoUrls(IList* pPhotoUrls);
IList* getPTags(); IList* getPTags();
void setPTags(IList* pTags); void setPTags(IList* pTags);
String* getPStatus(); String* getPStatus();
void setPStatus(String* pStatus); void setPStatus(String* pStatus);
private: private:
Long* pId; Long* pId;
SamiCategory* pCategory; SamiCategory* pCategory;
String* pName; String* pName;
IList* pPhotoUrls; IList* pPhotoUrls;
IList* pTags; IList* pTags;
String* pStatus; String* pStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -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 void
addPetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { addPetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode(); int code = pHttpResponse->GetHttpStatusCode();
@ -88,29 +39,64 @@ SamiPetApi::addPetWithCompletion(SamiPet* body, void(*success)(SamiError*)) {
headerParams->Construct(); 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); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; 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(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
@ -169,15 +154,11 @@ SamiPetApi::findPetsByStatusWithCompletion(IList* status, void (* success)(IList
queryParams->Add(new String("status"), new String(itemAt)); queryParams->Add(new String("status"), new String(itemAt));
} }
String* mBody = null; String* mBody = null;
String url(L"/pet/findByStatus"); String url(L"/pet/findByStatus");
client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; return null;
@ -227,7 +208,6 @@ SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, S
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
@ -238,15 +218,11 @@ SamiPetApi::findPetsByTagsWithCompletion(IList* tags, void (* success)(IList*, S
queryParams->Add(new String("tags"), new String(itemAt)); queryParams->Add(new String("tags"), new String(itemAt));
} }
String* mBody = null; String* mBody = null;
String url(L"/pet/findByTags"); String url(L"/pet/findByTags");
client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; return null;
@ -296,29 +272,65 @@ SamiPetApi::getPetByIdWithCompletion(Long* petId, void (* success)(SamiPet*, Sam
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
String url(L"/pet/{petId}"); String url(L"/pet/{petId}");
String s_petId(L"{"); String s_petId(L"{");
s_petId.Append(L"petId"); s_petId.Append(L"petId");
s_petId.Append(L"}"); s_petId.Append(L"}");
url.Replace(s_petId, stringify(petId, L"Long*")); url.Replace(s_petId, stringify(petId, L"Long*"));
client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); client->execute(SamiPetApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; 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 void
updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode(); int code = pHttpResponse->GetHttpStatusCode();
@ -334,7 +346,7 @@ updatePetWithFormProcessor(HttpResponse* pHttpResponse, void (* handler)(void*,
} }
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 = new SamiApiClient();
client->success(&updatePetWithFormProcessor, (void(*)(void*, SamiError*))success); client->success(&updatePetWithFormProcessor, (void(*)(void*, SamiError*))success);
@ -342,75 +354,21 @@ SamiPetApi::updatePetWithFormWithCompletion(String* petId, String* name, String*
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
String url(L"/pet/{petId}"); 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"{"); String s_petId(L"{");
s_petId.Append(L"petId"); s_petId.Append(L"petId");
s_petId.Append(L"}"); s_petId.Append(L"}");
url.Replace(s_petId, stringify(petId, L"Long*")); 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(); int code = pHttpResponse->GetHttpStatusCode();
if(code >= 200 && code < 300) { 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 { else {
SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText())); SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText()));
handler(null, error);
handler(error, null);
} }
} }
void SamiApiResponse*
SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void(*success)(SamiError*)) { SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, SamiFile* file, void (* success)(SamiApiResponse*, SamiError*)) {
client = new SamiApiClient(); client = new SamiApiClient();
client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success); client->success(&uploadFileProcessor, (void(*)(void*, SamiError*))success);
@ -437,27 +416,22 @@ SamiPetApi::uploadFileWithCompletion(Long* petId, String* additionalMetadata, Sa
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
String url(L"/pet/{petId}/uploadImage"); String url(L"/pet/{petId}/uploadImage");
String s_petId(L"{"); String s_petId(L"{");
s_petId.Append(L"petId"); s_petId.Append(L"petId");
s_petId.Append(L"}"); s_petId.Append(L"}");
url.Replace(s_petId, stringify(petId, L"Long*")); 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, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null;
} }

View File

@ -6,9 +6,10 @@
#include "SamiError.h" #include "SamiError.h"
#include "SamiPet.h" #include "SamiPet.h"
using Tizen::Base::String;
using Tizen::Base::Long; using Tizen::Base::Long;
using Tizen::Base::String;
#include "SamiFile.h" #include "SamiFile.h"
#include "SamiApiResponse.h"
using namespace Tizen::Net::Http; using namespace Tizen::Net::Http;
@ -19,31 +20,22 @@ public:
SamiPetApi(); SamiPetApi();
virtual ~SamiPetApi(); virtual ~SamiPetApi();
void
updatePetWithCompletion(SamiPet* body, void(* handler)(SamiError*));
void void
addPetWithCompletion(SamiPet* body, void(* handler)(SamiError*)); 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 void
deletePetWithCompletion(Long* petId, String* apiKey, void(* handler)(SamiError*)); 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 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() { static String getBasePath() {
return L"http://petstore.swagger.io/v2"; return L"http://petstore.swagger.io/v2";
} }

View File

@ -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 void
getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { getInventoryProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode(); int code = pHttpResponse->GetHttpStatusCode();
@ -60,19 +101,77 @@ SamiStoreApi::getInventoryWithCompletion( void (* success)(HashMap*, SamiError*)
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
String url(L"/store/inventory"); 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"); client->execute(SamiStoreApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; return null;
@ -122,144 +221,23 @@ SamiStoreApi::placeOrderWithCompletion(SamiOrder* body, void (* success)(SamiOrd
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
if(body != null) { if(body != null) {
mBody = new String(body->asJson()); mBody = new String(body->asJson());
headerParams->Add(new String("Content-Type"), new String("application/json")); headerParams->Add(new String("Content-Type"), new String("application/json"));
} }
String url(L"/store/order"); String url(L"/store/order");
client->execute(SamiStoreApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); client->execute(SamiStoreApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; 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 */ } /* namespace Swagger */

View File

@ -5,9 +5,10 @@
#include "SamiApiClient.h" #include "SamiApiClient.h"
#include "SamiError.h" #include "SamiError.h"
using Tizen::Base::String;
using Tizen::Base::Integer; using Tizen::Base::Integer;
#include "SamiOrder.h" #include "SamiOrder.h"
using Tizen::Base::String; using Tizen::Base::Long;
using namespace Tizen::Net::Http; using namespace Tizen::Net::Http;
@ -18,19 +19,14 @@ public:
SamiStoreApi(); SamiStoreApi();
virtual ~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 void
deleteOrderWithCompletion(String* orderId, void(* handler)(SamiError*)); 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() { static String getBasePath() {
return L"http://petstore.swagger.io/v2"; return L"http://petstore.swagger.io/v2";
} }

View File

@ -23,8 +23,7 @@ SamiTag::~SamiTag() {
void void
SamiTag::init() { SamiTag::init() {
pId = null; pId = null;
pName = null; pName = null;
} }
void void
@ -34,12 +33,11 @@ SamiTag::cleanup() {
delete pId; delete pId;
pId = null; pId = null;
} }
if(pName != null) { if(pName != null) {
delete pName; delete pName;
pName = null; pName = null;
} }
} }
@ -86,7 +84,7 @@ SamiTag::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pId, pIdVal, L"Long", L"Long"); jsonToValue(pId, pIdVal, L"Long", L"Long");
} }
delete pIdKey; delete pIdKey;
JsonString* pNameKey = new JsonString(L"name"); JsonString* pNameKey = new JsonString(L"name");
IJsonValue* pNameVal = null; IJsonValue* pNameVal = null;
pJsonObject->GetValue(pNameKey, pNameVal); pJsonObject->GetValue(pNameKey, pNameVal);
if(pNameVal != null) { if(pNameVal != null) {
@ -95,7 +93,6 @@ SamiTag::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pName, pNameVal, L"String", L"String"); jsonToValue(pName, pNameVal, L"String", L"String");
} }
delete pNameKey; delete pNameKey;
} }
} }
@ -146,15 +143,12 @@ SamiTag::asJsonObject() {
JsonObject *pJsonObject = new JsonObject(); JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct(); pJsonObject->Construct();
JsonString *pIdKey = new JsonString(L"id"); JsonString *pIdKey = new JsonString(L"id");
pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", ""));
JsonString *pNameKey = new JsonString(L"name"); JsonString *pNameKey = new JsonString(L"name");
pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); pJsonObject->Add(pNameKey, toJson(getPName(), "String", ""));
return pJsonObject; return pJsonObject;
} }

View File

@ -41,18 +41,14 @@ public:
SamiTag* fromJson(String* obj); SamiTag* fromJson(String* obj);
Long* getPId(); Long* getPId();
void setPId(Long* pId); void setPId(Long* pId);
String* getPName(); String* getPName();
void setPName(String* pName); void setPName(String* pName);
private: private:
Long* pId; Long* pId;
String* pName; String* pName;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -23,14 +23,13 @@ SamiUser::~SamiUser() {
void void
SamiUser::init() { SamiUser::init() {
pId = null; pId = null;
pUsername = null; pUsername = null;
pFirstName = null; pFirstName = null;
pLastName = null; pLastName = null;
pEmail = null; pEmail = null;
pPassword = null; pPassword = null;
pPhone = null; pPhone = null;
pUserStatus = null; pUserStatus = null;
} }
void void
@ -40,42 +39,41 @@ SamiUser::cleanup() {
delete pId; delete pId;
pId = null; pId = null;
} }
if(pUsername != null) { if(pUsername != null) {
delete pUsername; delete pUsername;
pUsername = null; pUsername = null;
} }
if(pFirstName != null) { if(pFirstName != null) {
delete pFirstName; delete pFirstName;
pFirstName = null; pFirstName = null;
} }
if(pLastName != null) { if(pLastName != null) {
delete pLastName; delete pLastName;
pLastName = null; pLastName = null;
} }
if(pEmail != null) { if(pEmail != null) {
delete pEmail; delete pEmail;
pEmail = null; pEmail = null;
} }
if(pPassword != null) { if(pPassword != null) {
delete pPassword; delete pPassword;
pPassword = null; pPassword = null;
} }
if(pPhone != null) { if(pPhone != null) {
delete pPhone; delete pPhone;
pPhone = null; pPhone = null;
} }
if(pUserStatus != null) { if(pUserStatus != null) {
delete pUserStatus; delete pUserStatus;
pUserStatus = null; pUserStatus = null;
} }
} }
@ -122,7 +120,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pId, pIdVal, L"Long", L"Long"); jsonToValue(pId, pIdVal, L"Long", L"Long");
} }
delete pIdKey; delete pIdKey;
JsonString* pUsernameKey = new JsonString(L"username"); JsonString* pUsernameKey = new JsonString(L"username");
IJsonValue* pUsernameVal = null; IJsonValue* pUsernameVal = null;
pJsonObject->GetValue(pUsernameKey, pUsernameVal); pJsonObject->GetValue(pUsernameKey, pUsernameVal);
if(pUsernameVal != null) { if(pUsernameVal != null) {
@ -131,7 +129,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pUsername, pUsernameVal, L"String", L"String"); jsonToValue(pUsername, pUsernameVal, L"String", L"String");
} }
delete pUsernameKey; delete pUsernameKey;
JsonString* pFirstNameKey = new JsonString(L"firstName"); JsonString* pFirstNameKey = new JsonString(L"firstName");
IJsonValue* pFirstNameVal = null; IJsonValue* pFirstNameVal = null;
pJsonObject->GetValue(pFirstNameKey, pFirstNameVal); pJsonObject->GetValue(pFirstNameKey, pFirstNameVal);
if(pFirstNameVal != null) { if(pFirstNameVal != null) {
@ -140,7 +138,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pFirstName, pFirstNameVal, L"String", L"String"); jsonToValue(pFirstName, pFirstNameVal, L"String", L"String");
} }
delete pFirstNameKey; delete pFirstNameKey;
JsonString* pLastNameKey = new JsonString(L"lastName"); JsonString* pLastNameKey = new JsonString(L"lastName");
IJsonValue* pLastNameVal = null; IJsonValue* pLastNameVal = null;
pJsonObject->GetValue(pLastNameKey, pLastNameVal); pJsonObject->GetValue(pLastNameKey, pLastNameVal);
if(pLastNameVal != null) { if(pLastNameVal != null) {
@ -149,7 +147,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pLastName, pLastNameVal, L"String", L"String"); jsonToValue(pLastName, pLastNameVal, L"String", L"String");
} }
delete pLastNameKey; delete pLastNameKey;
JsonString* pEmailKey = new JsonString(L"email"); JsonString* pEmailKey = new JsonString(L"email");
IJsonValue* pEmailVal = null; IJsonValue* pEmailVal = null;
pJsonObject->GetValue(pEmailKey, pEmailVal); pJsonObject->GetValue(pEmailKey, pEmailVal);
if(pEmailVal != null) { if(pEmailVal != null) {
@ -158,7 +156,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pEmail, pEmailVal, L"String", L"String"); jsonToValue(pEmail, pEmailVal, L"String", L"String");
} }
delete pEmailKey; delete pEmailKey;
JsonString* pPasswordKey = new JsonString(L"password"); JsonString* pPasswordKey = new JsonString(L"password");
IJsonValue* pPasswordVal = null; IJsonValue* pPasswordVal = null;
pJsonObject->GetValue(pPasswordKey, pPasswordVal); pJsonObject->GetValue(pPasswordKey, pPasswordVal);
if(pPasswordVal != null) { if(pPasswordVal != null) {
@ -167,7 +165,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pPassword, pPasswordVal, L"String", L"String"); jsonToValue(pPassword, pPasswordVal, L"String", L"String");
} }
delete pPasswordKey; delete pPasswordKey;
JsonString* pPhoneKey = new JsonString(L"phone"); JsonString* pPhoneKey = new JsonString(L"phone");
IJsonValue* pPhoneVal = null; IJsonValue* pPhoneVal = null;
pJsonObject->GetValue(pPhoneKey, pPhoneVal); pJsonObject->GetValue(pPhoneKey, pPhoneVal);
if(pPhoneVal != null) { if(pPhoneVal != null) {
@ -176,7 +174,7 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pPhone, pPhoneVal, L"String", L"String"); jsonToValue(pPhone, pPhoneVal, L"String", L"String");
} }
delete pPhoneKey; delete pPhoneKey;
JsonString* pUserStatusKey = new JsonString(L"userStatus"); JsonString* pUserStatusKey = new JsonString(L"userStatus");
IJsonValue* pUserStatusVal = null; IJsonValue* pUserStatusVal = null;
pJsonObject->GetValue(pUserStatusKey, pUserStatusVal); pJsonObject->GetValue(pUserStatusKey, pUserStatusVal);
if(pUserStatusVal != null) { if(pUserStatusVal != null) {
@ -185,7 +183,6 @@ SamiUser::fromJsonObject(IJsonValue* pJson) {
jsonToValue(pUserStatus, pUserStatusVal, L"Integer", L"Integer"); jsonToValue(pUserStatus, pUserStatusVal, L"Integer", L"Integer");
} }
delete pUserStatusKey; delete pUserStatusKey;
} }
} }
@ -236,39 +233,30 @@ SamiUser::asJsonObject() {
JsonObject *pJsonObject = new JsonObject(); JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct(); pJsonObject->Construct();
JsonString *pIdKey = new JsonString(L"id"); JsonString *pIdKey = new JsonString(L"id");
pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", ""));
JsonString *pUsernameKey = new JsonString(L"username"); JsonString *pUsernameKey = new JsonString(L"username");
pJsonObject->Add(pUsernameKey, toJson(getPUsername(), "String", "")); pJsonObject->Add(pUsernameKey, toJson(getPUsername(), "String", ""));
JsonString *pFirstNameKey = new JsonString(L"firstName"); JsonString *pFirstNameKey = new JsonString(L"firstName");
pJsonObject->Add(pFirstNameKey, toJson(getPFirstName(), "String", "")); pJsonObject->Add(pFirstNameKey, toJson(getPFirstName(), "String", ""));
JsonString *pLastNameKey = new JsonString(L"lastName"); JsonString *pLastNameKey = new JsonString(L"lastName");
pJsonObject->Add(pLastNameKey, toJson(getPLastName(), "String", "")); pJsonObject->Add(pLastNameKey, toJson(getPLastName(), "String", ""));
JsonString *pEmailKey = new JsonString(L"email"); JsonString *pEmailKey = new JsonString(L"email");
pJsonObject->Add(pEmailKey, toJson(getPEmail(), "String", "")); pJsonObject->Add(pEmailKey, toJson(getPEmail(), "String", ""));
JsonString *pPasswordKey = new JsonString(L"password"); JsonString *pPasswordKey = new JsonString(L"password");
pJsonObject->Add(pPasswordKey, toJson(getPPassword(), "String", "")); pJsonObject->Add(pPasswordKey, toJson(getPPassword(), "String", ""));
JsonString *pPhoneKey = new JsonString(L"phone"); JsonString *pPhoneKey = new JsonString(L"phone");
pJsonObject->Add(pPhoneKey, toJson(getPPhone(), "String", "")); pJsonObject->Add(pPhoneKey, toJson(getPPhone(), "String", ""));
JsonString *pUserStatusKey = new JsonString(L"userStatus"); JsonString *pUserStatusKey = new JsonString(L"userStatus");
pJsonObject->Add(pUserStatusKey, toJson(getPUserStatus(), "Integer", "")); pJsonObject->Add(pUserStatusKey, toJson(getPUserStatus(), "Integer", ""));
return pJsonObject; return pJsonObject;
} }

View File

@ -17,9 +17,9 @@
using namespace Tizen::Web::Json; using namespace Tizen::Web::Json;
using Tizen::Base::Integer;
using Tizen::Base::Long; using Tizen::Base::Long;
using Tizen::Base::String; using Tizen::Base::String;
using Tizen::Base::Integer;
namespace Swagger { namespace Swagger {
@ -42,42 +42,32 @@ public:
SamiUser* fromJson(String* obj); SamiUser* fromJson(String* obj);
Long* getPId(); Long* getPId();
void setPId(Long* pId); void setPId(Long* pId);
String* getPUsername(); String* getPUsername();
void setPUsername(String* pUsername); void setPUsername(String* pUsername);
String* getPFirstName(); String* getPFirstName();
void setPFirstName(String* pFirstName); void setPFirstName(String* pFirstName);
String* getPLastName(); String* getPLastName();
void setPLastName(String* pLastName); void setPLastName(String* pLastName);
String* getPEmail(); String* getPEmail();
void setPEmail(String* pEmail); void setPEmail(String* pEmail);
String* getPPassword(); String* getPPassword();
void setPPassword(String* pPassword); void setPPassword(String* pPassword);
String* getPPhone(); String* getPPhone();
void setPPhone(String* pPhone); void setPPhone(String* pPhone);
Integer* getPUserStatus(); Integer* getPUserStatus();
void setPUserStatus(Integer* pUserStatus); void setPUserStatus(Integer* pUserStatus);
private: private:
Long* pId; Long* pId;
String* pUsername; String* pUsername;
String* pFirstName; String* pFirstName;
String* pLastName; String* pLastName;
String* pEmail; String* pEmail;
String* pPassword; String* pPassword;
String* pPhone; String* pPhone;
Integer* pUserStatus; Integer* pUserStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -39,27 +39,19 @@ SamiUserApi::createUserWithCompletion(SamiUser* body, void(*success)(SamiError*)
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
if(body != null) { if(body != null) {
mBody = new String(body->asJson()); mBody = new String(body->asJson());
headerParams->Add(new String("Content-Type"), new String("application/json")); headerParams->Add(new String("Content-Type"), new String("application/json"));
} }
String url(L"/user"); String url(L"/user");
client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); 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(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
if(body != null) { if(body != null) {
mBody = new String(""); mBody = new String("");
int sz = body->GetCount(); int sz = body->GetCount();
@ -111,13 +99,9 @@ SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success)
mBody->Append("]"); mBody->Append("]");
headerParams->Add(new String("Content-Type"), new String("application/json")); headerParams->Add(new String("Content-Type"), new String("application/json"));
} }
String url(L"/user/createWithArray"); String url(L"/user/createWithArray");
client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); 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(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
if(body != null) { if(body != null) {
mBody = new String(""); mBody = new String("");
int sz = body->GetCount(); int sz = body->GetCount();
@ -169,88 +149,16 @@ SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)(
mBody->Append("]"); mBody->Append("]");
headerParams->Add(new String("Content-Type"), new String("application/json")); headerParams->Add(new String("Content-Type"), new String("application/json"));
} }
String url(L"/user/createWithList"); String url(L"/user/createWithList");
client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); client->execute(SamiUserApi::getBasePath(), url, "POST", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
} }
void void
loginUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { deleteUserProcessor(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(); int code = pHttpResponse->GetHttpStatusCode();
if(code >= 200 && code < 300) { if(code >= 200 && code < 300) {
@ -264,29 +172,29 @@ logoutUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiErr
} }
void void
SamiUserApi::logoutUserWithCompletion( void(*success)(SamiError*)) { SamiUserApi::deleteUserWithCompletion(String* username, void(*success)(SamiError*)) {
client = new SamiApiClient(); client = new SamiApiClient();
client->success(&logoutUserProcessor, (void(*)(void*, SamiError*))success); client->success(&deleteUserProcessor, (void(*)(void*, SamiError*))success);
HashMap* headerParams = new HashMap(SingleObjectDeleter); HashMap* headerParams = new HashMap(SingleObjectDeleter);
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; 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(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
String url(L"/user/{username}"); String url(L"/user/{username}");
String s_username(L"{"); String s_username(L"{");
s_username.Append(L"username"); s_username.Append(L"username");
s_username.Append(L"}"); s_username.Append(L"}");
url.Replace(s_username, stringify(username, L"String*")); 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, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; 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 void
updateUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { updateUserProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode(); int code = pHttpResponse->GetHttpStatusCode();
@ -380,82 +382,27 @@ SamiUserApi::updateUserWithCompletion(String* username, SamiUser* body, void(*su
headerParams->Construct(); headerParams->Construct();
HashMap* queryParams = new HashMap(SingleObjectDeleter); HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct(); queryParams->Construct();
String* mBody = null; String* mBody = null;
if(body != null) { if(body != null) {
mBody = new String(body->asJson()); mBody = new String(body->asJson());
headerParams->Add(new String("Content-Type"), new String("application/json")); headerParams->Add(new String("Content-Type"), new String("application/json"));
} }
String url(L"/user/{username}"); String url(L"/user/{username}");
String s_username(L"{"); String s_username(L"{");
s_username.Append(L"username"); s_username.Append(L"username");
s_username.Append(L"}"); s_username.Append(L"}");
url.Replace(s_username, stringify(username, L"String*")); url.Replace(s_username, stringify(username, L"String*"));
client->execute(SamiUserApi::getBasePath(), url, "PUT", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json"); 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 */ } /* namespace Swagger */

View File

@ -18,31 +18,22 @@ public:
SamiUserApi(); SamiUserApi();
virtual ~SamiUserApi(); virtual ~SamiUserApi();
void void
createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*)); createUserWithCompletion(SamiUser* body, void(* handler)(SamiError*));
void void
createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*)); createUsersWithArrayInputWithCompletion(IList* body, void(* handler)(SamiError*));
void void
createUsersWithListInputWithCompletion(IList* body, void(* handler)(SamiError*)); 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 void
deleteUserWithCompletion(String* username, void(* handler)(SamiError*)); 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() { static String getBasePath() {
return L"http://petstore.swagger.io/v2"; return L"http://petstore.swagger.io/v2";
} }