Commits

lfoust committed 7e2769b

Added the methods that need authentication

Comments (0)

Files changed (7)

trunk/source/Stacky/Entities/Event.cs

+using System;
+using Newtonsoft.Json;
+
+namespace Stacky
+{
+    /// <summary>
+    /// See: http://api.stackexchange.com/docs/types/event
+    /// </summary>
+    public class Event : Entity
+    {
+        private EventType type;
+        [JsonProperty("event_type")]
+        public EventType Type
+        {
+            get { return type; }
+            set { type = value; NotifyOfPropertyChange(() => Type); }
+        }
+
+        private int id;
+        [JsonProperty("event_id")]
+        public int Id
+        {
+            get { return id; }
+            set { id = value; NotifyOfPropertyChange(() => Id); }
+        }
+
+        private DateTime creationDate;
+        [JsonProperty("creation_date"), JsonConverter(typeof(UnixDateTimeConverter))]
+        public DateTime CreationDate
+        {
+            get { return creationDate; }
+            set { creationDate = value; NotifyOfPropertyChange(() => CreationDate); }
+        }
+
+        private string link;
+        [JsonProperty("link")]
+        public string Link
+        {
+            get { return link; }
+            set { link = value; NotifyOfPropertyChange(() => Link); }
+        }
+
+        private string excerpt;
+        [JsonProperty("excerpt")]
+        public string Excerpt
+        {
+            get { return excerpt; }
+            set { excerpt = value; NotifyOfPropertyChange(() => Excerpt); }
+        }
+    }
+}

trunk/source/Stacky/Entities/InboxItem.cs

+namespace Stacky
+{
+    using System;
+    using Newtonsoft.Json;
+
+    /// <summary>
+    /// See: http://api.stackexchange.com/docs/types/inbox-item
+    /// </summary>
+    public class InboxItem : Entity
+    {
+        private InboxItemType itemType;
+        [JsonProperty("item_type")]
+        public InboxItemType ItemType
+        {
+            get { return itemType; }
+            set { itemType = value; NotifyOfPropertyChange(() => ItemType); }
+        }
+
+        private int questionId;
+        [JsonProperty("question_id")]
+        public int QuestionId
+        {
+            get { return questionId; }
+            set { questionId = value; NotifyOfPropertyChange(() => QuestionId); }
+        }
+
+        private int answerId;
+        [JsonProperty("answer_id")]
+        public int AnswerId
+        {
+            get { return answerId; }
+            set { answerId = value; NotifyOfPropertyChange(() => AnswerId); }
+        }
+
+        private int commentId;
+        [JsonProperty("comment_id")]
+        public int CommentId
+        {
+            get { return commentId; }
+            set { commentId = value; NotifyOfPropertyChange(() => CommentId); }
+        }
+
+        private string title;
+        [JsonProperty("title")]
+        public string Title
+        {
+            get { return title; }
+            set { title = value; NotifyOfPropertyChange(() => Title); }
+        }
+
+        private DateTime creationDate;
+        [JsonProperty("creation_date"), JsonConverter(typeof(UnixDateTimeConverter))]
+        public DateTime CreationDate
+        {
+            get { return creationDate; }
+            set { creationDate = value; NotifyOfPropertyChange(() => CreationDate); }
+        }
+
+        private bool isUnread;
+        [JsonProperty("is_unread")]
+        public bool IsUnread
+        {
+            get { return isUnread; }
+            set { isUnread = value; NotifyOfPropertyChange(() => IsUnread); }
+        }
+
+        private Site site;
+        [JsonProperty("site")]
+        public Site Site
+        {
+            get { return site; }
+            set { site = value; NotifyOfPropertyChange(() => Site); }
+        }
+
+        private string body;
+        [JsonProperty("body")]
+        public string Body
+        {
+            get { return body; }
+            set { body = value; NotifyOfPropertyChange(() => Body); }
+        }
+
+        private string link;
+        [JsonProperty("link")]
+        public string Link
+        {
+            get { return link; }
+            set { link = value; NotifyOfPropertyChange(() => Link); }
+        }
+    }
+}

trunk/source/Stacky/Enums/EventType.cs

+namespace Stacky
+{
+    using System.Runtime.Serialization;
+
+    public enum EventType
+    {
+        [EnumMember(Value = "question_posted")]
+        QuestionPosted,
+        [EnumMember(Value = "answer_posted")]
+        AnswerPosted,
+        [EnumMember(Value = "comment_posted")]
+        CommentPosted,
+        [EnumMember(Value = "post_edited")]
+        PostEdited,
+        [EnumMember(Value = "user_created")]
+        UserCreated
+    }
+}

trunk/source/Stacky/Enums/InboxItemType.cs

+namespace Stacky
+{
+    using System.Runtime.Serialization;
+
+    public enum InboxItemType
+    {
+        Comment,
+        [EnumMember(Value = "chat_message")]
+        ChatMessage,
+        [EnumMember(Value = "new_answer")]
+        NewAnswer,
+        [EnumMember(Value = "careers_message")]
+        CareersMessage,
+        [EnumMember(Value = "careers_invitations")]
+        CareersInvitation,
+        [EnumMember(Value = "meta_question")]
+        MetaQuestion
+    }
+}

trunk/source/Stacky/StackyClient/EventMethods.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Stacky
+{
+    public partial class StackyClient
+    {
+        public IPagedList<Event> GetEvents(string accessToken, DateTime? since = null, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<Event>("events", null, new
+            {
+                site = this.SiteUrlName,
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                since = GetDateValue(since)
+            });
+            return new PagedList<Event>(response);
+        }
+    }
+}

trunk/source/Stacky/StackyClient/InboxMethods.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Stacky
+{
+    public partial class StackyClient
+    {
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetGlobalInbox(string accessToken, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("inbox", null, new
+            {
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null
+            });
+            return new PagedList<InboxItem>(response);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetUnreadGlobalInbox(string accessToken, DateTime? since = null, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("inbox", new string[] { "unread" }, new
+            {
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                since = GetDateValue(since)
+            });
+            return new PagedList<InboxItem>(response);
+        }
+    }
+}

trunk/source/Stacky/StackyClient/UserMethods.cs

             return Execute<User, Int32>("users", new string[] { "moderators", "elected" },
                 sortBy, sortDirection, page, pageSize, fromDate, toDate, min, max, filter);
         }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/me-unread-inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetMyUnreadInbox(string accessToken, DateTime? since = null, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("me", new string[] { "inbox", "unread" }, new
+            {
+                //key = TODO: add key here?
+                site = this.SiteUrlName,
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                since = GetDateValue(since)
+            });
+            return new PagedList<InboxItem>(response);
+        }
+
+        /// <summary>
+        /// See: https://api.stackexchange.com/docs/user-unread-inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetUnreadInbox(int userId, string accessToken, DateTime? since = null, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("users", new string[] { userId.ToString(), "inbox", "unread" }, new
+            {
+                site = this.SiteUrlName,
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null,
+                since = GetDateValue(since)
+            });
+            return new PagedList<InboxItem>(response);
+        }
+
+        /// <summary>
+        /// See: https://api.stackexchange.com/docs/user-inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetInbox(int userId, string accessToken, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("users", new string[] { userId.ToString(), "inbox" }, new
+            {
+                site = this.SiteUrlName,
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null
+            });
+            return new PagedList<InboxItem>(response);
+        }
+
+        /// <summary>
+        /// See: https://api.stackexchange.com/docs/user-inbox
+        /// </summary>
+        public IPagedList<InboxItem> GetMyInbox(string accessToken, int? page = null, int? pageSize = null)
+        {
+            var response = MakeRequest<InboxItem>("me", new string[] { "inbox" }, new
+            {
+                //key = TODO: add key here?
+                site = this.SiteUrlName,
+                access_token = accessToken,
+                page = page ?? null,
+                pagesize = pageSize ?? null
+            });
+            return new PagedList<InboxItem>(response);
+        }
+
+
     }
 }