/**
 * Nsmf_PDUSession
 * SMF PDU Session Service. © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. 
 *
 * The version of the OpenAPI document: 1.1.0.alpha-1
 *
 * NOTE: This class is auto generated by OpenAPI-Generator 4.1.1-SNAPSHOT.
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */



#include "ProblemDetails_2.h"

namespace oai {
namespace smf {
namespace model {




ProblemDetails_2::ProblemDetails_2()
{
    m_Type = utility::conversions::to_string_t("");
    m_TypeIsSet = false;
    m_Title = utility::conversions::to_string_t("");
    m_TitleIsSet = false;
    m_Status = 0;
    m_StatusIsSet = false;
    m_Detail = utility::conversions::to_string_t("");
    m_DetailIsSet = false;
    m_Instance = utility::conversions::to_string_t("");
    m_InstanceIsSet = false;
    m_Cause = utility::conversions::to_string_t("");
    m_CauseIsSet = false;
    m_InvalidParamsIsSet = false;
    m_SupportedFeatures = utility::conversions::to_string_t("");
    m_SupportedFeaturesIsSet = false;
}

ProblemDetails_2::~ProblemDetails_2()
{
}

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

web::json::value ProblemDetails_2::toJson() const
{
    web::json::value val = web::json::value::object();

    if(m_TypeIsSet)
    {
        val[utility::conversions::to_string_t("type")] = ModelBase::toJson(m_Type);
    }
    if(m_TitleIsSet)
    {
        val[utility::conversions::to_string_t("title")] = ModelBase::toJson(m_Title);
    }
    if(m_StatusIsSet)
    {
        val[utility::conversions::to_string_t("status")] = ModelBase::toJson(m_Status);
    }
    if(m_DetailIsSet)
    {
        val[utility::conversions::to_string_t("detail")] = ModelBase::toJson(m_Detail);
    }
    if(m_InstanceIsSet)
    {
        val[utility::conversions::to_string_t("instance")] = ModelBase::toJson(m_Instance);
    }
    if(m_CauseIsSet)
    {
        val[utility::conversions::to_string_t("cause")] = ModelBase::toJson(m_Cause);
    }
    {
        std::vector<web::json::value> jsonArray;
        for( auto& item : m_InvalidParams )
        {
            jsonArray.push_back(ModelBase::toJson(item));
        }
        if(jsonArray.size() > 0)
        {
            val[utility::conversions::to_string_t("invalidParams")] = web::json::value::array(jsonArray);
        }
    }
    if(m_SupportedFeaturesIsSet)
    {
        val[utility::conversions::to_string_t("supportedFeatures")] = ModelBase::toJson(m_SupportedFeatures);
    }

    return val;
}

void ProblemDetails_2::fromJson(const web::json::value& val)
{
    if(val.has_field(utility::conversions::to_string_t("type")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type"));
        if(!fieldValue.is_null())
        {
            setType(ModelBase::stringFromJson(fieldValue));
        }
    }
    if(val.has_field(utility::conversions::to_string_t("title")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("title"));
        if(!fieldValue.is_null())
        {
            setTitle(ModelBase::stringFromJson(fieldValue));
        }
    }
    if(val.has_field(utility::conversions::to_string_t("status")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
        if(!fieldValue.is_null())
        {
            setStatus(ModelBase::int32_tFromJson(fieldValue));
        }
    }
    if(val.has_field(utility::conversions::to_string_t("detail")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("detail"));
        if(!fieldValue.is_null())
        {
            setDetail(ModelBase::stringFromJson(fieldValue));
        }
    }
    if(val.has_field(utility::conversions::to_string_t("instance")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("instance"));
        if(!fieldValue.is_null())
        {
            setInstance(ModelBase::stringFromJson(fieldValue));
        }
    }
    if(val.has_field(utility::conversions::to_string_t("cause")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("cause"));
        if(!fieldValue.is_null())
        {
            setCause(ModelBase::stringFromJson(fieldValue));
        }
    }
    {
        m_InvalidParams.clear();
        std::vector<web::json::value> jsonArray;
        if(val.has_field(utility::conversions::to_string_t("invalidParams")))
        {
        for( auto& item : val.at(utility::conversions::to_string_t("invalidParams")).as_array() )
        {
            if(item.is_null())
            {
                m_InvalidParams.push_back( std::shared_ptr<InvalidParam_2>(nullptr) );
            }
            else
            {
                std::shared_ptr<InvalidParam_2> newItem(new InvalidParam_2());
                newItem->fromJson(item);
                m_InvalidParams.push_back( newItem );
            }
        }
        }
    }
    if(val.has_field(utility::conversions::to_string_t("supportedFeatures")))
    {
        const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("supportedFeatures"));
        if(!fieldValue.is_null())
        {
            setSupportedFeatures(ModelBase::stringFromJson(fieldValue));
        }
    }
}

void ProblemDetails_2::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
    utility::string_t namePrefix = prefix;
    if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
    {
        namePrefix += utility::conversions::to_string_t(".");
    }

    if(m_TypeIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("type"), m_Type));
    }
    if(m_TitleIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("title"), m_Title));
    }
    if(m_StatusIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("status"), m_Status));
    }
    if(m_DetailIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("detail"), m_Detail));
    }
    if(m_InstanceIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("instance"), m_Instance));
    }
    if(m_CauseIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("cause"), m_Cause));
    }
    {
        std::vector<web::json::value> jsonArray;
        for( auto& item : m_InvalidParams )
        {
            jsonArray.push_back(ModelBase::toJson(item));
        }
        
        if(jsonArray.size() > 0)
        {
            multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("invalidParams"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
        }
    }
    if(m_SupportedFeaturesIsSet)
    {
        multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("supportedFeatures"), m_SupportedFeatures));
    }
}

void ProblemDetails_2::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
    utility::string_t namePrefix = prefix;
    if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
    {
        namePrefix += utility::conversions::to_string_t(".");
    }

    if(multipart->hasContent(utility::conversions::to_string_t("type")))
    {
        setType(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("type"))));
    }
    if(multipart->hasContent(utility::conversions::to_string_t("title")))
    {
        setTitle(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("title"))));
    }
    if(multipart->hasContent(utility::conversions::to_string_t("status")))
    {
        setStatus(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status"))));
    }
    if(multipart->hasContent(utility::conversions::to_string_t("detail")))
    {
        setDetail(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("detail"))));
    }
    if(multipart->hasContent(utility::conversions::to_string_t("instance")))
    {
        setInstance(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("instance"))));
    }
    if(multipart->hasContent(utility::conversions::to_string_t("cause")))
    {
        setCause(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("cause"))));
    }
    {
        m_InvalidParams.clear();
        if(multipart->hasContent(utility::conversions::to_string_t("invalidParams")))
        {

        web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("invalidParams"))));
        for( auto& item : jsonArray.as_array() )
        {
            if(item.is_null())
            {
                m_InvalidParams.push_back( std::shared_ptr<InvalidParam_2>(nullptr) );
            }
            else
            {
                std::shared_ptr<InvalidParam_2> newItem(new InvalidParam_2());
                newItem->fromJson(item);
                m_InvalidParams.push_back( newItem );
            }
        }
        }
    }
    if(multipart->hasContent(utility::conversions::to_string_t("supportedFeatures")))
    {
        setSupportedFeatures(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("supportedFeatures"))));
    }
}

utility::string_t ProblemDetails_2::getType() const
{
    return m_Type;
}

void ProblemDetails_2::setType(const utility::string_t& value)
{
    m_Type = value;
    m_TypeIsSet = true;
}

bool ProblemDetails_2::typeIsSet() const
{
    return m_TypeIsSet;
}

void ProblemDetails_2::unsetType()
{
    m_TypeIsSet = false;
}

utility::string_t ProblemDetails_2::getTitle() const
{
    return m_Title;
}

void ProblemDetails_2::setTitle(const utility::string_t& value)
{
    m_Title = value;
    m_TitleIsSet = true;
}

bool ProblemDetails_2::titleIsSet() const
{
    return m_TitleIsSet;
}

void ProblemDetails_2::unsetTitle()
{
    m_TitleIsSet = false;
}

int32_t ProblemDetails_2::getStatus() const
{
    return m_Status;
}

void ProblemDetails_2::setStatus(int32_t value)
{
    m_Status = value;
    m_StatusIsSet = true;
}

bool ProblemDetails_2::statusIsSet() const
{
    return m_StatusIsSet;
}

void ProblemDetails_2::unsetStatus()
{
    m_StatusIsSet = false;
}

utility::string_t ProblemDetails_2::getDetail() const
{
    return m_Detail;
}

void ProblemDetails_2::setDetail(const utility::string_t& value)
{
    m_Detail = value;
    m_DetailIsSet = true;
}

bool ProblemDetails_2::detailIsSet() const
{
    return m_DetailIsSet;
}

void ProblemDetails_2::unsetDetail()
{
    m_DetailIsSet = false;
}

utility::string_t ProblemDetails_2::getInstance() const
{
    return m_Instance;
}

void ProblemDetails_2::setInstance(const utility::string_t& value)
{
    m_Instance = value;
    m_InstanceIsSet = true;
}

bool ProblemDetails_2::instanceIsSet() const
{
    return m_InstanceIsSet;
}

void ProblemDetails_2::unsetInstance()
{
    m_InstanceIsSet = false;
}

utility::string_t ProblemDetails_2::getCause() const
{
    return m_Cause;
}

void ProblemDetails_2::setCause(const utility::string_t& value)
{
    m_Cause = value;
    m_CauseIsSet = true;
}

bool ProblemDetails_2::causeIsSet() const
{
    return m_CauseIsSet;
}

void ProblemDetails_2::unsetCause()
{
    m_CauseIsSet = false;
}

std::vector<std::shared_ptr<InvalidParam_2>>& ProblemDetails_2::getInvalidParams()
{
    return m_InvalidParams;
}

void ProblemDetails_2::setInvalidParams(const std::vector<std::shared_ptr<InvalidParam_2>>& value)
{
    m_InvalidParams = value;
    m_InvalidParamsIsSet = true;
}

bool ProblemDetails_2::invalidParamsIsSet() const
{
    return m_InvalidParamsIsSet;
}

void ProblemDetails_2::unsetInvalidParams()
{
    m_InvalidParamsIsSet = false;
}

utility::string_t ProblemDetails_2::getSupportedFeatures() const
{
    return m_SupportedFeatures;
}

void ProblemDetails_2::setSupportedFeatures(const utility::string_t& value)
{
    m_SupportedFeatures = value;
    m_SupportedFeaturesIsSet = true;
}

bool ProblemDetails_2::supportedFeaturesIsSet() const
{
    return m_SupportedFeaturesIsSet;
}

void ProblemDetails_2::unsetSupportedFeatures()
{
    m_SupportedFeaturesIsSet = false;
}

}
}
}


