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

namespace io {
namespace swagger {
namespace server {
namespace model {

Pet::Pet()
{
    m_Id = 0L;
    m_IdIsSet = false;
    m_CategoryIsSet = false;
    m_Name = "";
    m_TagsIsSet = false;
    m_Status = "";
    m_StatusIsSet = false;
    
}

Pet::~Pet()
{
}

void Pet::validate()
{
    // TODO: implement validation
}

nlohmann::json Pet::toJson() const
{
    nlohmann::json val = nlohmann::json::object();

    if(m_IdIsSet)
    {
        val["id"] = m_Id;
    }
    if(m_CategoryIsSet)
    {
        val["category"] = ModelBase::toJson(m_Category);
    }
    val["name"] = ModelBase::toJson(m_Name);
    {
        nlohmann::json jsonArray;
        for( auto& item : m_PhotoUrls )
        {
            jsonArray.push_back(ModelBase::toJson(item));
        }
        val["photoUrls"] = jsonArray;
            }
    {
        nlohmann::json jsonArray;
        for( auto& item : m_Tags )
        {
            jsonArray.push_back(ModelBase::toJson(item));
        }
        
        if(jsonArray.size() > 0)
        {
            val["tags"] = jsonArray;
        }
    }
    if(m_StatusIsSet)
    {
        val["status"] = ModelBase::toJson(m_Status);
    }
    

    return val;
}

void Pet::fromJson(nlohmann::json& val)
{
    if(val.find("id") != val.end())
    {
        setId(val.at("id"));
    }
    if(val.find("category") != val.end())
    {
        if(!val["category"].is_null())
        {
            std::shared_ptr<Category> newItem(new Category());
            newItem->fromJson(val["category"]);
            setCategory( newItem );
        }
        
    }
    setName(val.at("name"));
    {
        m_PhotoUrls.clear();
        nlohmann::json jsonArray;
                for( auto& item : val["photoUrls"] )
        {
            m_PhotoUrls.push_back(item);
            
        }
    }
    {
        m_Tags.clear();
        nlohmann::json jsonArray;
        if(val.find("tags") != val.end())
        {
        for( auto& item : val["tags"] )
        {
            
            if(item.is_null())
            {
                m_Tags.push_back( std::shared_ptr<Tag>(nullptr) );
            }
            else
            {
                std::shared_ptr<Tag> newItem(new Tag());
                newItem->fromJson(item);
                m_Tags.push_back( newItem );
            }
            
        }
        }
    }
    if(val.find("status") != val.end())
    {
        setStatus(val.at("status"));
        
    }
    
}


int64_t Pet::getId() const
{
    return m_Id;
}
void Pet::setId(int64_t value)
{
    m_Id = value;
    m_IdIsSet = true;
}
bool Pet::idIsSet() const
{
    return m_IdIsSet;
}
void Pet::unsetId()
{
    m_IdIsSet = false;
}
std::shared_ptr<Category> Pet::getCategory() const
{
    return m_Category;
}
void Pet::setCategory(std::shared_ptr<Category> value)
{
    m_Category = value;
    m_CategoryIsSet = true;
}
bool Pet::categoryIsSet() const
{
    return m_CategoryIsSet;
}
void Pet::unsetCategory()
{
    m_CategoryIsSet = false;
}
std::string Pet::getName() const
{
    return m_Name;
}
void Pet::setName(std::string value)
{
    m_Name = value;
    
}
std::vector<std::string>& Pet::getPhotoUrls()
{
    return m_PhotoUrls;
}
std::vector<std::shared_ptr<Tag>>& Pet::getTags()
{
    return m_Tags;
}
bool Pet::tagsIsSet() const
{
    return m_TagsIsSet;
}
void Pet::unsetTags()
{
    m_TagsIsSet = false;
}
std::string Pet::getStatus() const
{
    return m_Status;
}
void Pet::setStatus(std::string value)
{
    m_Status = value;
    m_StatusIsSet = true;
}
bool Pet::statusIsSet() const
{
    return m_StatusIsSet;
}
void Pet::unsetStatus()
{
    m_StatusIsSet = false;
}

}
}
}
}

