/**
 * 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 "SWGUser.h"

#include "SWGHelpers.h"

#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>

namespace Swagger {


SWGUser::SWGUser(QString* json) {
    init();
    this->fromJson(*json);
}

SWGUser::SWGUser() {
    init();
}

SWGUser::~SWGUser() {
    this->cleanup();
}

void
SWGUser::init() {
    id = 0L;
    username = new QString("");
    first_name = new QString("");
    last_name = new QString("");
    email = new QString("");
    password = new QString("");
    phone = new QString("");
    user_status = 0;
}

void
SWGUser::cleanup() {
    

    if(username != nullptr) {
        delete username;
    }

    if(first_name != nullptr) {
        delete first_name;
    }

    if(last_name != nullptr) {
        delete last_name;
    }

    if(email != nullptr) {
        delete email;
    }

    if(password != nullptr) {
        delete password;
    }

    if(phone != nullptr) {
        delete phone;
    }

}

SWGUser*
SWGUser::fromJson(QString &json) {
    QByteArray array (json.toStdString().c_str());
    QJsonDocument doc = QJsonDocument::fromJson(array);
    QJsonObject jsonObject = doc.object();
    this->fromJsonObject(jsonObject);
    return this;
}

void
SWGUser::fromJsonObject(QJsonObject &pJson) {
    ::Swagger::setValue(&id, pJson["id"], "qint64", "");
    ::Swagger::setValue(&username, pJson["username"], "QString", "QString");
    ::Swagger::setValue(&first_name, pJson["firstName"], "QString", "QString");
    ::Swagger::setValue(&last_name, pJson["lastName"], "QString", "QString");
    ::Swagger::setValue(&email, pJson["email"], "QString", "QString");
    ::Swagger::setValue(&password, pJson["password"], "QString", "QString");
    ::Swagger::setValue(&phone, pJson["phone"], "QString", "QString");
    ::Swagger::setValue(&user_status, pJson["userStatus"], "qint32", "");
}

QString
SWGUser::asJson ()
{
    QJsonObject* obj = this->asJsonObject();
    
    QJsonDocument doc(*obj);
    QByteArray bytes = doc.toJson();
    return QString(bytes);
}

QJsonObject*
SWGUser::asJsonObject() {
    QJsonObject* obj = new QJsonObject();
    
    obj->insert("id", QJsonValue(id));

    toJsonValue(QString("username"), username, obj, QString("QString"));

    toJsonValue(QString("firstName"), first_name, obj, QString("QString"));

    toJsonValue(QString("lastName"), last_name, obj, QString("QString"));

    toJsonValue(QString("email"), email, obj, QString("QString"));

    toJsonValue(QString("password"), password, obj, QString("QString"));

    toJsonValue(QString("phone"), phone, obj, QString("QString"));

    obj->insert("userStatus", QJsonValue(user_status));

    return obj;
}

qint64
SWGUser::getId() {
    return id;
}
void
SWGUser::setId(qint64 id) {
    this->id = id;
}

QString*
SWGUser::getUsername() {
    return username;
}
void
SWGUser::setUsername(QString* username) {
    this->username = username;
}

QString*
SWGUser::getFirstName() {
    return first_name;
}
void
SWGUser::setFirstName(QString* first_name) {
    this->first_name = first_name;
}

QString*
SWGUser::getLastName() {
    return last_name;
}
void
SWGUser::setLastName(QString* last_name) {
    this->last_name = last_name;
}

QString*
SWGUser::getEmail() {
    return email;
}
void
SWGUser::setEmail(QString* email) {
    this->email = email;
}

QString*
SWGUser::getPassword() {
    return password;
}
void
SWGUser::setPassword(QString* password) {
    this->password = password;
}

QString*
SWGUser::getPhone() {
    return phone;
}
void
SWGUser::setPhone(QString* phone) {
    this->phone = phone;
}

qint32
SWGUser::getUserStatus() {
    return user_status;
}
void
SWGUser::setUserStatus(qint32 user_status) {
    this->user_status = user_status;
}



} /* namespace Swagger */

