示例#1
0
        /// <summary>
        /// Moves the specified thread to the trash.
        /// </summary>
        /// <param name="id">The ID of the thread to Trash</param>
        /// <returns></returns>
        public async Task <MessageThread> TrashAsync(string id)
        {
            string queryString = new ThreadQueryStringBuilder()
                                 .SetRequestAction(ThreadRequestAction.Trash, id)
                                 .Build();

            return(await _proxy.Post <MessageThread>(queryString));
        }
示例#2
0
        /// <summary>
        /// Modifies the labels applied to the thread. This applies to all messages in the thread.
        /// </summary>
        /// <param name="id">The ID of the thread to modify</param>
        /// <param name="input">The input to modify a thread</param>
        /// <returns></returns>
        public async Task <MessageThread> ModifyAsync(string id, ModifyThreadInput input)
        {
            string queryString = new ThreadQueryStringBuilder()
                                 .SetRequestAction(ThreadRequestAction.Modify, id)
                                 .Build();

            return(await _proxy.Post <MessageThread>(queryString, input));
        }
示例#3
0
        /// <summary>
        /// Immediately and permanently deletes the specified thread. WARNING: This operation cannot be undone. Prefer threads.trash instead.
        /// </summary>
        /// <param name="id">ID of the Thread to delete.</param>
        /// <returns></returns>
        public async Task DeleteAsync(string id)
        {
            string queryString = new ThreadQueryStringBuilder()
                                 .SetRequestAction(ThreadRequestAction.Delete, id)
                                 .Build();

            await _proxy.Delete(queryString);
        }
示例#4
0
        /// <summary>
        /// Lists the thread IDs.
        /// </summary>
        /// <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>
        /// <param name="labelIds">Only return threads with labels that match all of the specified label IDs</param>
        /// <returns>A <see cref="ThreadList"/> containing the thread IDs</returns>
        public async Task <ThreadList> ListIdsAsync(string query = null, ushort maxResults = 0, bool includeSpamAndTrash = false, params string[] labelIds)
        {
            string queryString = new ThreadQueryStringBuilder()
                                 .SetRequestAction(ThreadRequestAction.List)
                                 .SetFields(ThreadFields.Id | ThreadFields.ResultSizeEstimate | ThreadFields.NextPageToken)
                                 .SetQuery(query)
                                 .SetLabelIds(labelIds)
                                 .SetMaxResults(maxResults)
                                 .SetIncludeSpamAndTrash(includeSpamAndTrash)
                                 .Build();

            return(await _proxy.Get <ThreadList>(queryString));
        }
示例#5
0
        public void CanBuild()
        {
            // Arrange
            var builder = new ThreadQueryStringBuilder()
                          .SetRequestAction(ThreadRequestAction.List)
                          .SetFormat(ThreadFormat.Minimal)
                          .SetMetadataHeaders(new[] { "header1", "header2" });

            // Act
            string queryString = builder.Build();

            // Assert
            queryString.Should().NotBeNullOrWhiteSpace();
        }
示例#6
0
        public void SetHeaders_OverwritesFormat()
        {
            // Act
            string queryString = new ThreadQueryStringBuilder()
                                 .SetFormat(ThreadFormat.Minimal)
                                 .SetMetadataHeaders(new[] { "header1" })
                                 .Build();

            // Arrange
            queryString = queryString.Substring(queryString.IndexOf('?'));
            var    collection = HttpUtility.ParseQueryString(queryString);
            string value      = collection["format"];

            // Assert
            value.Should().Be(ThreadFormat.Metadata.ToString());
        }