﻿namespace Yodo1.FanCraft
{
    using System.Collections.Generic;

    public class FanCraftUserInfo
    {
        public string Uid { get; private set; }
        public string GameUserId { get; private set; }
        public bool IsAnonymous { get; private set; } //Is the user anonymous or not
        public bool DeviceTokenSet { get; private set; } //If the device token has been set for the user

        public FanCraftUserInfo(Dictionary<string, object> dict)
        {
            if (dict.ContainsKey("uid"))
            {
                Uid = dict["uid"].ToString();
            }

            if (dict.ContainsKey("gameUserId"))
            {
                GameUserId = dict["gameUserId"].ToString();
            }

            if (dict.ContainsKey("game_user_id"))
            {
                GameUserId = dict["game_user_id"].ToString();
            }

            if (dict.ContainsKey("isAnonymous"))
            {
                IsAnonymous = bool.Parse(dict["isAnonymous"].ToString());
            }

            if (dict.ContainsKey("is_anonymous"))
            {
                IsAnonymous = bool.Parse(dict["is_anonymous"].ToString());
            }

            if (dict.ContainsKey("deviceTokenSet"))
            {
                DeviceTokenSet = bool.Parse(dict["deviceTokenSet"].ToString());
            }

            if (dict.ContainsKey("device_token_set"))
            {
                DeviceTokenSet = bool.Parse(dict["device_token_set"].ToString());
            }
        }
    }
}