/// <summary> /// Removes one or more users from a Site Stream /// </summary> /// <param name="ctx">Twitter Context</param> /// <param name="userIDs">List of user IDs to remove from Site Stream</param> /// <param name="streamID">ID of Site Stream to remove users from</param> /// <param name="callback">Async Callback</param> /// <returns>Control Stream with CommandResponse property for Twitter's response message</returns> public static ControlStream RemoveSiteStreamUser(this TwitterContext ctx, List<ulong> userIDs, string streamID, Action<TwitterAsyncResponse<ControlStream>> callback) { if (string.IsNullOrEmpty(streamID)) throw new ArgumentNullException("streamID", "streamID is required."); var newUrl = ctx.SiteStreamUrl + "site/c/" + streamID + "/remove_user.json"; string userIDString = string.Join(",", userIDs.Select(user => user.ToString()).ToArray()); var reqProc = new ControlStreamRequestProcessor<ControlStream>(); var twitExe = ctx.TwitterExecutor; twitExe.AsyncCallback = callback; var resultsJson = twitExe.PostToTwitter( newUrl, new Dictionary<string, string> { {"user_id", userIDString} }, response => reqProc.ProcessActionResult(response, ControlStreamType.Info)); ControlStream cs = reqProc.ProcessActionResult(resultsJson, ControlStreamType.Info); return cs; }
/// <summary> /// Handles command responses /// </summary> /// <param name="responseJson">Response from Twitter</param> /// <param name="theAction">Identifies the type of response to work with.</param> /// <returns></returns> public T ProcessActionResult(string responseJson, Enum theAction) { var cs = new ControlStream { CommandResponse = responseJson }; return(cs.ItemCast(default(T))); }
/// <summary> /// Transforms twitter response into List of Blocks objects /// </summary> /// <param name="responseJson">JSON with Twitter response</param> /// <returns>List of DirectMessage</returns> public virtual List <T> ProcessResults(string responseJson) { if (string.IsNullOrWhiteSpace(responseJson)) { return(new List <T>()); } var csJson = JsonMapper.ToObject(responseJson); var ctrlStream = new ControlStream { Type = Type, UserID = UserID, StreamID = StreamID }; var csList = new List <ControlStream> { ctrlStream }; switch (Type) { case ControlStreamType.Followers: ctrlStream.Follow = new ControlStreamFollow(csJson); break; case ControlStreamType.Info: ctrlStream.Info = new ControlStreamInfo(csJson); break; default: csList = new List <ControlStream>(); break; } return(csList.OfType <T>().ToList()); }