#region License



#endregion

using System;
using System.Globalization;

using Spring.Json;

namespace Spring.Social.Facebook.Api.Impl.Json
{
	/// <summary>
	/// JSON deserializer for Account. 
	/// </summary>
	/// <author>Craig Walls</author>
	/// <author>SplendidCRM (.NET)</author>
	class AccountDeserializer : IJsonDeserializer
	{
		public object Deserialize(JsonValue json, JsonMapper mapper)
		{
			Account account = null;
			if ( json != null && !json.IsNull )
			{
				account = new Account();
				account.ID          = json.ContainsName("id"          ) ? json.GetValue<string>("id"          ) : String.Empty;
				account.Name        = json.ContainsName("name"        ) ? json.GetValue<string>("name"        ) : String.Empty;
				account.Category    = json.ContainsName("category"    ) ? json.GetValue<string>("category"    ) : String.Empty;
				account.AccessToken = json.ContainsName("access_token") ? json.GetValue<string>("access_token") : String.Empty;
			}
			return account;
		}
	}
}
