/// <summary>
        /// Get profile information for a user.
        /// </summary>
        /// <param name="user">The user to get profile information for.</param>
        /// <param name="decorations">The additional detail to include in the response</param>
        /// <returns>Social profile information for the user.</returns>
        public Task <XboxSocialUser> GetProfileInfo(XboxLiveUser user, SocialManagerExtraDetailLevel decorations)
        {
            string path = "/users/me/people/xuids(" + user.XboxUserId + ")";

            path += "/decoration/";
            if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None)
            {
                if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory))
                {
                    path += "titlehistory(" + this.appConfig.TitleId + "),";
                }

                if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor))
                {
                    path += "preferredcolor,";
                }
            }
            // We always ask for presence detail.
            path += "presenceDetail";

            XboxLiveHttpRequest request = XboxLiveHttpRequest.Create(
                HttpMethod.Get,
                this.peopleHubEndpoint,
                path);

            request.ContractVersion = "1";
            request.XboxLiveAPI     = XboxLiveAPIName.GetProfileInfo;
            request.CallerContext   = "SocialManager";

            return(request.GetResponseWithAuth(user)
                   .ContinueWith(responseTask =>
            {
                if (responseTask.IsFaulted)
                {
                    throw new XboxException("PeopleHub call failed with " + responseTask.Exception);
                }

                var response = responseTask.Result;

                if (response.HttpStatus != 200)
                {
                    throw new XboxException("PeopleHub call failed with " + response.HttpStatus);
                }

                JObject responseBody = JObject.Parse(response.ResponseBodyString);
                List <XboxSocialUser> users = responseBody["people"].ToObject <List <XboxSocialUser> >();
                return users[0];
            }));
        }
        private string CreateSocialGraphSubpath(string xboxUserId, SocialManagerExtraDetailLevel decorations, string relationshipType, bool isBatch)
        {
            StringBuilder path = new StringBuilder();

            path.Append("/users/xuid(");
            path.Append(xboxUserId);
            path.Append(")/people");
            if (!string.IsNullOrEmpty(relationshipType))
            {
                path.Append("/");
                path.Append(relationshipType);
            }

            if (isBatch)
            {
                path.Append("/batch");
            }

            if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None)
            {
                path.Append("/decoration/");

                if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory))
                {
                    path.Append("titlehistory(" + this.appConfig.TitleId + "),");
                }

                if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor))
                {
                    path.Append("preferredcolor,");
                }

                path.Append("presenceDetail");
            }

            return(path.ToString());
        }
        /// <summary>
        /// Get profile information for a user.
        /// </summary>
        /// <param name="user">The user to get profile information for.</param>
        /// <param name="decorations">The additional detail to include in the response</param>
        /// <returns>Social profile information for the user.</returns>
        public Task <XboxSocialUser> GetProfileInfo(XboxLiveUser user, SocialManagerExtraDetailLevel decorations)
        {
            string path = "/users/me/people/xuids(" + user.XboxUserId + ")";

            path += "/decoration/";
            if ((decorations | SocialManagerExtraDetailLevel.None) != SocialManagerExtraDetailLevel.None)
            {
                if (decorations.HasFlag(SocialManagerExtraDetailLevel.TitleHistory))
                {
                    path += "titlehistory(" + this.appConfig.TitleId + "),";
                }

                if (decorations.HasFlag(SocialManagerExtraDetailLevel.PreferredColor))
                {
                    path += "preferredcolor,";
                }
            }
            // We always ask for presence detail.
            path += "presenceDetail";

            XboxLiveHttpRequest request = XboxLiveHttpRequest.Create(
                this.httpCallSettings,
                HttpMethod.Get,
                this.peopleHubHost,
                path);

            request.ContractVersion = "1";

            return(request.GetResponseWithAuth(user, HttpCallResponseBodyType.JsonBody)
                   .ContinueWith(responseTask =>
            {
                var response = responseTask.Result;
                JObject responseBody = JObject.Parse(response.ResponseBodyString);
                List <XboxSocialUser> users = responseBody["people"].ToObject <List <XboxSocialUser> >();
                return users[0];
            }));
        }