コード例 #1
0
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > GetUserTimelineAsync(
            [NotNull] this IApiAccessor accessor,
            [NotNull] UserParameter targetUser, int?count, long?sinceId, long?maxId,
            bool?excludeReplies, bool?includeRetweets, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (targetUser == null)
            {
                throw new ArgumentNullException(nameof(targetUser));
            }
            var param = new Dictionary <string, object>
            {
                { "since_id", sinceId },
                { "max_id", maxId },
                { "count", count },
                { "exclude_replies", excludeReplies },
                { "include_rts", includeRetweets },
            }.ApplyParameter(targetUser).SetExtended();

            return(await accessor.GetAsync("statuses/user_timeline.json", param,
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #2
0
ファイル: Lists.cs プロジェクト: Rires-Magica/Cadena
 public static async Task <IApiResult <TwitterList> > ShowListAsync(
     [NotNull] this IApiAccessor accessor,
     [NotNull] ListParameter targetList, CancellationToken cancellationToken)
 {
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     return(await accessor.GetAsync("lists/show.json", targetList.ToDictionary(),
                                    ResultHandlers.ReadAsListAsync, cancellationToken).ConfigureAwait(false));
 }
コード例 #3
0
ファイル: Help.cs プロジェクト: Rires-Magica/Cadena
 /// <summary>
 /// Get current configuration of Twitter.
 /// </summary>
 /// <param name="accessor">current configuration of Twitter</param>
 /// <param name="cancellationToken">cancellation token</param>
 /// <returns>object represents current configuration state of twitter.</returns>
 public static async Task <IApiResult <TwitterConfiguration> > GetConfigurationAsync(
     [NotNull] this IApiAccessor accessor, CancellationToken cancellationToken)
 {
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     return(await accessor.GetAsync("help/configuration.json",
                                    new Dictionary <string, object>(), ResultHandlers.ReadAsConfigurationAsync,
                                    cancellationToken).ConfigureAwait(false));
 }
コード例 #4
0
ファイル: Searching.cs プロジェクト: Rires-Magica/Cadena
 public static async Task <IApiResult <IEnumerable <TwitterSavedSearch> > > GetSavedSearchesAsync(
     [NotNull] this IApiAccessor accessor, CancellationToken cancellationToken)
 {
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     return(await accessor.GetAsync("saved_searches/list.json", new Dictionary <string, object>(),
                                    ResultHandlers.ReadAsSavedSearchCollectionAsync, cancellationToken)
            .ConfigureAwait(false));
 }
コード例 #5
0
ファイル: Relations.cs プロジェクト: Rires-Magica/Cadena
 public static async Task <IApiResult <IEnumerable <long> > > GetNoRetweetsIdsAsync(
     [NotNull] this IApiAccessor accessor,
     CancellationToken cancellationToken)
 {
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     return(await accessor.GetAsync("friendships/no_retweets/ids.json",
                                    new Dictionary <string, object>(), ResultHandlers.ReadAsIdCollectionAsync,
                                    cancellationToken).ConfigureAwait(false));
 }
コード例 #6
0
        public static async Task <IApiResult <ICursorResult <IEnumerable <long> > > > GetBlocksIdsAsync(
            [NotNull] this IApiAccessor accessor, long cursor, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object> {
                { "cursor", cursor }
            };

            return(await accessor.GetAsync("blocks/ids.json", param,
                                           ResultHandlers.ReadAsCursoredIdsAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #7
0
        public static async Task <IApiResult <IEnumerable <TwitterUser> > > GetRetweetsAsync(
            [NotNull] this IApiAccessor accessor, long id, int?count,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object> {
                { "count", count }
            };

            return(await accessor.GetAsync("statuses/retweets/" + id + ".json", param,
                                           ResultHandlers.ReadAsUserCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #8
0
        public static async Task <IApiResult <TwitterUser> > VerifyCredentialAsync(
            [NotNull] this IApiAccessor accessor,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "skip_status", true }
            };

            return(await accessor.GetAsync("account/verify_accesss.json",
                                           param, ResultHandlers.ReadAsUserAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #9
0
        public static async Task <IApiResult <TwitterStatus> > ShowTweetAsync(
            [NotNull] this IApiAccessor accessor, long id,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "id", id }
            }.SetExtended();

            return(await accessor.GetAsync("statuses/show.json", param,
                                           ResultHandlers.ReadAsStatusAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #10
0
ファイル: DirectMessages.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <TwitterStatus> > ShowDirectMessageAsync(
            [NotNull] this IApiAccessor accessor, long id,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "id", id },
                { "full_text", true } // full_text mode is always applied
            }.SetExtended();

            return(await accessor.GetAsync("direct_messages/show.json", param,
                                           ResultHandlers.ReadAsStatusAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #11
0
ファイル: Users.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <TwitterUser> > ShowUserAsync(
            [NotNull] this IApiAccessor accessor, [NotNull] UserParameter parameter,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }
            var param = parameter.ToDictionary();

            return(await accessor.GetAsync("users/show.json", param,
                                           ResultHandlers.ReadAsUserAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #12
0
ファイル: Relations.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <ICursorResult <IEnumerable <long> > > > GetFollowersIdsAsync(
            [NotNull] this IApiAccessor accessor,
            [CanBeNull] UserParameter nullableTargetUser, long?cursor, int?count, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "cursor", cursor },
                { "count", count }
            }.ApplyParameter(nullableTargetUser);

            return(await accessor.GetAsync("followers/ids.json", param,
                                           ResultHandlers.ReadAsCursoredIdsAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #13
0
ファイル: Lists.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterList> > > GetListsAsync(
            [NotNull] this IApiAccessor accessor, [NotNull] UserParameter targetUser,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (targetUser == null)
            {
                throw new ArgumentNullException(nameof(targetUser));
            }

            return(await accessor.GetAsync("lists/list.json", targetUser.ToDictionary(),
                                           ResultHandlers.ReadAsListCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #14
0
ファイル: Searching.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > SearchAsync(
            [NotNull] this IApiAccessor accessor, [NotNull] SearchParameter query,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            return(await accessor.GetAsync("search/tweets.json", query.ToDictionary().SetExtended(),
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #15
0
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > GetRetweetsOfMeAsync(
            [NotNull] this IApiAccessor accessor,
            int?count, long?sinceId, long?maxId, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "count", count },
                { "since_id", sinceId },
                { "max_id", maxId },
            }.SetExtended();

            return(await accessor.GetAsync("statuses/retweets_of_me.json", param,
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #16
0
ファイル: Favorites.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > GetFavoritesAsync(
            [NotNull] this IApiAccessor accessor, [CanBeNull] UserParameter targetUser,
            int?count, long?sinceId, long?maxId,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "count", count },
                { "since_id", sinceId },
                { "max_id", maxId },
            }.ApplyParameter(targetUser).SetExtended();

            return(await accessor.GetAsync("favorites/list.json", param,
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #17
0
ファイル: DirectMessages.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > GetDirectMessagesAsync(
            [NotNull] this IApiAccessor accessor, int?count, long?sinceId, long?maxId,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "count", count },
                { "since_id", sinceId },
                { "max_id", maxId },
                { "full_text", true } // full_text mode is always applied
            }.SetExtended();

            return(await accessor.GetAsync("direct_messages.json", param,
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #18
0
ファイル: Lists.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <ICursorResult <IEnumerable <TwitterList> > > > GetListMembershipsAsync(
            [NotNull] this IApiAccessor accessor,
            [NotNull] ListParameter targetList, long?cursor, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (targetList == null)
            {
                throw new ArgumentNullException(nameof(targetList));
            }
            var param = new Dictionary <string, object>()
            {
                { "cursor", cursor },
            }.ApplyParameter(targetList);

            return(await accessor.GetAsync("lists/memberships.json", param,
                                           ResultHandlers.ReadAsCursoredListsAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #19
0
ファイル: Users.cs プロジェクト: Rires-Magica/Cadena
        private static async Task <IApiResult <IEnumerable <TwitterUser> > > LookupUserCoreAsync(
            [NotNull] IApiAccessor accessor, IEnumerable <long> userIds, IEnumerable <string> screenNames,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var userIdsString = userIds == null
                ? null
                : String.Join(",", userIds.Select(s => s.ToString(CultureInfo.InvariantCulture)));
            var param = new Dictionary <string, object>
            {
                { "user_id", userIdsString },
                { "screen_name", screenNames == null ? null : String.Join(",", screenNames) }
            };

            return(await accessor.GetAsync("users/lookup.json", param,
                                           ResultHandlers.ReadAsUserCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #20
0
ファイル: Lists.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterStatus> > > GetListTimelineAsync(
            [NotNull] this IApiAccessor accessor,
            [NotNull] ListParameter listTarget, long?sinceId, long?maxId, int?count, bool?includeRts,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>()
            {
                { "since_id", sinceId },
                { "max_id", maxId },
                { "count", count },
                { "include_rts", includeRts },
            }.ApplyParameter(listTarget).SetExtended();

            return(await accessor.GetAsync("lists/statuses.json", param,
                                           ResultHandlers.ReadAsStatusCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #21
0
ファイル: Relations.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <TwitterFriendship> > ShowFriendshipAsync(
            [NotNull] this IApiAccessor accessor,
            [NotNull] UserParameter sourceUser, [NotNull] UserParameter targetUser, CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (sourceUser == null)
            {
                throw new ArgumentNullException(nameof(sourceUser));
            }
            if (targetUser == null)
            {
                throw new ArgumentNullException(nameof(targetUser));
            }
            sourceUser.SetKeyAsSource();
            targetUser.SetKeyAsTarget();
            var param = sourceUser.ToDictionary().ApplyParameter(targetUser);

            return(await accessor.GetAsync("friendships/show.json", param,
                                           ResultHandlers.ReadAsFriendshipAsync, cancellationToken).ConfigureAwait(false));
        }
コード例 #22
0
ファイル: Users.cs プロジェクト: Rires-Magica/Cadena
        public static async Task <IApiResult <IEnumerable <TwitterUser> > > SearchUserAsync(
            [NotNull] this IApiAccessor accessor, [NotNull] string query, int?page, int?count,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            var param = new Dictionary <string, object>
            {
                { "q", query },
                { "page", page },
                { "count", count },
            };

            return(await accessor.GetAsync("users/search.json", param,
                                           ResultHandlers.ReadAsUserCollectionAsync, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #23
0
        public static async Task <IApiResult <long?> > GetMyRetweetIdOfStatusAsync(
            [NotNull] this IApiAccessor accessor, long id,
            CancellationToken cancellationToken)
        {
            if (accessor == null)
            {
                throw new ArgumentNullException(nameof(accessor));
            }
            var param = new Dictionary <string, object>
            {
                { "id", id },
                { "include_my_retweet", true }
            };

            return(await accessor.GetAsync("statuses/show.json", param,
                                           async resp =>
            {
                var json = await resp.ReadAsStringAsync().ConfigureAwait(false);
                var graph = MeteorJson.Parse(json);
                return graph.ContainsKey("current_user_retweet")
                        ? graph["current_user_retweet"]["id_str"].AsString().ParseLong()
                        : (long?)null;
            }, cancellationToken).ConfigureAwait(false));
        }