• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rwjdk / TrelloDotNet / 5986049453

26 Aug 2023 05:15PM UTC coverage: 70.85% (-0.2%) from 71.075%
5986049453

push

github

rwjdk
Added GetCommentReactions

825 of 1493 branches covered (0.0%)

Branch coverage included in aggregate %.

14 of 14 new or added lines in 4 files covered. (100.0%)

2077 of 2603 relevant lines covered (79.79%)

63.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.59
/TrelloDotNet/TrelloDotNet/TrelloClient.Comments.cs
1
using System.Collections.Generic;
2
using System.Linq;
3
using System.Threading;
4
using System.Threading.Tasks;
5
using TrelloDotNet.Model;
6
using TrelloDotNet.Model.Actions;
7

8
namespace TrelloDotNet
9
{
10
    public partial class TrelloClient
11
    {
12
        /// <summary>
13
        /// Add a new Comment on a Card
14
        /// </summary>
15
        /// <paramref name="cardId">Id of the Card</paramref>
16
        /// <paramref name="comment">The Comment</paramref>
17
        /// <returns>The Comment Action</returns>
18
        public async Task<TrelloAction> AddCommentAsync(string cardId, Comment comment, CancellationToken cancellationToken = default)
19
        {
20
            return await _apiRequestController.Post<TrelloAction>($"{UrlPaths.Cards}/{cardId}/actions/comments", cancellationToken, _queryParametersBuilder.GetViaQueryParameterAttributes(comment));
54✔
21
        }
54✔
22

23
        /// <summary>
24
        /// Update a comment Action (aka only way to update comments as they are not seen as their own objects)
25
        /// </summary>
26
        /// <param name="commentAction">The comment Action with the updated text</param>
27
        /// <param name="cancellationToken">Cancellation Token</param>
28
        public async Task<TrelloAction> UpdateCommentActionAsync(TrelloAction commentAction, CancellationToken cancellationToken = default)
29
        {
30
            return await _apiRequestController.Put<TrelloAction>($"{UrlPaths.Actions}/{commentAction.Id}", cancellationToken, new QueryParameter(@"text", commentAction.Data.Text));
1✔
31
        }
1✔
32

33
        /// <summary>
34
        /// Delete a Comment (WARNING: THERE IS NO WAY GOING BACK!!!).
35
        /// </summary>
36
        /// <param name="commentActionId">Id of Comment Action Id</param>
37
        /// <param name="cancellationToken">Cancellation Token</param>
38
        public async Task DeleteCommentActionAsync(string commentActionId, CancellationToken cancellationToken = default)
39
        {
40
            await _apiRequestController.Delete($"{UrlPaths.Actions}/{commentActionId}", cancellationToken, 0);
2✔
41
        }
2✔
42

43
/// <summary>
44
/// Get All Comments on a Card
45
/// </summary>
46
/// <param name="cardId">Id of Card</param>
47
/// <param name="cancellationToken">Cancellation Token</param>
48
/// <returns>List of Comments</returns>
49
public async Task<List<TrelloAction>> GetAllCommentsOnCardAsync(string cardId, CancellationToken cancellationToken = default)
50
        {
51
            var result = new List<TrelloAction>();
5✔
52
            int page = 0;
5✔
53
            bool moreComments = true;
5✔
54
            do
55
            {
56
                var comments = await GetPagedCommentsOnCardAsync(cardId, page, cancellationToken);
9✔
57
                page++;
9✔
58
                if (comments.Any())
9✔
59
                {
60
                    result.AddRange(comments);
4✔
61
                }
62
                else
63
                {
64
                    moreComments = false;
5✔
65
                }
66
            } while (moreComments);
9✔
67

68
            return result;
5✔
69
        }
5✔
70

71
        /// <summary>
72
        /// Get Paged Comments on a Card (Note: this method can max return up to 50 comments. For more use the page parameter [note: the API can't give you back how many there are in total so you need to try until non is returned])
73
        /// </summary>
74
        /// <param name="cardId">Id of Card</param>
75
        /// <param name="page">The page of results for actions. Each page of results has 50 actions. (Default: 0, Maximum: 19)</param>
76
        /// <param name="cancellationToken">Cancellation Token</param>
77
        /// <returns>List of Comments</returns>
78
        public async Task<List<TrelloAction>> GetPagedCommentsOnCardAsync(string cardId, int page = 0, CancellationToken cancellationToken = default)
79
        {
80
            return await _apiRequestController.Get<List<TrelloAction>>($"{UrlPaths.Cards}/{cardId}/actions", cancellationToken,
11✔
81
                new QueryParameter(@"filter", @"commentCard"),
11✔
82
                new QueryParameter(@"page", page));
11✔
83
        }
11✔
84

85
        /// <summary>
86
        /// The reactions to a comment
87
        /// </summary>
88
        /// <param name="commentActionId">Id of the Comment (ActionId)</param>
89
        /// <param name="cancellationToken">CancellationToken</param>
90
        /// <returns>The Reactions</returns>
91
        public async Task<List<CommentReaction>> GetCommentReactions(string commentActionId, CancellationToken cancellationToken = default)
92
        {
93
            return await _apiRequestController.Get<List<CommentReaction>>($"{UrlPaths.Actions}/{commentActionId}/reactions", cancellationToken);
×
94
        }
×
95
    }
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc