Beispiel #1
0
        /// <summary>
        /// Returns the current configuration used by Twitter including twitter.com slugs which are not usernames, maximum photo resolutions, and t.co URL lengths.
        /// </summary>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/rest/reference/get/help/configuration </remarks>
        public async static Task <Configuration> GetConfiguration(this IUserSession session)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create();
            return(await session.GetAsync(TwitterApi.Resolve("/1.1/help/configuration.json"), parameters).ContinueWith(c => c.MapToSingle <Configuration>()));
        }
Beispiel #2
0
        public TwitterParametersCollection ChangeSearchParameters(string track = null, string follow = null, string locations = null, string filterlevel = "none", string language = "en")
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(stall_warnings: false, delimited: false);

            if (track != null)
            {
                parameters.CreateCommaDelimitedList("track", new List <string> {
                    track
                });
            }
            if (follow != null)
            {
                parameters.CreateCommaDelimitedList("follow", new List <string> {
                    follow
                });
            }
            if (locations != null)
            {
                parameters.CreateCommaDelimitedList("locations", new List <string> {
                    locations
                });
            }

            parameters.Add("filter_level", filterlevel);
            parameters.Add("language", language);

            return(parameters);
        }
Beispiel #3
0
        /// <summary>
        /// Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.
        /// </summary>
        /// <param name="name">Full name associated with the profile. Maximum of 20 characters.</param>
        /// <param name="profileUrl">URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.</param>
        /// <param name="location">The city or country describing where the user of the account is located.</param>
        /// <param name="description">A description of the user owning the account. Maximum of 160 characters.</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/account/update_profile </remarks>
        public static async Task <User> ChangeAccountProfile(this IUserSession session, string name = "",
                                                             string profileUrl = "", string location = "", string description = "")
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, skip_status: true);

            // first 20 chars
            if (!string.IsNullOrWhiteSpace(name))
            {
                parameters.Add("name", name.TrimAndTruncate(20));
            }

            // first 100 chars
            if (!string.IsNullOrWhiteSpace(profileUrl))
            {
                parameters.Add("purl", profileUrl.TrimAndTruncate(100));
            }

            // first 30 chars
            if (!string.IsNullOrWhiteSpace(location))
            {
                parameters.Add("location", location.TrimAndTruncate(30));
            }

            // first 160 chars
            if (!string.IsNullOrWhiteSpace(description))
            {
                parameters.Add("description", description.TrimAndTruncate(160));
            }

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/account/update_profile.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <User>()));
        }
        /// <summary>
        /// Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of tweets to try and retrieve, up to a maximum of 200 per distinct request</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <param name="excludeReplies">This parameter will prevent replies from appearing in the returned timeline. </param>
        /// <param name="includeRetweets">When set to false, the timeline will strip any native retweets</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline </remarks>
        public async static Task<TwitterResponseCollection<Tweet>> GetUserTimeline(this ITwitterSession session, string screenName = "", long userId = 0, long sinceId = 0, long maxId = 0, int count = 200, bool excludeReplies = true, bool includeRetweets = true)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId, screen_name:screenName);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/user_timeline.json"), parameters)
                          .ContinueWith(c => c.MapToMany<Tweet>());
        }
        /// <summary>
        /// Returns the most recent tweets authored by the authenticating user that have been retweeted by others. 
        /// </summary>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of records to retrieve. Must be less than or equal to 100. If omitted, 20 will be assumed.</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/retweets_of_me </remarks>
        public async static Task<TwitterResponseCollection<Tweet>> GetRetweetsOfMe(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/retweets_of_me.json"), parameters)
                          .ContinueWith(c => c.MapToMany<Tweet>());
        }
        /// <summary>
        /// Returns a direct message sent to the authenticating user.
        /// </summary>
        /// <param name="Id">ID of direct message to return</param>
        /// <returns>(awaitable) Get A DirectMessage sent/received the session's authenticated user</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/show </remarks>
        public async static Task<DirectMessage> GetDirectMessageSingle(this IUserSession session, long Id)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(id: Id, full_text:true);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/show.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<DirectMessage>());
        }
        /// <summary>
        /// Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
        /// </summary>
        /// <returns></returns>
        public static async Task<User> GetVerifyCredentials(this IUserSession session) 
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(include_entities: true);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/account/verify_credentials.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<User>());
        }
        /// <summary>
        /// Returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user.
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/friendships/incoming </remarks>
        public async static Task <FriendsFollowersIDsCursored> GetFriendshipRequestsIncoming(this IUserSession session, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(cursor: cursor);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/friendships/incoming.json"), parameters)
                   .ContinueWith(t => t.MapToSingle <FriendsFollowersIDsCursored>()));
        }
        /// <summary>
        /// Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="userId">The ID of the user to remove from the list. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <param name="screenName">The screen name of the user for whom to remove from the list. Helpful for disambiguating when a valid screen name is also a user ID.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy </remarks>
        public static async Task<TwitterSuccess> DeleteUserFromList(this IUserSession session, long listId = 0, string slug = "",
            long userId = 0, string screenName = "", string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, user_id: userId, screen_name: screenName);

            return await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy"), parameters)
                          .ContinueWith(c => c.MapToTwitterSuccess());
        }
Beispiel #10
0
        /// <summary>
        /// Returns a direct message sent to the authenticating user.
        /// </summary>
        /// <param name="Id">ID of direct message to return</param>
        /// <returns>(awaitable) Get A DirectMessage sent/received the session's authenticated user</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/show </remarks>
        public async static Task <DirectMessage> GetDirectMessageSingle(this IUserSession session, long Id)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(id: Id);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/show.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <DirectMessage>()));
        }
Beispiel #11
0
        /// <summary>
        /// Deletes a sent direct message
        /// </summary>
        /// <param name="Id">ID of the direct message to delete</param>
        /// <returns>TwitterSuccess (true) if deletion worked</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy </remarks>
        public async static Task <TwitterSuccess> DeleteDirectMessage(this IUserSession session, long Id)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(id: Id);

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/direct_messages/destroy.json"), parameters)
                   .ContinueWith(c => c.MapToTwitterSuccess()));
        }
        /// <summary>
        /// Returns the most recent direct messages sent by the authenticating user.
        /// </summary>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID</param>
        /// <param name="count">Specifies the number of direct messages to try and retrieve, up to a maximum of 200</param>
        /// <returns>(awaitable) IEnumerable of DirectMessages Sent by the session's authenticated user</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent </remarks>
        public async static Task<TwitterResponseCollection<DirectMessage>> GetDirectMessagesSent(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(include_entities: true, count: count, since_id: sinceId,
                max_id: maxId, full_text:true);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/sent.json"), parameters)
                          .ContinueWith(c => c.MapToMany<DirectMessage>());
        }
        /// <summary>
        /// https://dev.twitter.com/docs/api/1.1/post/favorites/destroy
        /// Un-favourites a given tweet
        /// </summary>
        /// <param name="tweet">Tweet for to favourite</param>
        /// <returns></returns>
        public async static Task<Tweet> DeleteFavourite(this IUserSession session, Tweet tweet)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(id: tweet.Id);

            var url = TwitterApi.Resolve("/1.1/favorites/destroy.json");
            return await session.PostAsync(url, parameters)
                          .ContinueWith(c => c.MapToSingle<Tweet>());
        }
Beispiel #14
0
        /// <summary>
        /// Returns the most recent tweets authored by the authenticating user that have been retweeted by others.
        /// </summary>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of records to retrieve. Must be less than or equal to 100. If omitted, 20 will be assumed.</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/retweets_of_me </remarks>
        public async static Task <TwitterResponseCollection <Tweet> > GetRetweetsOfMe(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/retweets_of_me.json"), parameters)
                   .ContinueWith(c => c.MapToMany <Tweet>()));
        }
Beispiel #15
0
        /// <summary>
        /// Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of tweets to try and retrieve, up to a maximum of 200 per distinct request</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <param name="excludeReplies">This parameter will prevent replies from appearing in the returned timeline. </param>
        /// <param name="includeRetweets">When set to false, the timeline will strip any native retweets</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline </remarks>
        public async static Task <TwitterResponseCollection <Tweet> > GetUserTimeline(this ITwitterSession session, string screenName = "", long userId = 0, long sinceId = 0, long maxId = 0, int count = 200, bool excludeReplies = true, bool includeRetweets = true)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, include_rts: true, count: count, since_id: sinceId, max_id: maxId, screen_name: screenName);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/user_timeline.json"), parameters)
                   .ContinueWith(c => c.MapToMany <Tweet>()));
        }
Beispiel #16
0
        /// <summary>
        /// Returns a collection of user objects that the authenticating user is blocking.
        /// </summary>
        /// <param name="cursor">Causes the list of blocked users to be broken into pages of no more than 5000 IDs at a time.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/blocks/list </remarks>
        public static async Task <UserListDetailedCursored> GetBlockList(this IUserSession session, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(cursor: cursor);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/blocks/list.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <UserListDetailedCursored>()));
        }
Beispiel #17
0
        /// <summary>
        /// Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
        /// </summary>
        /// <returns></returns>
        public static async Task <User> GetVerifyCredentials(this IUserSession session)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/account/verify_credentials.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <User>()));
        }
        /// <summary>
        /// https://dev.twitter.com/docs/api/1.1/get/favorites/list
        /// Returns the count most recent Tweets favorited by the authenticating or specified user.
        /// If user_id and screen_name is left blank, current auth'd user favourites are returned
        /// Entities are always returned
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for</param>
        /// <param name="screenName">The screen name of the user for whom to return results for</param>
        /// <param name="sinceId">Returns results with an ID greater than</param>
        /// <param name="count">Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified </param>
        /// <returns></returns>
        public async static Task<TwitterResponseCollection<Tweet>> GetFavourites(this ITwitterSession session, string screenName = "", int userId = 0, long sinceId = 0, long maxId = 0, int count = 20 )
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(count:count,include_entities:true,since_id:sinceId,max_id:maxId, user_id:userId, screen_name:screenName);

            var url = TwitterApi.Resolve("/1.1/favorites/list.json");
            return await session.GetAsync(url, parameters)
                          .ContinueWith(c => c.MapToMany<Tweet>());
        }
Beispiel #19
0
        /// <summary>
        /// Returns fully-hydrated tweets for up to 100 tweets per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.
        /// </summary>
        /// <param name="tweetIds">up to 100 are allowed in a single request.</param>
        /// <returns>Observable List of full tweets</returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/lookup </remarks>
        public static async Task <TwitterResponseCollection <Tweet> > GetTweetsFull(this IUserSession session, IEnumerable <long> tweetIds = null)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true);
            parameters.CreateCollection(tweetids: tweetIds);

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/statuses/lookup.json"), parameters)
                   .ContinueWith(c => c.MapToMany <Tweet>()));
        }
Beispiel #20
0
        /// <summary>
        /// Returns the members of the specified list. Private list members will only be shown if the authenticated user owns the specified list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="cursor">Breaks the results into pages.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/members </remarks>
        public static async Task <UserListDetailedCursored> GetMembersOnList(this IUserSession session, long listId, string slug,
                                                                             string ownerScreenName = "", long ownerId = 0, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, skip_status: true, include_entities: true, cursor: cursor);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/members.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <UserListDetailedCursored>()));
        }
Beispiel #21
0
        /// <summary>
        /// Check if the specified user is a member of the specified list
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="userId">The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/members/show </remarks>
        public static async Task <User> IsUserOnList(this ITwitterSession session, long listId, string slug = "",
                                                     long userId = 0, string screenName = "", string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(user_id: userId, screen_name: screenName, list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, skip_status: true, include_entities: true);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/members/show.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <User>()));
        }
Beispiel #22
0
        /// <summary>
        /// Returns the specified list. Private lists will only be shown if the authenticated user owns the specified list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/show </remarks>
        public static async Task <TwitterList> GetList(this ITwitterSession session, long listId, string slug,
                                                       string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/show.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <TwitterList>()));
        }
Beispiel #23
0
        /// <summary>
        /// Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="userId">The ID of the user to remove from the list. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <param name="screenName">The screen name of the user for whom to remove from the list. Helpful for disambiguating when a valid screen name is also a user ID.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy </remarks>
        public static async Task <TwitterSuccess> DeleteUserFromList(this IUserSession session, long listId = 0, string slug = "",
                                                                     long userId = 0, string screenName = "", string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, user_id: userId, screen_name: screenName);

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy"), parameters)
                   .ContinueWith(c => c.MapToTwitterSuccess()));
        }
Beispiel #24
0
        /// <summary>
        /// Returns the most recent direct messages sent by the authenticating user.
        /// </summary>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID</param>
        /// <param name="count">Specifies the number of direct messages to try and retrieve, up to a maximum of 200</param>
        /// <returns>(awaitable) IEnumerable of DirectMessages Sent by the session's authenticated user</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent </remarks>
        public async static Task <TwitterResponseCollection <DirectMessage> > GetDirectMessagesSent(this IUserSession session, long sinceId = 0, long maxId = 0, int count = 20)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, count: count, since_id: sinceId,
                              max_id: maxId);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/direct_messages/sent.json"), parameters)
                   .ContinueWith(c => c.MapToMany <DirectMessage>()));
        }
Beispiel #25
0
        /// <summary>
        /// Returns the lists owned by the specified Twitter user. Private lists will only be shown if the authenticated user is also the owner of the lists.
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="userId"></param>
        /// <param name="count"></param>
        /// <param name="cursor"></param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/ownerships </remarks>
        public static async Task <TwitterListCursored> GetListOwned(this ITwitterSession session,
                                                                    string screenName = "", long userId = 0, int count = 20, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(user_id: userId, screen_name: screenName, count: count, cursor: cursor);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/ownerships.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <TwitterListCursored>()));
        }
Beispiel #26
0
        /// <summary>
        /// Gets the Users who retweeted a particular tweet
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <param name="tweetId">tweet ID must be provided</param>
        /// <param name="count">how many to return default 500</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids </remarks>
        public async static Task <RetweetersResponseIDsCursored> GetRetweeters(this IUserSession session, long tweetId, int count = 20, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(id: tweetId, count: count, cursor: cursor);

            var path = TwitterApi.Resolve("/1.1/statuses/retweeters/id.json", parameters);

            return(await session.GetAsync(path, parameters)
                   .ContinueWith(c => c.MapToSingle <RetweetersResponseIDsCursored>()));
        }
        /// <summary>
        /// https://dev.twitter.com/docs/api/1.1/get/favorites/list
        /// Returns the count most recent Tweets favorited by the authenticating or specified user.
        /// If user_id and screen_name is left blank, current auth'd user favourites are returned
        /// Entities are always returned
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for</param>
        /// <param name="screenName">The screen name of the user for whom to return results for</param>
        /// <param name="sinceId">Returns results with an ID greater than</param>
        /// <param name="count">Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20.</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified </param>
        /// <returns></returns>
        public async static Task <TwitterResponseCollection <Tweet> > GetFavourites(this ITwitterSession session, string screenName = "", int userId = 0, long sinceId = 0, long maxId = 0, int count = 20)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(count: count, include_entities: true, since_id: sinceId, max_id: maxId, user_id: userId, screen_name: screenName);

            var url = TwitterApi.Resolve("/1.1/favorites/list.json");

            return(await session.GetAsync(url, parameters)
                   .ContinueWith(c => c.MapToMany <Tweet>()));
        }
        /// <summary>
        /// https://dev.twitter.com/docs/api/1.1/post/favorites/destroy
        /// Un-favourites a given tweet
        /// </summary>
        /// <param name="tweet">Tweet for to favourite</param>
        /// <returns></returns>
        public async static Task <Tweet> DeleteFavourite(this IUserSession session, Tweet tweet)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(id: tweet.Id);

            var url = TwitterApi.Resolve("/1.1/favorites/destroy.json");

            return(await session.PostAsync(url, parameters)
                   .ContinueWith(c => c.MapToSingle <Tweet>()));
        }
        /// <summary>
        /// Returns a timeline of tweets authored by members of the specified list. Retweets are included by default.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of results to retrieve per "page."</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <param name="includeRetweets">the list timeline will contain native retweets (if they exist) in addition to the standard stream of tweets.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/statuses </remarks>
        public static async Task<TwitterResponseCollection<Tweet>> GetListTimeline(this ITwitterSession session, long listId, string slug, long ownerId = 0, string ownerScreenName = "", long sinceId = 0, int count = 20, long maxId = 0, bool includeRetweets = true)
        {
            var parameters = new TwitterParametersCollection
                                 {
                                     {"include_rts", includeRetweets.ToString()},
                                 };
            parameters.Create(list_id:listId, slug:slug, owner_id:ownerId, owner_screen_name:ownerScreenName, since_id:sinceId, max_id:maxId);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/statuses.json"), parameters)
                          .ContinueWith(c => c.MapToMany<Tweet>());
        }
Beispiel #30
0
        /// <summary>
        /// Returns a timeline of tweets authored by members of the specified list. Retweets are included by default.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="sinceId">Returns results with an ID greater than (that is, more recent than) the specified ID.</param>
        /// <param name="count">Specifies the number of results to retrieve per "page."</param>
        /// <param name="maxId">Returns results with an ID less than (that is, older than) or equal to the specified ID.</param>
        /// <param name="includeRetweets">the list timeline will contain native retweets (if they exist) in addition to the standard stream of tweets.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/statuses </remarks>
        public static async Task <TwitterResponseCollection <Tweet> > GetListTimeline(this ITwitterSession session, long listId, string slug, long ownerId = 0, string ownerScreenName = "", long sinceId = 0, int count = 20, long maxId = 0, bool includeRetweets = true)
        {
            var parameters = new TwitterParametersCollection
            {
                { "include_rts", includeRetweets.ToString() },
            };

            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, since_id: sinceId, max_id: maxId);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/statuses.json"), parameters)
                   .ContinueWith(c => c.MapToMany <Tweet>()));
        }
Beispiel #31
0
        /// <summary>
        /// Provides a simple, relevance-based search interface to public user accounts on Twitter. Only the first 1,000 matching results are available.
        /// </summary>
        /// <param name="searchQuery">The search query to run against people search.</param>
        /// <param name="count">The number of potential user results to retrieve per page. This value has a maximum of 20.</param>
        /// <param name="page">Specifies the page of results to retrieve.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/search </remarks>
        public async static Task <TwitterResponseCollection <User> > SearchForUsers(this IUserSession session, string searchQuery, int count = 20, int page = 1)
        {
            var parameters = new TwitterParametersCollection
            {
                { "q", searchQuery },
                { "page", page.ToString() },
            };

            parameters.Create(count: count, include_entities: true);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/search.json"), parameters).ContinueWith(c => c.MapToMany <User>()));
        }
Beispiel #32
0
        /// <summary>
        /// Returns the lists the specified user has been added to. If user_id or screen_name are not provided the memberships for the authenticating user are returned.
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="cursor">Breaks the results into pages. Provide a value of -1 to begin paging.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/memberships </remarks>
        public static async Task <UserInListCursored> GetListMembershipForUser(this ITwitterSession session, long userId = 0,
                                                                               string screenName = "", long cursor = -1)
        {
            var parameters = new TwitterParametersCollection
            {
                { "filter_to_owned_lists", false.ToString() },
            };

            parameters.Create(cursor: cursor, user_id: userId, screen_name: screenName);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/lists/memberships.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <UserInListCursored>()));
        }
Beispiel #33
0
        /// <summary>
        /// Gets a particular Tweet
        /// </summary>
        /// <param name="tweetId">The tweet ID to return</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid  </remarks>
        public async static Task <Tweet> GetTweet(this ITwitterSession session, long tweetId)
        {
            var parameters = new TwitterParametersCollection
            {
                { "trim_user", false.ToString() },
                { "include_my_retweet", true.ToString() },
            };

            parameters.Create(id: tweetId, include_entities: true);

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/statuses/show.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <Tweet>()));
        }
        /// <summary>
        /// Sends a direct message sent to a user.
        /// </summary>
        /// <param name="text">Text to send to user</param>
        /// <param name="screenName">Screen name of the recipient</param>
        /// <returns></returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/direct_messages/new </remarks>
        public async static Task<DirectMessage> SendDirectMessage(this IUserSession session, string screenName, string text)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(include_entities:true, screen_name:screenName, text:text.TrimAndTruncate(140));
            if (parameters.EnsureAllArePresent(new [] {"screen_name", "text"}).IsFalse())
            {
                return session.MapParameterError<DirectMessage>(
                        "Either screen_name and text required");
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/direct_messages/new.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<DirectMessage>());
        }
        /// <summary>
        /// Returns a cursored collection of user IDs following a particular user(otherwise known as their "followers")
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <param name="userId">screen_name or user_id must be provided</param>
        /// <param name="screenName">screen_name or user_id must be provided</param>
        /// <param name="count">how many to return default 500</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/followers/ids </remarks>
        public static async Task<FriendsFollowersIDsCursored> GetFollowersIDs(this ITwitterSession session, string screenName = "", int userId = 0, int count = 500, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(count: count, cursor: cursor, screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<FriendsFollowersIDsCursored>(
                        "Either screen_name or user_id required");
            }

            return await session.GetAsync(TwitterApi.Resolve("/1.1/followers/ids.json"), parameters)
                             .ContinueWith(t => t.MapToSingle<FriendsFollowersIDsCursored>());
        }
        /// <summary>
        /// Returns a variety of information about the user specified by the required user_id or screen_name parameter. The author's most recent Tweet will be returned inline when possible.
        /// </summary>
        /// <param name="screenName">The screen name of the user for whom to return results for. Either a id or screen_name is required for this method.</param>
        /// <param name="userId">The ID of the user for whom to return results for. Either an id or screen_name is required for this method.</param>
        /// <returns></returns>
        public static async Task<User> GetUserProfile(this ITwitterSession session, string screenName="", long userId=0)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(screen_name:screenName,include_entities:true,user_id:userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<User>(
                        "Either screen_name or user_id required");
            }

            return await session.GetAsync(TwitterApi.Resolve("/1.1/users/show.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<User>());
        }
        /// <summary>
        /// Report the specified user as a spam account to Twitter. Additionally performs the equivalent of POST blocks/create on behalf of the authenticated user.
        /// </summary>
        /// <param name="screenName">The ID or screen_name of the user you want to report as a spammer. Helpful for disambiguating when a valid screen name is also a user ID.</param>
        /// <param name="userId">The ID of the user you want to report as a spammer. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/users/report_spam </remarks>
        public async static Task<User> ReportUserForSpam(this IUserSession session, string screenName="", int userId=0)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<User>(
                        "Either screen_name or user_id required");
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/users/report_spam.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<User>());
        }
        /// <summary>
        /// Returns all lists the authenticating or specified user subscribes to, including their own. The user is specified using the user_id or screen_name parameters. If no user is given, the authenticating user is used.
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="reverse">Set this to true if you would like owned lists to be returned first.</param>
        /// <returns>(awaitable) IEnumerable Lists the authenticated user or screen_name subscribes to</returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/list </remarks>
        public static async Task<TwitterResponseCollection<TwitterList>> GetLists(this ITwitterSession session, long userId = 0, string screenName = "", bool reverse = false)
        {
            var parameters = new TwitterParametersCollection {{"reverse", reverse.ToString()}};
            parameters.Create(screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<TwitterResponseCollection<TwitterList>>(
                        "Either screen_name or user_id required");
            }

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/list.json"), parameters)
                          .ContinueWith(c => c.MapToMany<TwitterList>());
        }
Beispiel #39
0
        /// <summary>
        /// Returns a map of the available size variations of the specified user's profile banner.
        /// </summary>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="userId">The ID of the user for whom to return results for.</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/profile_banner </remarks>
        public static async Task <ProfileBanners> GetProfileBanners(this IUserSession session, string screenName = "", long userId = 0)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, skip_status: true, screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return(session.MapParameterError <ProfileBanners>(
                           "Either screen_name or user_id required"));
            }
            return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/profile_banner.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <ProfileBanners>()));
        }
Beispiel #40
0
        /// <summary>
        /// Sends a direct message sent to a user.
        /// </summary>
        /// <param name="text">Text to send to user</param>
        /// <param name="screenName">Screen name of the recipient</param>
        /// <returns></returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/direct_messages/new </remarks>
        public async static Task <DirectMessage> SendDirectMessage(this IUserSession session, string screenName, string text)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true, screen_name: screenName, text: text.TrimAndTruncate(140));
            if (parameters.EnsureAllArePresent(new [] { "screen_name", "text" }).IsFalse())
            {
                return(session.MapParameterError <DirectMessage>(
                           "Either screen_name and text required"));
            }

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/direct_messages/new.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <DirectMessage>()));
        }
        /// <summary>
        /// Returns a cursored collection of user IDs following a particular user(otherwise known as their "followers")
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <param name="userId">screen_name or user_id must be provided</param>
        /// <param name="screenName">screen_name or user_id must be provided</param>
        /// <param name="count">how many to return default 500</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/followers/ids </remarks>
        public static async Task <FriendsFollowersIDsCursored> GetFollowersIDs(this ITwitterSession session, string screenName = "", int userId = 0, int count = 500, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(count: count, cursor: cursor, screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return(session.MapParameterError <FriendsFollowersIDsCursored>(
                           "Either screen_name or user_id required"));
            }

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/followers/ids.json"), parameters)
                   .ContinueWith(t => t.MapToSingle <FriendsFollowersIDsCursored>()));
        }
Beispiel #42
0
        /// <summary>
        /// Report the specified user as a spam account to Twitter. Additionally performs the equivalent of POST blocks/create on behalf of the authenticated user.
        /// </summary>
        /// <param name="screenName">The ID or screen_name of the user you want to report as a spammer. Helpful for disambiguating when a valid screen name is also a user ID.</param>
        /// <param name="userId">The ID of the user you want to report as a spammer. Helpful for disambiguating when a valid user ID is also a valid screen name.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/users/report_spam </remarks>
        public async static Task <User> ReportUserForSpam(this IUserSession session, string screenName = "", int userId = 0)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(screen_name: screenName, user_id: userId);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return(session.MapParameterError <User>(
                           "Either screen_name or user_id required"));
            }

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/users/report_spam.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <User>()));
        }
Beispiel #43
0
        /// <summary>
        /// Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.
        /// </summary>
        /// <param name="screenNames">up to 100 are allowed in a single request.</param>
        /// <param name="userIds">up to 100 are allowed in a single request. </param>
        /// <returns>Observable List of full user details</returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/users/lookup </remarks>
        public static async Task <TwitterResponseCollection <User> > GetUsersDetailsFull(this ITwitterSession session, IEnumerable <string> screenNames = null,
                                                                                         IEnumerable <long> userIds = null)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(include_entities: true);
            parameters.CreateCollection(screen_names: screenNames, user_ids: userIds);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return(session.MapParameterError <TwitterResponseCollection <User> >(
                           "Either screen_names or user_ids required"));
            }

            return(await session.GetAsync(TwitterApi.Resolve("/1.1/users/lookup.json"), parameters).ContinueWith(c => c.MapToMany <User>()));
        }
        /// <summary>
        /// Allows one to enable or disable retweets and device notifications from the specified user.
        /// </summary>
        /// <param name="screenName">The screen name of the user</param>
        /// <param name="user_id">The ID of the user</param>
        /// <param name="device">Enable/disable device notifications from the target user.</param>
        /// <param name="retweets">Enable/disable retweets from the target user.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/friendships/update </remarks>
        public async static Task <UserStatus> ChangeFriendship(this IUserSession session, string screenName = "",
                                                               int user_id = 0, bool device = false, bool retweets = false)
        {
            var parameters = new TwitterParametersCollection();

            parameters.Create(screen_name: screenName, user_id: user_id, device: device, retweets: retweets);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return(session.MapParameterError <UserStatus>(
                           "Either screen_name or user_id required"));
            }

            return(await session.PostAsync(TwitterApi.Resolve("/1.1/friendships/update.json"), parameters)
                   .ContinueWith(c => c.MapToSingle <UserStatus>()));
        }
        //https://dev.twitter.com/docs/streaming-apis/parameters
        public TwitterParametersCollection ChangeSearchParameters(StreamSearchRequest searchRequest)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(stall_warnings: false, delimited: false);

            if (searchRequest.Tracks.HasAny())
                parameters.CreateCommaDelimitedList("track", searchRequest.Tracks);
            if (searchRequest.Follows.HasAny())
                parameters.CreateCommaDelimitedList("follow", searchRequest.Follows);
            if (searchRequest.Locations.HasAny())
                parameters.CreateCommaDelimitedList("locations", searchRequest.Locations);

            parameters.Add("filter_level", searchRequest.FilterLevel);
            parameters.Add("language", searchRequest.Language);

            return parameters;
        }
        public TwitterParametersCollection ChangeSearchParameters(IEnumerable<string> track = null, IEnumerable<string> follow = null, IEnumerable<string> locations = null, string filterlevel = "none", string language = "en")
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(stall_warnings: false, delimited: false);

            if (track != null)
                parameters.CreateCommaDelimitedList("track", track);
            if (follow != null)
                parameters.CreateCommaDelimitedList("follow", follow);
            if (locations != null)
                parameters.CreateCommaDelimitedList("locations", locations);

            parameters.Add("filter_level", filterlevel);
            parameters.Add("language", language);

            return parameters;
        }
        /// <summary>
        /// dedicated API for running searches against the real-time index of recent Tweets. 6-9 days of historical data
        /// </summary>
        /// <param name="searchText">search query of 1,000 characters maximum, including operators. Queries may additionally be limited by complexity.</param>
        /// <param name="maxId"></param>
        /// <param name="sinceId"></param>
        /// <param name="untilDate">YYYY-MM-DD format</param>
        /// <param name="count">Tweets to return Default 20</param>
        /// <param name="searchResponseType">SearchResult.Mixed (default), SearchResult.Recent, SearchResult.Popular</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/search/tweets </remarks>
        public async static Task<SearchResponse> SearchFor(this ITwitterSession session, string searchText, SearchResultType searchResponseType, long maxId = 0, long sinceId = 0, string untilDate = "", int count = 20)
        {
            var parameters = new TwitterParametersCollection
                                 {
                                     {"q", searchText.TrimAndTruncate(1000).UrlEncode()},
                                     {"result_type", SearchResultString(searchResponseType)},
                                 };
            parameters.Create(since_id:sinceId,max_id:maxId,count:count,include_entities:true);

            if (!string.IsNullOrWhiteSpace(untilDate))
            {
                parameters.Add("until", untilDate);
            }

            return await session.GetAsync(TwitterApi.Resolve("/1.1/search/tweets.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<SearchResponse>());
        }
        /// <summary>
        /// Sends a Tweet
        /// </summary>
        /// <param name="text">Text of tweet to send</param>
        /// <param name="latitude">Latitude of sender</param>
        /// <param name="longitude">Longotide of sender</param>
        /// <param name="placeId">A place in the world identified by a Twitter place ID. Place IDs can be retrieved from geo/reverse_geocode.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/statuses/update </remarks>
        public async static Task<Tweet> SendTweet(this IUserSession session, string text, double latitude = 0.0, double longitude = 0.0, string placeId="")
        {
            var parameters = new TwitterParametersCollection
                                 {
                                     { "status", text.TrimAndTruncate(1000)},
                                     { "trim_user", true.ToString() },
                                 };
            parameters.Create(include_entities:true,place_id:placeId);
            
            if (Math.Abs(latitude) > 0.0 && Math.Abs(longitude) > 0.0)
            {
                parameters.Add("lat", latitude.ToString());
                parameters.Add("long", longitude.ToString());
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/statuses/update.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<Tweet>());
        }
        /// <summary>
        /// Sends a Tweet in reply to another tweet
        /// </summary>
        /// <param name="tweet">Tweet replying to</param>
        /// <param name="text">Text of the reply</param>
        /// <param name="latitude">Latitude</param>
        /// <param name="longitude">Longitude</param>
        /// <param name="placeId">A place in the world identified by a Twitter place ID. Place IDs can be retrieved from geo/reverse_geocode.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/statuses/update </remarks>
        public async static Task<Tweet> ReplyToTweet(this IUserSession session, Tweet tweet, string text, double latitude=0.0, double longitude = 0.0, string placeId="")
        {
             var parameters = new TwitterParametersCollection
                                {
                                     {"status", text },
                                     {"in_reply_to_status_id", tweet.Id.ToString()}
                                 };
            parameters.Create(place_id:placeId);

            if (Math.Abs(latitude) > 0.0 && Math.Abs(longitude) > 0.0)
            {
                parameters.Add("lat", latitude.ToString());
                parameters.Add("long", longitude.ToString());
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/statuses/update.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<Tweet>());
        }
        /// <summary>
        /// Updates the authenticating user's settings.
        /// </summary>
        /// <param name="trendLocationWoeid">The Yahoo! Where On Earth ID to use as the user's default trend location.</param>
        /// <param name="sleepTimeEnabled">enable sleep time for the user. Sleep time is the time when push or SMS notifications should not be sent to the user.</param>
        /// <param name="startSleepTime">The hour that sleep time should begin if it is enabled. (00)</param>
        /// <param name="endSleepTime">The hour that sleep time should end if it is enabled. (23) </param>
        /// <param name="timeZone">The timezone dates and times should be displayed in for the user. http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html </param>
        /// <param name="language">The language which Twitter should render in for this user https://dev.twitter.com/docs/api/1/get/help/languages </param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/account/settings </remarks>
        public static async Task<AccountSettings> ChangeAccountSettings(this IUserSession session, string trendLocationWoeid = "1",
            bool sleepTimeEnabled = false, string startSleepTime = "", string endSleepTime = "",
            string timeZone = "", string language = "")
        {
            var parameters = new TwitterParametersCollection
                             {
                                 {"sleep_time_enabled", sleepTimeEnabled.ToString()},
                             };
            parameters.Create(include_entities: true);
 
            if (!string.IsNullOrWhiteSpace(trendLocationWoeid))
            {
                parameters.Add("trend_location_woeid", trendLocationWoeid);
            }

            if (!string.IsNullOrWhiteSpace(startSleepTime))
            {
                parameters.Add("start_sleep_time", startSleepTime);
            }

            if (!string.IsNullOrWhiteSpace(endSleepTime))
            {
                parameters.Add("end_sleep_time", endSleepTime);
            }

            if (!string.IsNullOrWhiteSpace(timeZone))
            {
                parameters.Add("time_zone", timeZone);
            }

            if (!string.IsNullOrWhiteSpace(language))
            {
                parameters.Add("lang", language);
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/account/settings.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<AccountSettings>());
        }
        /// <summary>
        /// Deletes a sent direct message
        /// </summary>
        /// <param name="Id">ID of the direct message to delete</param>
        /// <returns>TwitterSuccess (true) if deletion worked</returns>
        /// <remarks>ref: https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy </remarks>
        public async static Task<TwitterSuccess> DeleteDirectMessage(this IUserSession session, long Id)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(id: Id);

            return await session.PostAsync(TwitterApi.Resolve("/1.1/direct_messages/destroy.json"), parameters)
                          .ContinueWith(c => c.MapToTwitterSuccess());
        }
        /// <summary>
        /// Returns a cursored collection of user objects for users following the specified user.
        /// Presently in most recent following first
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <param name="userId">screen_name or user_id must be provided</param>
        /// <param name="screenName">screen_name or user_id must be provided</param>
        /// <param name="count">how many to return default 500</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/followers/list </remarks>
        public async static Task<UserListDetailedCursored> GetFollowersList(this ITwitterSession session, string screenName = "", int userId = 0, int count = 20, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection
                                    {
                                        {"include_user_entities", true.ToString()},
                                    };
            parameters.Create(count: count, cursor: cursor, screen_name: screenName, user_id: userId, skip_status:true);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<UserListDetailedCursored>(
                        "Either screen_name or user_id required");
            }

            return await session.GetAsync(TwitterApi.Resolve("/1.1/followers/list.json"), parameters)
                             .ContinueWith(t => t.MapToSingle<UserListDetailedCursored>());
        }
        /// <summary>
        /// Returns the members of the specified list. Private list members will only be shown if the authenticated user owns the specified list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="cursor">Breaks the results into pages.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/members </remarks>
        public static async Task<UserListDetailedCursored> GetMembersOnList(this IUserSession session, long listId, string slug,
            string ownerScreenName = "", long ownerId = 0, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName, skip_status: true, include_entities: true, cursor:cursor);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/members.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<UserListDetailedCursored>());
        }
        /// <summary>
        /// Updates the specified list. The authenticated user must own the list to be able to update it.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="name">The name for the list.</param>
        /// <param name="mode">Whether your list is public or private. Values can be public or private. If no mode is specified the list will be public.</param>
        /// <param name="description">The description to give the list.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/lists/update </remarks>
        public static async Task<TwitterSuccess> ChangeList(this IUserSession session, long listId,
            string slug, string name = "", string mode = "", string description = "", long ownerId = 0,
            string ownerScreenName = "")
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(name:name, list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName);

            if (!string.IsNullOrWhiteSpace(mode))
            {
                parameters.Add("mode", mode);
            }
            if (!string.IsNullOrWhiteSpace(description))
            {
                parameters.Add("description", description);
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/lists/update.json"), parameters)
                          .ContinueWith(c => c.MapToTwitterSuccess());
        }
        /// <summary>
        /// Removes multiple members from a list, by specifying a comma-separated list of member ids or screen names. The authenticated user must own the list to be able to remove members from it.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="screenNames">list of screen names, up to 100 are allowed in a single request.</param>
        /// <param name="userIds">list of user IDs, up to 100 are allowed in a single request.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all </remarks>
        public static async Task<TwitterSuccess> DeleteUsersFromList(this IUserSession session, long listId=0, string slug="",
            IEnumerable<string> screenNames=null, IEnumerable<long> userIds=null,
            string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName);
            parameters.CreateCollection(screen_names:screenNames, user_ids:userIds);

            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<TwitterSuccess>(
                        "Either screen_names or user_ids required");
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/lists/members/destroy_all.json"), parameters)
                          .ContinueWith(c => c.MapToTwitterSuccess());
        }
        /// <summary>
        /// Returns the lists owned by the specified Twitter user. Private lists will only be shown if the authenticated user is also the owner of the lists.
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="userId"></param>
        /// <param name="count"></param>
        /// <param name="cursor"></param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/ownerships </remarks>
        public static async Task<TwitterListCursored> GetListOwned(this ITwitterSession session,
            string screenName = "", long userId = 0, int count = 20, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(user_id: userId, screen_name: screenName, count: count, cursor: cursor);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/ownerships.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<TwitterListCursored>());
        }
        /// <summary>
        /// Returns the lists the specified user has been added to. If user_id or screen_name are not provided the memberships for the authenticating user are returned.
        /// </summary>
        /// <param name="userId">The ID of the user for whom to return results for.</param>
        /// <param name="screenName">The screen name of the user for whom to return results for.</param>
        /// <param name="cursor">Breaks the results into pages. Provide a value of -1 to begin paging.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/memberships </remarks>
        public static async Task<UserInListCursored> GetListMembershipForUser(this ITwitterSession session, long userId = 0,
            string screenName = "", long cursor = -1)
        {
            var parameters = new TwitterParametersCollection
                                 {
                                     {"filter_to_owned_lists", false.ToString()},
                                 };
            parameters.Create(cursor: cursor, user_id: userId, screen_name: screenName);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/memberships.json"), parameters)
                          .ContinueWith(c => c.MapToSingle <UserInListCursored>()); 
        }
        /// <summary>
        /// Allows one to enable or disable retweets and device notifications from the specified user.
        /// </summary>
        /// <param name="screenName">The screen name of the user</param>
        /// <param name="user_id">The ID of the user</param>
        /// <param name="device">Enable/disable device notifications from the target user.</param>
        /// <param name="retweets">Enable/disable retweets from the target user.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/post/friendships/update </remarks>
        public async static Task<UserStatus> ChangeFriendship(this IUserSession session, string screenName = "",
            int user_id = 0, bool device=false, bool retweets=false)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(screen_name: screenName, user_id: user_id,device:device,retweets:retweets);
            
            if (parameters.EnsureEitherOr("screen_name", "user_id").IsFalse())
            {
                return session.MapParameterError<UserStatus>(
                        "Either screen_name or user_id required");
            }

            return await session.PostAsync(TwitterApi.Resolve("/1.1/friendships/update.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<UserStatus>());
        }
        /// <summary>
        /// Returns the specified list. Private lists will only be shown if the authenticated user owns the specified list.
        /// </summary>
        /// <param name="listId">The numerical id of the list.</param>
        /// <param name="slug">You can identify a list by its slug instead of its numerical id. If you decide to do so, note that you'll also have to specify the list owner using the owner_id or owner_screen_name parameters.</param>
        /// <param name="ownerId">The user ID of the user who owns the list being requested by a slug.</param>
        /// <param name="ownerScreenName">The screen name of the user who owns the list being requested by a slug.</param>
        /// <returns></returns>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/lists/show </remarks>
        public static async Task<TwitterList> GetList(this ITwitterSession session, long listId, string slug,
            string ownerScreenName = "", long ownerId = 0)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(list_id: listId, slug: slug, owner_id: ownerId, owner_screen_name: ownerScreenName);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/lists/show.json"), parameters)
                          .ContinueWith(c => c.MapToSingle<TwitterList>());
        }
        /// <summary>
        /// Returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user.
        /// </summary>
        /// <param name="cursor">default is first page (-1) otherwise provide starting point</param>
        /// <remarks> ref: https://dev.twitter.com/docs/api/1.1/get/friendships/incoming </remarks>
        public async static Task<FriendsFollowersIDsCursored> GetFriendshipRequestsIncoming(this IUserSession session, long cursor = -1)
        {
            var parameters = new TwitterParametersCollection();
            parameters.Create(cursor:cursor);

            return await session.GetAsync(TwitterApi.Resolve("/1.1/friendships/incoming.json"), parameters)
                             .ContinueWith(t => t.MapToSingle<FriendsFollowersIDsCursored>());
        }