Commits

lfoust committed 3c6a0b7

Finished adding question methods

Comments (0)

Files changed (10)

trunk/data/V2.0 Upgrade Checklist.xlsx

Binary file modified.

trunk/source/Stacky.Net35/Stacky.Net35.csproj

     <Compile Include="..\Stacky\Entities\Question.cs">
       <Link>Entities\Question.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\QuestionTimeline.cs">
+      <Link>Entities\QuestionTimeline.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\RelatedSite.cs">
       <Link>Entities\RelatedSite.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\TagSynonymSort.cs">
       <Link>Enums\TagSynonymSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\TimelineType.cs">
+      <Link>Enums\TimelineType.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\TopUserPeriod.cs">
       <Link>Enums\TopUserPeriod.cs</Link>
     </Compile>

trunk/source/Stacky.Silverlight/Stacky.Silverlight.csproj

     <Compile Include="..\Stacky\Entities\Question.cs">
       <Link>Entities\Question.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\QuestionTimeline.cs">
+      <Link>Entities\QuestionTimeline.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\RelatedSite.cs">
       <Link>Entities\RelatedSite.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\TagSynonymSort.cs">
       <Link>Enums\TagSynonymSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\TimelineType.cs">
+      <Link>Enums\TimelineType.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\TopUserPeriod.cs">
       <Link>Enums\TopUserPeriod.cs</Link>
     </Compile>

trunk/source/Stacky.WindowsPhone/Stacky.WindowsPhone.csproj

     <Compile Include="..\Stacky\Entities\Question.cs">
       <Link>Entities\Question.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Entities\QuestionTimeline.cs">
+      <Link>Entities\QuestionTimeline.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Entities\RelatedSite.cs">
       <Link>Entities\RelatedSite.cs</Link>
     </Compile>
     <Compile Include="..\Stacky\Enums\TagSynonymSort.cs">
       <Link>Enums\TagSynonymSort.cs</Link>
     </Compile>
+    <Compile Include="..\Stacky\Enums\TimelineType.cs">
+      <Link>Enums\TimelineType.cs</Link>
+    </Compile>
     <Compile Include="..\Stacky\Enums\TopUserPeriod.cs">
       <Link>Enums\TopUserPeriod.cs</Link>
     </Compile>

trunk/source/Stacky/Entities/QuestionTimeline.cs

+using System;
+using Newtonsoft.Json;
+
+namespace Stacky
+{
+    public class QuestionTimeline : Entity
+    {
+        private TimelineType timelineType;
+        [JsonProperty("timeline_type")]
+        public TimelineType TimelineType
+        {
+            get { return timelineType; }
+            set { timelineType = value; NotifyOfPropertyChange(() => TimelineType); }
+        }
+
+        private int questionId;
+        [JsonProperty("question_id")]
+        public int QuestionId
+        {
+            get { return questionId; }
+            set { questionId = value; NotifyOfPropertyChange(() => QuestionId); }
+        }
+
+        private int postId;
+        [JsonProperty("post_id")]
+        public int PostId
+        {
+            get { return postId; }
+            set { postId = value; NotifyOfPropertyChange(() => PostId); }
+        }
+
+        private int commentId;
+        [JsonProperty("comment_id")]
+        public int CommentId
+        {
+            get { return commentId; }
+            set { commentId = value; NotifyOfPropertyChange(() => CommentId); }
+        }
+
+        private Guid revisionGuid;
+        [JsonProperty("revision_guid")]
+        public Guid RevisionGuid
+        {
+            get { return revisionGuid; }
+            set { revisionGuid = value; NotifyOfPropertyChange(() => RevisionGuid); }
+        }
+
+        private int upVoteCount;
+        [JsonProperty("up_vote_count")]
+        public int UpVoteCount
+        {
+            get { return upVoteCount; }
+            set { upVoteCount = value; NotifyOfPropertyChange(() => UpVoteCount); }
+        }
+
+        private int downVoteCount;
+        [JsonProperty("down_vote_count")]
+        public int DownVoteCount
+        {
+            get { return downVoteCount; }
+            set { downVoteCount = value; NotifyOfPropertyChange(() => DownVoteCount); }
+        }
+
+        private DateTime creationDate;
+        [JsonProperty("creation_date")]
+        public DateTime CreationDate
+        {
+            get { return creationDate; }
+            set { creationDate = value; NotifyOfPropertyChange(() => CreationDate); }
+        }
+
+        private ShallowUser user;
+        [JsonProperty("user")]
+        public ShallowUser User
+        {
+            get { return user; }
+            set { user = value; NotifyOfPropertyChange(() => User); }
+        }
+
+        private ShallowUser owner;
+        [JsonProperty("owner")]
+        public ShallowUser Owner
+        {
+            get { return owner; }
+            set { owner = value; NotifyOfPropertyChange(() => Owner); }
+        }
+    }
+}

trunk/source/Stacky/Enums/TimelineType.cs

+namespace Stacky
+{
+    using System.Runtime.Serialization;
+
+    public enum TimelineType
+    {
+        Question,
+        Answer,
+        Comment,
+        [EnumMember(Value = "unaccepted_answer")]
+        UnacceptedAnswer,
+        [EnumMember(Value = "accepted_answer")]
+        AcceptedAnswer,
+        [EnumMember(Value = "vote_aggregate")]
+        VoteAggregate,
+        Revision,
+        [EnumMember(Value = "post_state_changed")]
+        PostStateChanged
+    }
+}

trunk/source/Stacky/Stacky.csproj

     <Compile Include="Entities\PostEvent.cs" />
     <Compile Include="Entities\Privilege.cs" />
     <Compile Include="Entities\Question.cs" />
+    <Compile Include="Entities\QuestionTimeline.cs" />
     <Compile Include="Entities\RelatedSite.cs" />
     <Compile Include="Entities\Reputation.cs" />
     <Compile Include="Entities\ResponseError.cs" />
     <Compile Include="Entities\Tag.cs" />
     <Compile Include="Entities\TagSynonym.cs" />
     <Compile Include="Entities\TagWiki.cs" />
+    <Compile Include="Enums\TimelineType.cs" />
     <Compile Include="Entities\TopTag.cs" />
     <Compile Include="Entities\TopUser.cs" />
     <Compile Include="Entities\User.cs" />

trunk/source/Stacky/StackyClient/AnswerMethods.cs

             return new PagedList<Answer>(response);
         }
 
-        /// <summary>
-        /// Gets the question answers.
-        /// </summary>
-        /// <param name="questionId">The question id.</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(int questionId, 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)
-        {
-            return GetQuestionAnswers(questionId.ToArray(), sortBy, sortDirection, page, pageSize, includeBody, includeComments, min, max, fromDate, toDate);
-        }
-
         public virtual Answer GetAnswer(int answerId, bool includeBody = true, bool includeComments = true)
         {
             return GetAnswers(answerId.ToArray(), includeBody: includeBody, includeComments : includeComments).FirstOrDefault();

trunk/source/Stacky/StackyClient/PostMethods.cs

 
         public IPagedList<Post> GetPosts(IEnumerable<int> ids, PostSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
         {
+            ValidateVectorizedParameters(ids);
             return Execute<Post>("posts", new string[] { ids.Vectorize() },
                 sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
         }
 
         public IPagedList<Comment> GetPostComments(IEnumerable<int> ids, CommentSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
         {
+            ValidateVectorizedParameters(ids);
             return Execute<Comment>("posts", new string[] { ids.Vectorize(), "comments" },
                 sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
         }
 
         public IPagedList<Revision> GetPostRevisions(IEnumerable<int> ids, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, string filter = null)
         {
+            ValidateVectorizedParameters(ids);
             return Execute<Revision>("posts", new string[] { ids.Vectorize(), "revisions" },
                 null, null, page, pageSize, fromDate, toDate, null, null, filter);
         }
 
         public IPagedList<SuggestedEdit> GetPostSuggestedEdits(IEnumerable<int> ids, SuggestedEditSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, string filter = null)
         {
+            ValidateVectorizedParameters(ids);
             return Execute<SuggestedEdit>("posts", new string[] { ids.Vectorize(), "suggested-edits" },
                 null, null, page, pageSize, fromDate, toDate, null, null, filter);
         }

trunk/source/Stacky/StackyClient/QuestionMethods.cs

 {
     public partial class StackyClient
     {
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/questions
+        /// </summary>
         public IPagedList<Question> GetQuestions(QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
         {
             return Execute<Question>("questions", null,
                 sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
         }
 
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/questions-by-ids
+        /// </summary>
         public Question GetQuestion(int id, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
         {
             return GetQuestions(id.ToArray(), sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter).FirstOrDefault();
         }
 
+        /// <summary>
+        /// https://api.stackexchange.com/docs/questions-by-ids
+        /// </summary>
         public IPagedList<Question> GetQuestions(IEnumerable<int> ids, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
         {
+            ValidateVectorizedParameters(ids);
             return Execute<Question>("questions", new string[] { ids.Vectorize() },
                 sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
         }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/answers-on-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Answer> GetQuestionAnswers(int id, AnswerSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            return GetQuestionAnswers(id.ToArray(), sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/answers-on-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Answer> GetQuestionAnswers(IEnumerable<int> ids, AnswerSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            ValidateVectorizedParameters(ids);
+            return Execute<Answer>("questions", new string[] { ids.Vectorize(), "answers" },
+                sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/comments-on-questions
+        /// </summary>
+        public IPagedList<Comment> GetQuestionComments(int id, CommentSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            return GetQuestionComments(id.ToArray(), sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/comments-on-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Comment> GetQuestionComments(IEnumerable<int> ids, CommentSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            ValidateVectorizedParameters(ids);
+            return Execute<Comment>("questions", new string[] { ids.Vectorize(), "comments" },
+                sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/linked-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetLinkedQuestions(int id, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            return GetLinkedQuestions(id.ToArray(), sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/linked-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetLinkedQuestions(IEnumerable<int> ids, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            ValidateVectorizedParameters(ids);
+            return Execute<Question>("questions", new string[] { ids.Vectorize(), "linked" },
+                sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/linked-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetRelatedQuestions(int id, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            return GetRelatedQuestions(id.ToArray(), sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/linked-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetRelatedQuestions(IEnumerable<int> ids, QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string filter = null)
+        {
+            ValidateVectorizedParameters(ids);
+            return Execute<Question>("questions", new string[] { ids.Vectorize(), "related" },
+                sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/questions-timeline
+        /// </summary>
+        public IPagedList<QuestionTimeline> GetQuestionTimeline(int id, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, string filter = null)
+        {
+            return GetQuestionTimeline(id.ToArray(), page, pageSize, fromDate, toDate, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/questions-timeline
+        /// </summary>
+        public IPagedList<QuestionTimeline> GetQuestionTimeline(IEnumerable<int> ids, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, string filter = null)
+        {
+            ValidateVectorizedParameters(ids);
+            return Execute<QuestionTimeline>("questions", new string[] { ids.Vectorize(), "timeline" },
+                null, null, page, pageSize, fromDate, toDate, null, null, filter);
+        }
+
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/unanswered-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetUnansweredQuestions(QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string tagged = null, string filter = null)
+        {
+            var response = MakeRequest<Question>("questions", new string[] { "unanswered" }, new
+            {
+                site = this.SiteUrlName,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                fromdate = GetDateValue(fromDate),
+                todate = GetDateValue(toDate),
+                sort = GetEnumValue(sortBy),
+                order = GetSortDirection(sortDirection),
+                min = GetDateValue(min),
+                max = GetDateValue(max),
+                tagged = tagged,
+                filter = filter
+            });
+            return new PagedList<Question>(response);
+        }
+
+        // <summary>
+        /// See https://api.stackexchange.com/docs/unanswered-questions
+        /// </summary>
+        /// TODO: Fix Sort
+        public IPagedList<Question> GetQuestionsWithNoAnswers(QuestionSort? sortBy = null, SortDirection? sortDirection = null, int? page = null, int? pageSize = null, DateTime? fromDate = null, DateTime? toDate = null, DateTime? min = null, DateTime? max = null, string tagged = null, string filter = null)
+        {
+            var response = MakeRequest<Question>("questions", new string[] { "no-answers" }, new
+            {
+                site = this.SiteUrlName,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                fromdate = GetDateValue(fromDate),
+                todate = GetDateValue(toDate),
+                sort = GetEnumValue(sortBy),
+                order = GetSortDirection(sortDirection),
+                min = GetDateValue(min),
+                max = GetDateValue(max),
+                tagged = tagged,
+                filter = filter
+            });
+            return new PagedList<Question>(response);
+        }
     }
 }