using System.Collections.ObjectModel;
using VkNet.Utils;

namespace VkNet.Model
{
	/// <summary>
	/// Ïîëüçîâàòåëè îíëàéí ïî òèïó (ìîáèëüíûå / ïê)
	/// </summary>
	public class FriendOnline
	{
		/// <summary>
		/// Online ñ ÏÊ
		/// </summary>
		public ReadOnlyCollection<long> Online { get; set; }

		/// <summary>
		/// Online ñ ìîáèëüíîãî óñòðîéñòâà.
		/// </summary>
		public ReadOnlyCollection<long> MobileOnline { get; set; }

		/// <summary>
		/// Ðàçîáðàòü èç json.
		/// </summary>
		/// <param name="response">Îòâåò ñåðâåðà.</param>
		/// <returns></returns>
		internal static FriendOnline FromJson(VkResponse response)
		{
			VkResponseArray mobile = response["online_mobile"];
			VkResponseArray pc = response["online"];
			var item = new FriendOnline
			{
				MobileOnline = mobile.ToReadOnlyCollectionOf<long>(x => x),
				Online = pc.ToReadOnlyCollectionOf<long>(x => x)
			};

			return item;
		}
	}
}