com.vzaar.api.Vzaar.getUserDetails C# (CSharp) Method

getUserDetails() public method

This API call returns the user's public details along with it's relevant metadata.
public getUserDetails ( string username ) : com.vzaar.api.UserDetails
username string is the vzaar login name for the user. Note: This must be the actual username and not the email address
return com.vzaar.api.UserDetails
        public UserDetails getUserDetails(string username)
        {
            var url = apiUrl + "/api/users/" + username + ".json";
            var response = executeRequest(url);
            var jo = (JObject)JsonConvert.DeserializeObject(response);

            var details = new UserDetails
            {
                videoCount = String.IsNullOrEmpty(jo["video_count"].ToString()) ? 0 : Int64.Parse(jo["video_count"].ToString()),
                videosTotalSize = String.IsNullOrEmpty(jo["video_total_size"].ToString()) ? 0 : Int64.Parse(jo["video_total_size"].ToString()),
                maxFileSize = String.IsNullOrEmpty(jo["max_file_size"].ToString()) ? 0 : Int64.Parse(jo["max_file_size"].ToString()),
                playCount = String.IsNullOrEmpty(jo["play_count"].ToString()) ? 0 : Int64.Parse(jo["play_count"].ToString()),
                version = (string)jo["version"],
                authorId = String.IsNullOrEmpty(jo["author_id"].ToString()) ? 0 : int.Parse(jo["author_id"].ToString()),
                authorAccountTitle = (string)jo["author_account_title"],
                authorName = (string)jo["author_name"],
                authorAccount = String.IsNullOrEmpty(jo["author_account"].ToString()) ? 0 : int.Parse(jo["author_account"].ToString()),
                authorUrl = (string)jo["author_url"],
                createdAt = DateTime.Parse((string)jo["created_at"]),
                bandwidthThisMonth = String.IsNullOrEmpty(jo["bandwidth_this_month"].ToString()) ? 0 : Int64.Parse(jo["bandwidth_this_month"].ToString())
            };

            var bandwidth = new List<UserBandwidthDetails>();
            JsonConvert.PopulateObject(jo["bandwidth"].ToString(), bandwidth);
            details.bandwidth = bandwidth;

            return details;
        }

Usage Example

Esempio n. 1
0
		static void Main(string[] args)
		{
			var api = new Vzaar("username", "token");
			var details = api.getUserDetails("skitsanos");

			Console.WriteLine("Videos owned: " + details.videoCount);
			Console.WriteLine("Storage used: " + String.Format(new FileSizeFormatProvider(), "File size: {0:fs}", details.videosTotalSize));
			Console.WriteLine("Bandwidth this month: " + String.Format(new FileSizeFormatProvider(), "File size: {0:fs}", details.bandwidthThisMonth));
		}