package com.yyrh.constant;

import android.text.TextUtils;

import com.yyrh.utils.Utils;

import org.json.JSONObject;

public class LoginData {



    public String uname = "";

    public String token = "";

    public String rn_bd = "";

    public JSONObject links = null;

    public String channel_uid = "";

    public int is_rn = 0;


    public String solo_email = "";

    public String user_center = "";

    public String authentication = "";

    public String login_token = "";

    public static LoginData toBean(JSONObject json){
        if (TextUtils.isEmpty(json.toString())) {
            return null;
        }
        LoginData loginData = new LoginData();

        loginData.token = json.optString("token");

        loginData.uname = json.optString("uname");

        loginData.channel_uid  = json.optString("channel_uid");

        loginData.rn_bd = json.optString("rn_bd");

        loginData.is_rn = json.optInt("is_rn");

        loginData.links = json.optJSONObject("links");

        loginData.login_token = json.optString("login_token");

        if (loginData.links == null){
            loginData.solo_email = "";
            loginData.user_center = "";
        }else {
            loginData.solo_email = loginData.links.optString("solo_email");
            loginData.user_center = loginData.links.optString("user_center");
            loginData.authentication = loginData.links.optString("authentication");
        }




        return loginData;

    }

    @Override
    public String toString() {
        return "LoginData{" +
                "uname='" + uname + '\'' +
                ", token='" + token + '\'' +
                ", rn_bd='" + rn_bd + '\'' +
                ", links=" + links +
                ", channel_uid='" + channel_uid + '\'' +
                ", is_rn=" + is_rn +
                ", solo_email='" + solo_email + '\'' +
                ", user_center='" + user_center + '\'' +
                ", authentication='" + authentication + '\'' +
                ", login_token='" + login_token + '\'' +
                '}';
    }
}
