/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2021-11-04 09:39:46
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-02-23 10:24:10
 */

#include <iostream>
using namespace std;

#include <rapidjson/document.h>
#include <rapidjson/rapidjson.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>

class NettyHttpToken
{
public:
    std::string authToken = "";
    std::string expiration = "";
    std::string refreshToken = "";
    
public:
    NettyHttpToken() {}
    ~NettyHttpToken() {}
    
    /**
     * @description: json反序列为对象
     * @param {*}
     * @return {*}
     */    
    bool jsonToObject(const rapidjson::Value& object){
        const auto end = object.MemberEnd();
        if(end == object.FindMember("authToken") || !object["authToken"].IsString()){
            return false;
        }else{
            authToken = object["authToken"].GetString();
        }
        if(end == object.FindMember("expiration") || !object["expiration"].IsString()){
            return false;
        }else{
            expiration = object["expiration"].GetString();
        }
        if(end == object.FindMember("refreshToken") || !object["refreshToken"].IsString()){
            return false;
        }else{
            refreshToken = object["refreshToken"].GetString();
        }
        return true;
    }
};


