/// <summary> /// Lists the threads in the specified label. /// </summary> /// <param name="service">Gmail API service instance</param> /// <param name="labelId">Only return threads with the specified label ID</param> /// <param name="query">Only return threads matching the specified query. /// Supports the same query format as the Gmail search box. For example, "from:[email protected] rfc822msgid: is:unread".</param> /// <param name="maxResults">Maximum number of threads to return</param> /// <param name="includeSpamAndTrash">Include threads from SPAM and TRASH in the results.</param> /// <returns>A list of threads</returns> public static async Task <IList <MessageThread> > ListByLabelAsync(this ThreadService service, string labelId, string query = null, ushort maxResults = 0, bool includeSpamAndTrash = false) { var threadList = await service.ListIdsAsync(query, maxResults, includeSpamAndTrash, labelId); var tasks = threadList.Threads.Select(id => service.GetAsync(id.Id)); return((await Task.WhenAll(tasks)).ToList()); }
//[Fact] TODO: implement public void CanListIds() { // Act Func <Task> action = async() => await _service.ListIdsAsync(); // Assert action.ShouldNotThrow(); }
/// <summary> /// Lists the thread IDs of the user's inbox. /// </summary> /// <param name="service">Gmail API service instance</param> /// <returns>A <see cref="ThreadList"/> instance</returns> public static async Task <ThreadList> ListIdsAsync(this ThreadService service) { return(await service.ListIdsAsync(labelIds : Label.Inbox)); }
/// <summary> /// Get the number of estimated threads of the specified label. /// </summary> /// <param name="service">Gmail API service instance</param> /// <param name="labelIds">Only return threads with labels that match all of the specified label IDs</param> /// <returns>The number of threads</returns> public static async Task <uint> CountAsync(this ThreadService service, params string[] labelIds) { return((await service.ListIdsAsync(labelIds: labelIds)).ResultSizeEstimate); }