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

@ -28,7 +28,6 @@ void
SWGCategory::init() { SWGCategory::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
@ -37,7 +36,6 @@ SWGCategory::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGCategory* SWGCategory*
@ -53,7 +51,6 @@ 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
@ -76,8 +73,6 @@ SWGCategory::asJsonObject() {
return obj; return obj;
} }

View File

@ -35,11 +35,9 @@ public:
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

@ -32,7 +32,6 @@ SWGOrder::init() {
shipDate = NULL; shipDate = NULL;
status = new QString(""); status = new QString("");
complete = false; complete = false;
} }
void void
@ -47,7 +46,6 @@ SWGOrder::cleanup() {
delete status; delete status;
} }
} }
SWGOrder* SWGOrder*
@ -67,7 +65,6 @@ SWGOrder::fromJsonObject(QJsonObject &pJson) {
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
@ -93,14 +90,11 @@ SWGOrder::asJsonObject() {
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

@ -44,7 +44,6 @@ public:
bool getComplete(); bool getComplete();
void setComplete(bool complete); void setComplete(bool complete);
private: private:
qint64 id; qint64 id;
qint64 petId; qint64 petId;
@ -52,7 +51,6 @@ private:
QDateTime* shipDate; QDateTime* shipDate;
QString* status; QString* status;
bool complete; bool complete;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -32,7 +32,6 @@ SWGPet::init() {
photoUrls = new QList<QString*>(); photoUrls = new QList<QString*>();
tags = new QList<SWGTag*>(); tags = new QList<SWGTag*>();
status = new QString(""); status = new QString("");
} }
void void
@ -61,7 +60,6 @@ SWGPet::cleanup() {
if(status != NULL) { if(status != NULL) {
delete status; delete status;
} }
} }
SWGPet* SWGPet*
@ -81,7 +79,6 @@ SWGPet::fromJsonObject(QJsonObject &pJson) {
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
@ -105,13 +102,11 @@ SWGPet::asJsonObject() {
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;
toJsonArray((QList<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString"); toJsonArray((QList<void*>*)photoUrls, &photoUrlsJsonArray, "photoUrls", "QString");
@ -120,7 +115,6 @@ SWGPet::asJsonObject() {
QList<SWGTag*>* tagsList = tags; QList<SWGTag*>* tagsList = tags;
QJsonArray tagsJsonArray; QJsonArray tagsJsonArray;
toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag"); toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
@ -129,13 +123,10 @@ SWGPet::asJsonObject() {
toJsonValue(QString("status"), status, obj, QString("QString")); toJsonValue(QString("status"), status, obj, QString("QString"));
return obj; return obj;
} }

View File

@ -46,7 +46,6 @@ public:
QString* getStatus(); QString* getStatus();
void setStatus(QString* status); void setStatus(QString* status);
private: private:
qint64 id; qint64 id;
SWGCategory* category; SWGCategory* category;
@ -54,7 +53,6 @@ private:
QList<QString*>* photoUrls; QList<QString*>* photoUrls;
QList<SWGTag*>* tags; QList<SWGTag*>* tags;
QString* status; QString* status;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -15,54 +15,6 @@ 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;
@ -70,22 +22,15 @@ SWGPetApi::addPet(SWGPet body) {
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,
this, this,
@ -112,6 +57,48 @@ 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");
@ -119,12 +106,8 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
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
@ -164,8 +147,6 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
} }
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
@ -173,8 +154,6 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -210,7 +189,6 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
worker->deleteLater(); worker->deleteLater();
emit findPetsByStatusSignal(output); emit findPetsByStatusSignal(output);
@ -224,12 +202,8 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
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
@ -269,8 +243,6 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
} }
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
@ -278,8 +250,6 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -315,7 +285,6 @@ SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
worker->deleteLater(); worker->deleteLater();
emit findPetsByTagsSignal(output); emit findPetsByTagsSignal(output);
@ -326,13 +295,10 @@ 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");
@ -340,8 +306,6 @@ SWGPetApi::getPetById(qint64 petId) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -361,33 +325,65 @@ 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();
emit getPetByIdSignal(output); emit getPetByIdSignal(output);
} }
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");
@ -401,8 +397,6 @@ SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -429,65 +423,14 @@ 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");
@ -501,8 +444,6 @@ SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestI
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -522,113 +463,13 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
} }
worker->deleteLater();
emit uploadFileSignal();
}
void
SWGPetApi::getPetByIdWithByteArray(qint64 petId) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}?testing_byte_array=true");
QString petIdPathParam("{"); petIdPathParam.append("petId").append("}");
fullPath.replace(petIdPathParam, stringValue(petId));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
connect(worker,
&HttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::getPetByIdWithByteArrayCallback);
worker->execute(&input);
}
void
SWGPetApi::getPetByIdWithByteArrayCallback(HttpRequestWorker * worker) {
QString msg;
if (worker->error_type == QNetworkReply::NoError) {
msg = QString("Success! %1 bytes").arg(worker->response.length());
}
else {
msg = "Error: " + worker->error_str;
}
QString json(worker->response); QString json(worker->response);
QString* output = static_cast<QString*>(create(json, QString("QString"))); SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
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,193 +15,15 @@ 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");
@ -209,8 +31,6 @@ SWGStoreApi::deleteOrder(QString* orderId) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -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

@ -28,7 +28,6 @@ void
SWGTag::init() { SWGTag::init() {
id = 0L; id = 0L;
name = new QString(""); name = new QString("");
} }
void void
@ -37,7 +36,6 @@ SWGTag::cleanup() {
if(name != NULL) { if(name != NULL) {
delete name; delete name;
} }
} }
SWGTag* SWGTag*
@ -53,7 +51,6 @@ 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
@ -76,8 +73,6 @@ SWGTag::asJsonObject() {
return obj; return obj;
} }

View File

@ -35,11 +35,9 @@ public:
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

@ -34,7 +34,6 @@ SWGUser::init() {
password = new QString(""); password = new QString("");
phone = new QString(""); phone = new QString("");
userStatus = 0; userStatus = 0;
} }
void void
@ -59,7 +58,6 @@ SWGUser::cleanup() {
delete phone; delete phone;
} }
} }
SWGUser* SWGUser*
@ -81,7 +79,6 @@ SWGUser::fromJsonObject(QJsonObject &pJson) {
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
@ -105,38 +102,31 @@ SWGUser::asJsonObject() {
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

@ -47,7 +47,6 @@ public:
qint32 getUserStatus(); qint32 getUserStatus();
void setUserStatus(qint32 userStatus); void setUserStatus(qint32 userStatus);
private: private:
qint64 id; qint64 id;
QString* username; QString* username;
@ -57,7 +56,6 @@ private:
QString* password; QString* password;
QString* phone; QString* phone;
qint32 userStatus; qint32 userStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -22,22 +22,15 @@ SWGUserApi::createUser(SWGUser body) {
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,
this, this,
@ -70,15 +63,10 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
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*"));
@ -89,8 +77,6 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -123,15 +109,10 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
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*"));
@ -142,8 +123,6 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -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
@ -186,10 +247,6 @@ SWGUserApi::loginUser(QString* username, QString* password) {
.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
@ -199,9 +256,6 @@ SWGUserApi::loginUser(QString* username, QString* password) {
.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");
@ -209,8 +263,6 @@ SWGUserApi::loginUser(QString* username, QString* password) {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -230,16 +282,10 @@ 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();
emit loginUserSignal(output); emit loginUserSignal(output);
@ -252,8 +298,6 @@ SWGUserApi::logoutUser() {
HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET"); HttpRequestInput input(fullPath, "GET");
@ -261,8 +305,6 @@ SWGUserApi::logoutUser() {
connect(worker, connect(worker,
&HttpRequestWorker::on_execution_finished, &HttpRequestWorker::on_execution_finished,
this, this,
@ -289,86 +331,23 @@ 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,
this, this,
@ -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

@ -24,7 +24,6 @@ void
SamiCategory::init() { SamiCategory::init() {
pId = null; pId = null;
pName = null; pName = null;
} }
void void
@ -39,7 +38,6 @@ SamiCategory::cleanup() {
delete pName; delete pName;
pName = null; pName = 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

@ -28,7 +28,6 @@ SamiOrder::init() {
pShipDate = null; pShipDate = null;
pStatus = null; pStatus = null;
pComplete = null; pComplete = null;
} }
void void
@ -63,7 +62,6 @@ SamiOrder::cleanup() {
delete pComplete; delete pComplete;
pComplete = null; pComplete = 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,26 +44,19 @@ 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;
@ -71,7 +64,6 @@ private:
DateTime* pShipDate; DateTime* pShipDate;
String* pStatus; String* pStatus;
Boolean* pComplete; Boolean* pComplete;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -28,7 +28,6 @@ SamiPet::init() {
pPhotoUrls = null; pPhotoUrls = null;
pTags = null; pTags = null;
pStatus = null; pStatus = null;
} }
void void
@ -63,7 +62,6 @@ SamiPet::cleanup() {
delete pStatus; delete pStatus;
pStatus = null; pStatus = 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,26 +44,19 @@ 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;
@ -71,7 +64,6 @@ private:
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,32 +39,67 @@ SamiPetApi::addPetWithCompletion(SamiPet* 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"/pet"); String url(L"/pet");
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");
} }
void
deletePetProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode();
if(code >= 200 && code < 300) {
handler(null, null);
}
else {
SamiError* error = new SamiError(code, new String(pHttpResponse->GetStatusText()));
handler(error, null);
}
}
void
SamiPetApi::deletePetWithCompletion(Long* petId, String* apiKey, void(*success)(SamiError*)) {
client = new SamiApiClient();
client->success(&deletePetProcessor, (void(*)(void*, SamiError*))success);
HashMap* headerParams = new HashMap(SingleObjectDeleter);
headerParams->Construct();
headerParams->Add(new String("api_key"), apiKey);
HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct();
String* mBody = null;
String url(L"/pet/{petId}");
String s_petId(L"{");
s_petId.Append(L"petId");
s_petId.Append(L"}");
url.Replace(s_petId, stringify(petId, L"Long*"));
client->execute(SamiPetApi::getBasePath(), url, "DELETE", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
}
void void
findPetsByStatusProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) { findPetsByStatusProcessor(HttpResponse* pHttpResponse, void (* handler)(void*, SamiError*)) {
int code = pHttpResponse->GetHttpStatusCode(); int code = pHttpResponse->GetHttpStatusCode();
@ -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,16 +154,12 @@ 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,16 +218,12 @@ 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, "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");
} }
@ -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

@ -24,7 +24,6 @@ void
SamiTag::init() { SamiTag::init() {
pId = null; pId = null;
pName = null; pName = null;
} }
void void
@ -39,7 +38,6 @@ SamiTag::cleanup() {
delete pName; delete pName;
pName = null; pName = 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

@ -30,7 +30,6 @@ SamiUser::init() {
pPassword = null; pPassword = null;
pPhone = null; pPhone = null;
pUserStatus = null; pUserStatus = null;
} }
void void
@ -75,7 +74,6 @@ SamiUser::cleanup() {
delete pUserStatus; delete pUserStatus;
pUserStatus = null; pUserStatus = 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,32 +42,23 @@ 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;
@ -77,7 +68,6 @@ private:
String* pPassword; String* pPassword;
String* pPhone; String* pPhone;
Integer* pUserStatus; Integer* pUserStatus;
}; };
} /* namespace Swagger */ } /* namespace Swagger */

View File

@ -39,28 +39,20 @@ 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();
@ -112,13 +100,9 @@ SamiUserApi::createUsersWithArrayInputWithCompletion(IList* body, void(*success)
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();
@ -170,87 +150,15 @@ SamiUserApi::createUsersWithListInputWithCompletion(IList* body, void(*success)(
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/{username}");
String url(L"/user/logout"); 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");
client->execute(SamiUserApi::getBasePath(), url, "GET", (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");
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"); client->execute(SamiUserApi::getBasePath(), url, "GET", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
return null; 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";
} }