Files
openapi-generator/samples/client/petstore/qt5cpp/client/ApiResponse.cpp

127 lines
2.5 KiB
C++

/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "ApiResponse.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace Swagger {
ApiResponse::ApiResponse(QString* json) {
init();
this->fromJson(*json);
}
ApiResponse::ApiResponse() {
init();
}
ApiResponse::~ApiResponse() {
this->cleanup();
}
void
ApiResponse::init() {
code = 0;
type = new QString("");
message = new QString("");
}
void
ApiResponse::cleanup() {
if(type != nullptr) {
delete type;
}
if(message != nullptr) {
delete message;
}
}
ApiResponse*
ApiResponse::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
ApiResponse::fromJsonObject(QJsonObject &pJson) {
::Swagger::setValue(&code, pJson["code"], "qint32", "");
::Swagger::setValue(&type, pJson["type"], "QString", "QString");
::Swagger::setValue(&message, pJson["message"], "QString", "QString");
}
QString
ApiResponse::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject*
ApiResponse::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("code", QJsonValue(code));
toJsonValue(QString("type"), type, obj, QString("QString"));
toJsonValue(QString("message"), message, obj, QString("QString"));
return obj;
}
qint32
ApiResponse::getCode() {
return code;
}
void
ApiResponse::setCode(qint32 code) {
this->code = code;
}
QString*
ApiResponse::getType() {
return type;
}
void
ApiResponse::setType(QString* type) {
this->type = type;
}
QString*
ApiResponse::getMessage() {
return message;
}
void
ApiResponse::setMessage(QString* message) {
this->message = message;
}
}