Exemplo n.º 1
0
        private ChatterResponse MakeRestCall(string call, RestSharp.Method method, Dictionary <string, string> postParams)
        {
            var request = new RestRequest("data/v25.0/chatter/" + call, method);

            request.AddHeader("Authorization", "Bearer " + _token.access_token);

            if (postParams != null)
            {
                foreach (KeyValuePair <String, String> entry in postParams)
                {
                    request.AddParameter(entry.Key, entry.Value);
                }
            }
            /// execute the request
            if (logService)
            {
                string content = _client.Execute(request).Content; // raw content as string
                WriteLogToFile(call + " : " + method);
                WriteLogToFile(content);
            }
            //return content;
            ChatterResponse response = _client.Execute <ChatterResponse>(request).Data;

            return(response);
        }
Exemplo n.º 2
0
 public ChatterResponse GetPreviousPage(ChatterResponse resp)
 {
     if (resp.previousPageUrl != null)
     {
         String call = resp.nextPageUrl.Substring(resp.previousPageUrl.IndexOf("/chatter/") + 9);
         return(MakeRestCall(call, Method.GET, null));
     }
     return(null);
 }
Exemplo n.º 3
0
        public ChatterResponse Unfollow(string viewerId, string ownerId)
        {
            // find the subscription for this relationship and then delete it
            ChatterResponse cresp = GetFollowing(viewerId);

            while (cresp != null && cresp.following != null)
            {
                foreach (ChatterSubscription csub in cresp.following)
                {
                    if (csub.subject.id.StartsWith(ownerId))
                    {
                        return(MakeRestCall("subscriptions/" + csub.id, Method.DELETE, null));
                    }
                }
                cresp = GetNextPage(cresp);
            }

            return(cresp);
        }
Exemplo n.º 4
0
 public ChatterResponse GetPreviousPage(ChatterResponse resp)
 {
     if (resp.previousPageUrl != null)
     {
         String call = resp.nextPageUrl.Substring(resp.previousPageUrl.IndexOf("/chatter/") + 9);
         return MakeRestCall(call, Method.GET, null);
     }
     return null;
 }