public Task <MessageListAPI> GetStreamMessages(String streamId, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().GetStreamMessages(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.GetStreamMessages"), this.GetWho(), streamId, socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task <String> FollowStream(String streamId, String follow, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().FollowStream(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.FollowStream"), this.GetWho(), streamId, Boolean.Parse(follow), socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task<String> LikeMessage(String streamId, String messageId, String like, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "LikeMessage - Not implemented.");
 }
 public Task<MessageListAPI> GetStreamMessages(String streamId, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "GetStreamMessages - Not implemented.");
 }
 public List<WhoAPI> GetStreamFollowers(String streamId, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "GetStreamFollowers - Not implemented.");
 }
 public WhoAPI GetUserInfo(String streamId, String userId, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "GetUserInfo - Not implemented.");
 }
 public String CreateStream(SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "CreateStream - Not implemented.");
 }
        /// <summary>
        /// This is a general purpose method for getting user information from chatter.
        /// </summary>
        public WhoAPI GetUserInfoById(INotifier notifier, IAuthenticatedWho authenticatedWho, String streamId, String id, SocialServiceRequestAPI socialServiceRequestAPI)
        {
            List <WhoAPI>       stuffAuthenticatedUserIsFollowing = null;
            ChatterUserInfo     chatterUserInfo     = null;
            HttpResponseMessage httpResponseMessage = null;
            HttpClient          httpClient          = null;
            WhoAPI who            = null;
            String chatterBaseUrl = null;
            String endpointUrl    = null;
            String adminEmail     = null;

            if (authenticatedWho == null)
            {
                throw new ArgumentNullException("BadRequest", "AuthenticatedWho is null.");
            }

            if (id == null ||
                id.Trim().Length == 0)
            {
                throw new ArgumentNullException("BadRequest", "Id for user is null or blank.");
            }

            if (streamId == null ||
                streamId.Trim().Length == 0)
            {
                throw new ArgumentNullException("BadRequest", "Stream identifier is null or blank.");
            }

            if (socialServiceRequestAPI == null)
            {
                throw new ArgumentNullException("BadRequest", "SocialServiceRequest is null.");
            }

            // We only need the chatter base url for this call
            chatterBaseUrl = ValueUtils.GetContentValue(SalesforceServiceSingleton.SERVICE_VALUE_CHATTER_BASE_URL, socialServiceRequestAPI.configurationValues, true);
            adminEmail     = ValueUtils.GetContentValue(SalesforceServiceSingleton.SERVICE_VALUE_ADMIN_EMAIL, socialServiceRequestAPI.configurationValues, true);

            // We enclose the request in a for loop to handle http errors
            for (int i = 0; i < SalesforceHttpUtils.MAXIMUM_RETRIES; i++)
            {
                try
                {
                    // Create a new client object
                    httpClient = SalesforceHttpUtils.CreateHttpClient(SalesforceHttpUtils.GetAuthenticationDetails(authenticatedWho.Token).Token);

                    // Create the endpoint url
                    endpointUrl = chatterBaseUrl + SalesforceServiceSingleton.CHATTER_URI_PART_API_VERSION + SalesforceServiceSingleton.CHATTER_URI_PART_USERS + "/" + id;

                    // Call the get method on the chatter API to grab the user information
                    httpResponseMessage = httpClient.GetAsync(endpointUrl).Result;

                    // Check the status of the response and respond appropriately
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        // Grab the chatter user info from the result
                        chatterUserInfo = httpResponseMessage.Content.ReadAsAsync <ChatterUserInfo>().Result;

                        // Convert the chatter user info over to a who
                        who = this.ChatterUserInfoToWhoAPI(chatterUserInfo);

                        // Get the stuff this user is following
                        stuffAuthenticatedUserIsFollowing = this.GetStuffAuthenticatedUserIsFollowing(httpClient, chatterBaseUrl);

                        // Check to see if the authenticated user is also the id
                        if (id.Equals(SalesforceServiceSingleton.CHATTER_ME, StringComparison.InvariantCultureIgnoreCase) == false)
                        {
                            // Check to see if the currently authenticated user is following the provided user id
                            if (stuffAuthenticatedUserIsFollowing != null &&
                                stuffAuthenticatedUserIsFollowing.Any(x => x.id == id) == true)
                            {
                                // The authenticated user is following the provided user id
                                who.isFollower = true;
                            }
                        }
                        else
                        {
                            // If the authenticated user is the same as the provided id, the "is following" refers to the stream
                            if (stuffAuthenticatedUserIsFollowing != null &&
                                stuffAuthenticatedUserIsFollowing.Any(x => x.id == streamId) == true)
                            {
                                // We are following this stream
                                who.isFollower = true;
                            }
                        }

                        // We successfully executed the request, we can break out of the retry loop
                        break;
                    }
                    else
                    {
                        // Make sure we handle the lack of success properly
                        BaseHttpUtils.HandleUnsuccessfulHttpResponseMessage(notifier, authenticatedWho, i, httpResponseMessage, endpointUrl);
                    }
                }
                catch (Exception exception)
                {
                    // Make sure we handle the exception properly
                    BaseHttpUtils.HandleHttpException(notifier, authenticatedWho, i, exception, endpointUrl);
                }
                finally
                {
                    // Clean up the objects from the request
                    BaseHttpUtils.CleanUpHttp(httpClient, null, httpResponseMessage);
                }
            }

            return(who);
        }
        /// <summary>
        /// This method is used to get the user info for the provided user id in docordo.
        /// </summary>
        public WhoAPI GetUserInfo(IAuthenticatedWho authenticatedWho, String streamId, String id, SocialServiceRequestAPI serviceRequest)
        {
            WhoAPI whoAPI = null;

            return whoAPI;
        }
        /// <summary>
        /// This method allows the user to follow the stream in chatter.
        /// </summary>
        public async Task<String> FollowStream(IAuthenticatedWho authenticatedWho, String streamId, Boolean follow, SocialServiceRequestAPI socialServiceRequest)
        {
            String response = null;

            return response;
        }
        /// <summary>
        /// This method allows the user to search for users by name in chatter.
        /// </summary>
        public async Task<List<MentionedWhoAPI>> SearchUsersByName(IAuthenticatedWho authenticatedWho, String streamId, String name, SocialServiceRequestAPI socialServiceRequest)
        {
            List<MentionedWhoAPI> mentionedUsers = null;

            return mentionedUsers;
        }
        /// <summary>
        /// This method allows the user to like messages in the stream in chatter.
        /// </summary>
        public async Task<String> LikeMessage(IAuthenticatedWho authenticatedWho, String streamId, String messageId, Boolean like, SocialServiceRequestAPI socialServiceRequest)
        {
            String response = null;

            return response;
        }
        /// <summary>
        /// This method is used to get the list of stream messages in salesforce.
        /// </summary>
        public async Task<MessageListAPI> GetStreamMessages(IAuthenticatedWho authenticatedWho, String streamId, SocialServiceRequestAPI socialServiceRequest)
        {
            MessageListAPI messageList = null;

            return messageList;
        }
        /// <summary>
        /// This method is used to get the list of stream followers in salesforce.
        /// </summary>
        public List<WhoAPI> GetStreamFollowers(IAuthenticatedWho authenticatedWho, String streamId, SocialServiceRequestAPI socialServiceRequest)
        {
            List<WhoAPI> whos = null;

            return whos;
        }
 public Task<String> FollowStream(String streamId, String follow, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "FollowStream - Not implemented.");
 }
 public Task <List <MentionedWhoAPI> > SearchUsersByName(String streamId, String name, SocialServiceRequestAPI socialServiceRequest)
 {
     try
     {
         return(SalesforceServiceSingleton.GetInstance().SearchUsersByName(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.SearchUsersByName"), this.GetWho(), streamId, name, socialServiceRequest));
     }
     catch (Exception exception)
     {
         throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
     }
 }
 public Task<List<MentionedWhoAPI>> SearchUsersByName(String streamId, String name, SocialServiceRequestAPI socialServiceRequest)
 {
     throw ErrorUtils.GetWebException(HttpStatusCode.BadRequest, "SearchUsersByName - Not implemented.");
 }
        /// <summary>
        /// This method is used to create a new activity stream in salesforce based on the provided configuration.
        /// </summary>
        public String CreateStream(IAuthenticatedWho authenticatedWho, SocialServiceRequestAPI socialServiceRequestAPI)
        {
            String streamId = null;

            return streamId;
        }