Exemplo n.º 1
0
        /// <summary>
        ///     指定した公開制限のブックマークで、小説に対して付けたタグのリストを取得します。
        /// </summary>
        /// <param name="restrict">
        ///     公開制限
        /// </param>
        /// <returns>
        ///     <see cref="BookmarkTagCollection" />
        /// </returns>
        public async Task <BookmarkTagCollection> NovelAsync(Restrict restrict = Restrict.Public)
        {
            Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict));
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameters = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            return(await PixivClient.GetAsync <BookmarkTagCollection>("https://app-api.pixiv.net/v1/user/bookmark-tags/novel", parameters).Stay());
        }
Exemplo n.º 2
0
        /// <summary>
        ///     指定したユーザーをフォローします。
        /// </summary>
        /// <param name="userId">ユーザー ID</param>
        /// <param name="restrict">公開制限</param>
        public async Task AddAsync(long userId, Restrict restrict = Restrict.Public)
        {
            Ensure.GreaterThanZero(userId, nameof(userId));
            Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict));
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("user_id", userId.ToString()),
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            await PixivClient.PostAsync("https://app-api.pixiv.net/v1/user/follow/add", parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     フォローしているユーザーの新着イラストを取得します。
        /// </summary>
        /// <param name="restrict">公開制限</param>
        /// <param name="offset">オフセット</param>
        /// <returns>
        ///     <see cref="IllustCollection" />
        /// </returns>
        public async Task <IllustCollection> FollowAsync(Restrict restrict = Restrict.All, long offset = 0)
        {
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            if (offset > 0)
            {
                parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString()));
            }

            return(await PixivClient.GetAsync <IllustCollection>("https://app-api.pixiv.net/v2/illust/follow", parameters).Stay());
        }
Exemplo n.º 4
0
        /// <summary>
        ///     指定したイラストをブックマークに追加します。
        /// </summary>
        /// <param name="illustId">イラスト ID</param>
        /// <param name="restrict">公開制限</param>
        /// <param name="tags">タグ</param>
        public async Task AddAsync(long illustId, Restrict restrict = Restrict.Public, string[] tags = null)
        {
            Ensure.GreaterThanZero(illustId, nameof(illustId));
            Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict));
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("illust_id", illustId.ToString()),
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            if (tags?.Length > 0)
            {
                parameters.Add(new KeyValuePair <string, string>("tags[]", string.Join(",", tags)));
            }

            await PixivClient.PostAsync("https://app-api.pixiv.net/v2/illust/bookmark/add", parameters).Stay();
        }
Exemplo n.º 5
0
        /// <summary>
        ///     指定したユーザーの小説ブックマークを取得します。
        /// </summary>
        /// <param name="userId">ユーザー ID</param>
        /// <param name="restrict">公開制限 (自分以外は Public のみ取得可能)</param>
        /// <param name="tag">絞り込みタグ (自分に対してのみ使用可能)</param>
        /// <returns>
        ///     <see cref="NovelCollection" />
        /// </returns>
        public async Task <NovelCollection> NovelAsync(long userId, Restrict restrict = Restrict.Public, string tag = null)
        {
            Ensure.GreaterThanZero(userId, nameof(userId));
            Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict));
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameter = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("user_id", userId.ToString()),
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            if (!string.IsNullOrWhiteSpace(tag))
            {
                parameter.Add(new KeyValuePair <string, string>("tag", tag));
            }

            return(await PixivClient.GetAsync <NovelCollection>("https://app-api.pixiv.net/v1/user/bookmarks/novel", parameter).Stay());
        }
Exemplo n.º 6
0
        /// <summary>
        ///     指定したユーザーがフォローしているユーザーを取得します。
        /// </summary>
        /// <param name="userId">ユーザー ID</param>
        /// <param name="restrict">公開制限</param>
        /// <param name="offset">オフセット</param>
        /// <param name="filter">フィルター (`for_ios` が有効)</param>
        /// <returns>
        ///     <see cref="UserPreviewCollection" />
        /// </returns>
        public async Task <UserPreviewCollection> FollowingAsync(long userId, Restrict restrict = Restrict.Public, long offset = 0, string filter = "")
        {
            Ensure.GreaterThanZero(userId, nameof(userId));
            Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("user_id", userId.ToString()),
                new KeyValuePair <string, string>("restrict", restrict.ToParameter())
            };

            if (offset > 0)
            {
                parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(filter))
            {
                parameters.Add(new KeyValuePair <string, string>("filter", filter));
            }

            return(await PixivClient.GetAsync <UserPreviewCollection>("https://app-api.pixiv.net/v1/user/following", parameters).Stay());
        }