Ejemplo n.º 1
0
        public virtual void GetComments(IEnumerable<int> fromUserIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError, CommentOptions options)
        {
            string[] urlParameters = null;
            if (options.ToUserId.HasValue)
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments", options.ToUserId.ToString() };
            }
            else
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments" };
            }

            MakeRequest<CommentResponse>("users", urlParameters, new
            {
                key = apiKey,
                page = options.Page ?? null,
                pagesize = options.PageSize ?? null,
                fromdate = options.FromDate.HasValue ? (long?)options.FromDate.Value.ToUnixTime() : null,
                todate = options.ToDate.HasValue ? (long?)options.ToDate.Value.ToUnixTime() : null,
                sort = options.SortBy.ToString().ToLower(),
                order = GetSortDirection(options.SortDirection),
                min = options.Min ?? null,
                max = options.Max ?? null
            }, (items) => onSuccess(new PagedList<Comment>(items.Comments, items)), onError);
        }
Ejemplo n.º 2
0
 public virtual IEnumerable<Badge> GetUserBadges(IEnumerable<int> userIds)
 {
     return MakeRequest<BadgeResponse>("users", new string[] { userIds.Vectorize(), "badges" }, new
     {
         key = apiKey
     }).Badges;
 }
Ejemplo n.º 3
0
 public virtual void GetUsers(IEnumerable<int> userIds, Action<IPagedList<User>> onSuccess, Action<ApiException> onError = null)
 {
     MakeRequest<UserResponse>("users", new string[] { userIds.Vectorize() }, new
     {
         key = apiKey
     }, (items) => onSuccess(new PagedList<User>(items.Users, items)), onError);
 }
Ejemplo n.º 4
0
 public virtual void GetUserTimeline(IEnumerable<int> userIds, Action<IPagedList<UserEvent>> onSuccess, Action<ApiException> onError = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<UserEventResponse>("users", new string[] { userIds.Vectorize(), "timeline" }, new
     {
         key = apiKey,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(new PagedList<UserEvent>(items.Events, items)), onError);
 }
Ejemplo n.º 5
0
 public virtual IEnumerable<Revision> GetRevisions(IEnumerable<int> ids, DateTime? fromDate, DateTime? toDate)
 {
     return MakeRequest<RevisionResponse>("revisions", new string[] { ids.Vectorize() }, new
     {
         key = apiKey,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }).Revisions;
 }
Ejemplo n.º 6
0
 public virtual void GetRevisions(IEnumerable<int> ids, Action<IEnumerable<Revision>> onSuccess, Action<ApiException> onError = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<RevisionResponse>("revisions", new string[] { ids.Vectorize() }, new
     {
         key = apiKey,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(items.Revisions), onError);
 }
Ejemplo n.º 7
0
 public virtual void GetUserReputation(IEnumerable<int> userIds, Action<IPagedList<Reputation>> onSuccess, Action<ApiException> onError = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<ReputationResponse>("users", new string[] { userIds.Vectorize(), "reputation" }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(new PagedList<Reputation>(items.Reputation, items)), onError);
 }
Ejemplo n.º 8
0
 public virtual void GetUsersByBadge(IEnumerable<int> userIds, Action<IPagedList<User>> onSuccess, Action<ApiException> onError, BadgeByUserOptions options)
 {
     MakeRequest<UserResponse>("badges", new string[] { userIds.Vectorize(), "badges" }, new
     {
         key = apiKey,
         page = options.Page ?? null,
         pagesize = options.PageSize ?? null,
         fromdate = options.FromDate.HasValue ? (long?)options.FromDate.Value.ToUnixTime() : null,
         todate = options.ToDate.HasValue ? (long?)options.ToDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(new PagedList<User>(items.Users, items)), onError);
 }
Ejemplo n.º 9
0
 public virtual void GetUsersByBadge(IEnumerable<int> badgeId, Action<IPagedList<User>> onSuccess, Action<ApiException> onError = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<UserResponse>("badges", new string[] { badgeId.Vectorize() }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(new PagedList<User>(items.Users, items)), onError);
 }
Ejemplo n.º 10
0
 public virtual void GetQuestionTimeline(IEnumerable<int> questionIds, Action<IPagedList<PostEvent>> onSuccess, Action<ApiException> onError = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<QuestionTimelineResponse>("questions", new string[] { questionIds.Vectorize(), "timeline" }, new
     {
         key = apiKey,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
         page = page ?? null,
         pagesize = pageSize ?? null
     }, (items) => onSuccess(new PagedList<PostEvent>(items.Events, items)), onError);
 }
Ejemplo n.º 11
0
 public virtual IPagedList<User> GetUsersByBadge(IEnumerable<int> badgeIds, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     var response = MakeRequest<UserResponse>("badges", new string[] { badgeIds.Vectorize() }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     });
     return new PagedList<User>(response.Users, response);
 }
Ejemplo n.º 12
0
 public virtual IPagedList<Reputation> GetUserReputation(IEnumerable<int> userIds, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     var response = MakeRequest<ReputationResponse>("users", new string[] { userIds.Vectorize(), "reputation" }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     });
     return new PagedList<Reputation>(response.Reputation, response);
 }
Ejemplo n.º 13
0
 public virtual IPagedList<PostEvent> GetQuestionTimeline(IEnumerable<int> questionIds, QuestionTimelineOptions options)
 {
     var response = MakeRequest<QuestionTimelineResponse>("questions", new string[] { questionIds.Vectorize(), "timeline" }, new
     {
         key = apiKey,
         page = options.Page ?? null,
         pagesize = options.PageSize ?? null,
         fromdate = options.FromDate.HasValue ? (long?)options.FromDate.Value.ToUnixTime() : null,
         todate = options.ToDate.HasValue ? (long?)options.ToDate.Value.ToUnixTime() : null
     });
     return new PagedList<PostEvent>(response.Events, response);
 }
Ejemplo n.º 14
0
 public virtual void GetQuestions(IEnumerable<int> questionIds, Action<IPagedList<Question>> onSuccess, Action<ApiException> onError = null, int? page = null, int? pageSize = null, bool includeBody = false, bool includeComments = false, bool includeAnswers = false)
 {
     MakeRequest<QuestionResponse>("questions", new string[] { questionIds.Vectorize() }, new
     {
         key = apiKey,
         body = includeBody ? (bool?)true : null,
         comments = includeComments ? (bool?)true : null,
         answers = includeAnswers ? (bool?)true : null,
         page = page ?? null,
         pagesize = pageSize ?? null
     }, (items) => onSuccess(new PagedList<Question>(items.Questions, items)), onError);
 }
Ejemplo n.º 15
0
 public virtual void GetCommentsByPost(IEnumerable<int> postIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError, CommentsByPostOptions options)
 {
     MakeRequest<CommentResponse>("posts", new string[] { postIds.Vectorize(), "comments" }, new
     {
         key = apiKey,
         page = options.Page ?? null,
         pagesize = options.PageSize ?? null,
         fromdate = options.FromDate.HasValue ? (long?)options.FromDate.Value.ToUnixTime() : null,
         todate = options.ToDate.HasValue ? (long?)options.ToDate.Value.ToUnixTime() : null,
         sort = options.SortBy.ToString().ToLower(),
         order = GetSortDirection(options.SortDirection),
     }, (items) => onSuccess(new PagedList<Comment>(items.Comments, items)), onError);
 }
Ejemplo n.º 16
0
 public virtual void GetCommentsByPost(IEnumerable<int> postIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError = null, CommentSort sortBy = CommentSort.Creation, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<CommentResponse>("posts", new string[] { postIds.Vectorize(), "comments" }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
         sort = sortBy.ToString().ToLower(),
         order = GetSortDirection(sortDirection),
     }, (items) => onSuccess(new PagedList<Comment>(items.Comments, items)), onError);
 }
Ejemplo n.º 17
0
        public virtual void GetComments(IEnumerable<int> fromUserIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError = null, CommentSort sortBy = CommentSort.Creation, SortDirection sortDirection = SortDirection.Descending, int? toUserId = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null)
        {
            string[] urlParameters = null;
            if (toUserId.HasValue)
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments", toUserId.ToString() };
            }
            else
            {
                urlParameters = new string[] { fromUserIds.Vectorize(), "comments" };
            }

            MakeRequest<CommentResponse>("users", urlParameters, new
            {
                key = apiKey,
                page = page ?? null,
                pagesize = pageSize ?? null,
                fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
                todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
                sort = sortBy.ToString().ToLower(),
                order = GetSortDirection(sortDirection)
            }, (items) => onSuccess(new PagedList<Comment>(items.Comments, items)), onError);
        }
Ejemplo n.º 18
0
 public virtual void GetAnswerComments(IEnumerable<int> answerIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError = null, CommentSort sortBy = CommentSort.Creation, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, int? min = null, int? max = null)
 {
     MakeRequest<CommentResponse>("answers", new string[] { answerIds.Vectorize(), "comments" }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
         sort = sortBy.ToString().ToLower(),
         order = GetSortDirection(sortDirection),
         min = min ?? null,
         max = max ?? null
     }, response => onSuccess(new PagedList<Comment>(response.Comments, response)), onError);
 }
Ejemplo n.º 19
0
 public virtual IPagedList<Comment> GetUserMentions(IEnumerable<int> userIds, UserMentionSort sortBy = UserMentionSort.Creation, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, int? min = null, int? max = null)
 {
     var response = MakeRequest<CommentResponse>("users", new string[] { userIds.Vectorize(), "mentioned" }, new
     {
         key = apiKey,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
         page = page ?? null,
         pagesize = pageSize ?? null,
         min = min ?? null,
         max = max ?? null,
         sort = sortBy.ToString().ToLower(),
         order = GetSortDirection(sortDirection)
     });
     return new PagedList<Comment>(response.Comments, response);
 }
Ejemplo n.º 20
0
 public virtual void GetAnswers(IEnumerable<int> answerIds, Action<IPagedList<Answer>> onSuccess, Action<ApiException> onError = null, AnswerSort sortBy = AnswerSort.Activity, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, bool includeBody = false, bool includeComments = false, int? min = null, int? max = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     MakeRequest<AnswerResponse>("answers", new string[] { answerIds.Vectorize() }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         body = includeBody ? (bool?)true : null,
         sort = sortBy.ToString().ToLower(),
         order = GetSortDirection(sortDirection),
         min = min ?? null,
         max = max ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     }, (items) => onSuccess(new PagedList<Answer>(items.Answers, items)), onError);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Gets the question answers.
 /// </summary>
 /// <param name="questionIds">The question ids.</param>
 /// <param name="sortBy">The sort by.</param>
 /// <param name="sortDirection">The sort direction.</param>
 /// <param name="page">The page.</param>
 /// <param name="pageSize">Size of the page.</param>
 /// <param name="includeBody">if set to <c>true</c> [include body].</param>
 /// <param name="includeComments">if set to <c>true</c> [include comments].</param>
 /// <param name="min">The min.</param>
 /// <param name="max">The max.</param>
 /// <param name="fromDate">From date.</param>
 /// <param name="toDate">To date.</param>
 /// <returns></returns>
 public virtual IPagedList<Answer> GetQuestionAnswers(IEnumerable<int> questionIds, QuestionsByUserSort sortBy = QuestionsByUserSort.Activity, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null, bool includeBody = false, bool includeComments = false, int? min = null, int? max = null, DateTime? fromDate = null, DateTime? toDate = null)
 {
     var response = MakeRequest<AnswerResponse>("questions", new string[] { questionIds.Vectorize(), "answers" }, new
     {
         key = apiKey,
         page = page ?? null,
         pagesize = pageSize ?? null,
         body = includeBody ? (bool?)true : null,
         sort = sortBy.ToString().ToLower(),
         order = GetSortDirection(sortDirection),
         min = min ?? null,
         max = max ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null
     });
     return new PagedList<Answer>(response.Answers, response);
 }
Ejemplo n.º 22
0
 public virtual IPagedList<Question> GetQuestions(IEnumerable<int> questionIds, int? page = null, int? pageSize = null, bool includeBody = false, bool includeComments = false, bool includeAnswers = false, DateTime? fromDate = null, DateTime? toDate = null, int? min = null, int? max = null, string[] tags = null)
 {
     var response = MakeRequest<QuestionResponse>("questions", new string[] { questionIds.Vectorize() }, new
     {
         key = apiKey,
         body = includeBody ? (bool?)true : null,
         comments = includeComments ? (bool?)true : null,
         answers = includeAnswers ? (bool?)true : null,
         page = page ?? null,
         pagesize = pageSize ?? null,
         fromdate = fromDate.HasValue ? (long?)fromDate.Value.ToUnixTime() : null,
         todate = toDate.HasValue ? (long?)toDate.Value.ToUnixTime() : null,
         min = min ?? null,
         max = max ?? null
     });
     return new PagedList<Question>(response.Questions, response);
 }
Ejemplo n.º 23
0
 public virtual void GetAnswerComments(IEnumerable<int> answerIds, Action<IPagedList<Comment>> onSuccess, Action<ApiException> onError, CommentsByPostOptions options)
 {
     MakeRequest<CommentResponse>("answers", new string[] { answerIds.Vectorize(), "comments" }, new
     {
         key = apiKey,
         page = options.Page ?? null,
         pagesize = options.PageSize ?? null,
         fromdate = options.FromDate.HasValue ? (long?)options.FromDate.Value.ToUnixTime() : null,
         todate = options.ToDate.HasValue ? (long?)options.ToDate.Value.ToUnixTime() : null,
         sort = options.SortBy.ToString().ToLower(),
         order = GetSortDirection(options.SortDirection),
         min = options.Min ?? null,
         max = options.Max ?? null
     }, response => onSuccess(new PagedList<Comment>(response.Comments, response)), onError);
 }
Ejemplo n.º 24
0
 public virtual void GetQuestionAnswers(IEnumerable<int> questionIds, Action<IPagedList<Answer>> onSuccess, Action<ApiException> onError, AnswerOptions options)
 {
     GetAnswers("questions", new string[] { questionIds.Vectorize(), "answers" }, onSuccess, onError, options);
 }
Ejemplo n.º 25
0
 public virtual void GetTagsByUser(IEnumerable<int> userIds, Action<IPagedList<Tag>> onSuccess, Action<ApiException> onError = null, int? page = null, int? pageSize = null)
 {
     //TODO: does this method support sort and order?
     GetTags(onSuccess, onError, "users", new string[] { userIds.Vectorize(), "tags" }, null, null, page, pageSize);
 }
Ejemplo n.º 26
0
 public virtual IPagedList<Tag> GetTagsByUser(IEnumerable<int> userIds, int? page = null, int? pageSize = null)
 {
     //TODO: does this method support sort and order?
     return GetTags("users", new string[] { userIds.Vectorize(), "tags" }, null, null, page, pageSize);
 }
Ejemplo n.º 27
0
 public virtual void GetTagsByUser(IEnumerable<int> userIds, Action<IPagedList<Tag>> onSuccess, Action<ApiException> onError, TagOptions options)
 {
     GetTags(onSuccess, onError, "users", new string[] { userIds.Vectorize(), "tags" }, options.Filter, options.SortBy.ToString(), GetSortDirection(options.SortDirection), options.Page, options.PageSize, options.FromDate, options.ToDate, options.Min, options.Max);
 }
Ejemplo n.º 28
0
 public virtual IPagedList<Tag> GetTagsByUser(IEnumerable<int> userIds, TagOptions options)
 {
     return GetTags("users", new string[] { userIds.Vectorize(), "tags" }, options.Filter, options.SortBy.ToString(), GetSortDirection(options.SortDirection), options.Page, options.PageSize, options.FromDate, options.ToDate, options.Min, options.Max);
 }
Ejemplo n.º 29
0
 public virtual IPagedList<Question> GetQuestions(IEnumerable<int> questionIds, QuestionOptions options)
 {
     var sortArgs = options.SortBy.GetAttribute<SortArgsAttribute>();
     string[] urlArgs = sortArgs.UrlArgs.Concat(new string[] { questionIds.Vectorize() }).ToArray();
     return GetQuestions("questions", urlArgs, sortArgs.Sort, GetSortDirection(options.SortDirection), options.Page, options.PageSize, options.IncludeBody, options.IncludeComments, options.IncludeAnswers, options.FromDate, options.ToDate, options.Min, options.Max, options.Tags);
 }