public async Task<PrivateMessageMetadata> RefreshAsync(string privateMessageId)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("private.php");
     endpoint.AddParameter("action", "show");
     endpoint.AddParameter("privatemessageid", privateMessageId);
     var doc = await endpoint.GetHtmlAsync(this.Client);
     return PrivateMessageParser.ParsePrivateMessageDocument(doc);
 }
 public async Task<IPrivateMessageRequest> CreateNewPrivateMessageAsync()
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("private.php");
     endpoint.AddParameter("action", "newmessage");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     return PrivateMessageParser.ParseNewPrivateMessageFormDocument(doc);
 }
 public Task<bool> MarkAsReadAsync(string threadid, string threadIndex)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("showthread.php");
     endpoint.AddParameter("action", "setseen");
     endpoint.AddParameter("threadid", threadid);
     endpoint.AddParameter("index", threadIndex);
     return endpoint.SendAndConfirmAsync(this.Client);
 }
 public async Task<ThreadPageMetadata> RefreshAsync(string threadid, int pagenumber)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("showthread.php");
     endpoint.AddParameter("threadid", threadid);
     endpoint.AddParameter("pagenumber", pagenumber);
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var result = Task.Run(() => { return ThreadPageParser.ParseThreadPage(doc); });
     return await result;
 }
 public async Task<UserSettings> GetUserSettingsAsync()
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("member.php");
     endpoint.AddParameter("action", "editoptions");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var settings = Task.Run(() => { return UserSettings.FromHtmlDocument(doc); });
     return await settings;
 }
        public Task<bool> RateAsync(string threadid, int rating)
        {
            if (rating < MIN_RATING || rating > MAX_RATING)
                throw new ArgumentOutOfRangeException(string.Format(
                    "Rating must be between {0} and {1}.", MIN_RATING, MAX_RATING));

            HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("threadrate.php");
            endpoint.AddParameter("vote", rating);
            endpoint.AddParameter("threadid", threadid);
            return endpoint.SendAndConfirmAsync(this.Client);
        }
 public async Task<ThreadPageMetadata> GetNewPostAsync(string threadID)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("showthread.php");
     endpoint.AddParameter("threadid", threadID);
     endpoint.AddParameter("goto", "newpost");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var result = Task.Run(() => { return ThreadPageParser.ParseThreadPage(doc); });
     return await result;
 }
 public async Task<PrivateMessageFolderEditor> EditPrivateMessageFoldersAsync()
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("private.php");
     endpoint.AddParameter("action", "editfolders");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var result = Task.Run(() => { return PrivateMessageParser.ParseEditFolderPage(doc); });
     return await result;
 }
 public async Task<IThreadForm> GetThreadReplyFormAsync(string threadid)
 {
     // http://forums.somethingawful.com/newreply.php?action=newreply&threadid=3545394
     HtmlDocument formDocument = null;
     HttpGetRequestBuilder request = new HttpGetRequestBuilder("newreply.php");
     request.AddParameter("action", "newreply");
     request.AddParameter("threadid", threadid);
     formDocument = await request.GetHtmlAsync(this.Client);
     return ThreadReplyForm.FromHtmlDocument(formDocument);
 }
        public async Task<ThreadPageMetadata> GetThreadPageAsync(string threadID, int pageNumber = 1)
        {
            HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("showthread.php");
            endpoint.AddParameter("threadid", threadID);
            endpoint.AddParameter("pagenumber", pageNumber);

            var htmlDoc = await endpoint.GetHtmlAsync(this.Client);
            return ThreadPageParser.ParseThreadPage(htmlDoc);
        }
 private async Task<IEnumerable<ForumMetadata>> GetShallowForumListAsync()
 {
     var endpoint = new HttpGetRequestBuilder("index.php");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     Task<IEnumerable<ForumMetadata>> forumList = Task.Run(() => { return ForumParser.ParseShallowForumList(doc); });
     return await forumList;
 }
 private async Task<IEnumerable<ForumMetadata>> GetDeepForumListAsync()
 {
     var endpoint = new HttpGetRequestBuilder("forumdisplay.php");
     endpoint.AddParameter("forumid", "1");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var forumList = Task.Run(() => { return ForumParser.ParseForumList(doc); });
     var forums = await GetForumDescriptionsAsync(await forumList, this.Client);
     return forums;
 }
 public async Task<IEnumerable<TagMetadata>> GetSmiliesAsync()
 {
     List<TagMetadata> list = null;
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("misc.php");
     endpoint.AddParameter("action", "showsmilies");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var smilies = Task.Run(() => { return SmileyParser.ParseSmiliesFromHtml(doc); });
     list.AddRange(await smilies);
     return list;
 }
 public async Task<IEnumerable<PrivateMessageFolderMetadata>> GetPrivateMessageFoldersAsync(bool loadInbox = true)
 {
     var endpoint = new HttpGetRequestBuilder("private.php");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     List<PrivateMessageFolderMetadata> items = new List<PrivateMessageFolderMetadata>();
     var folders = Task.Run(() => { return PrivateMessageParser.ParseFolderList(doc); });
     items.AddRange(await folders);
     if (loadInbox)
     {
         var inbox = Task.Run(() => { return PrivateMessageParser.ParseMessageList(doc); });
         List<PrivateMessageMetadata> messages = new List<PrivateMessageMetadata>();
         messages.AddRange(await inbox);
         items[0].Messages = messages;
     }
     return items;
 }
        public async Task<string> QuoteAsync(string postId)
        {
            HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("newreply.php");
            endpoint.AddParameter("action", "newreply");
            endpoint.AddParameter("postid", postId);
            var doc = await endpoint.GetHtmlAsync(this.Client);
            var bodyNode = doc.DocumentNode.Descendants("body").First();

            if (bodyNode.GetAttributeValue("class", string.Empty).Equals("standarderror"))
                throw new InvalidOperationException("Only registered members can quote posts.");

            string body = doc.DocumentNode.Descendants("textarea").First().InnerText;
            return WebUtility.HtmlDecode(body);
        }
 public async Task<PrivateMessageFolderMetadata> RefreshPrivateMessageFolderAsync(string folderId)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("private.php");
     endpoint.AddParameter("folderid", folderId);
     endpoint.AddParameter("daysprune", "9999");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     return PrivateMessageParser.ParsePrivateMessageFolder(doc);
 }
 public async Task<IThreadForm> BeginEditPostAsync(string postId)
 {
     HttpGetRequestBuilder endpoint = new HttpGetRequestBuilder("editpost.php");
     endpoint.AddParameter("action", "editpost");
     endpoint.AddParameter("postid", postId);
     var result = await endpoint.GetHtmlAsync(this.Client);
     PostEditForm form = PostEditForm.FromHtmlDocument(postId, result);
     return form;
 }
 public async Task<INewThreadRequest> BeginNewThreadAsync(string forumid)
 {
     var request = new HttpGetRequestBuilder("newthread.php");
     request.AddParameter("forumid", forumid);
     var doc = await request.GetHtmlAsync(this.Client);
     var result = Task.Run(() => 
     {
         var form = NewThreadRequest.ParseNewThreadRequest(doc);
         form.ForumId = forumid;
         return form;
     });
     return await result;
 }
 public async Task<UserFeatures> GetUserFeaturesAsync()
 {
     var endpoint = new HttpGetRequestBuilder("member.php");
     var doc = await endpoint.GetHtmlAsync(this.Client);
     var features = Task.Run(() => { return UserFeatures.FromHtmlDocument(doc); });
     return await features;
 }