﻿using SimpleJSON;

namespace ChatSDK
{
    /**
     * The multi-device information class.
     */
    public class DeviceInfo

    {
        /**
         * The information of other login devices.
         * 
         * With the device information, you can distinguish different types of devices.
         */
        public string Resource { get; private set; }

        /**
         * The UUID of the device.
         * 
         */
        public string DeviceUUID { get; private set; }

        /**
         * The device name.
         */
        public string DeviceName { get; private set; }


        internal DeviceInfo(string jsonString)
        {
            if (jsonString != null) {
                JSONNode jn = JSON.Parse(jsonString);
                if (!jn.IsNull && jn.IsObject)
                {
                    JSONObject jo = jn.AsObject;
                    Resource = jo["resource"];
                    DeviceUUID = jo["deviceUUID"];
                    DeviceName = jo["deviceName"];
                }
            }
        }
    }
}
