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

rwjdk / TrelloDotNet / 7308990850

23 Dec 2023 03:12PM UTC coverage: 63.815% (-2.5%) from 66.31%
7308990850

push

github

rwjdk
v1.9.7

890 of 1733 branches covered (0.0%)

Branch coverage included in aggregate %.

5 of 128 new or added lines in 7 files covered. (3.91%)

2 existing lines in 2 files now uncovered.

2332 of 3316 relevant lines covered (70.33%)

54.13 hits per line

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

76.81
/TrelloDotNet/TrelloDotNet/TrelloClient.Members.cs
1
using System.Collections.Generic;
2
using System.Linq;
3
using System.Threading;
4
using System.Threading.Tasks;
5
using TrelloDotNet.Control;
6
using TrelloDotNet.Model;
7
using TrelloDotNet.Model.Options;
8
using TrelloDotNet.Model.Options.GetMemberOptions;
9

10
namespace TrelloDotNet
11
{
12
    public partial class TrelloClient
13
    {
14
        /// <summary>
15
        /// Get the Members (users) of a board
16
        /// </summary>
17
        /// <param name="boardId">Id of the Board (in its long or short version)</param>
18
        /// <param name="cancellationToken">Cancellation Token</param>
19
        /// <returns>List of Members</returns>
20
        public async Task<List<Member>> GetMembersOfBoardAsync(string boardId, CancellationToken cancellationToken = default)
21
        {
22
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfBoard(boardId), cancellationToken);
15✔
23
        }
15✔
24

25
        /// <summary>
26
        /// Get the Members (users) of a board
27
        /// </summary>
28
        /// <param name="boardId">Id of the Board (in its long or short version)</param>
29
        /// <param name="options">Option for what data to include on the Member</param>
30
        /// <param name="cancellationToken">Cancellation Token</param>
31
        /// <returns>List of Members</returns>
32
        public async Task<List<Member>> GetMembersOfBoardAsync(string boardId, GetMemberOptions options, CancellationToken cancellationToken = default)
33
        {
NEW
34
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfBoard(boardId), cancellationToken, options.GetParameters());
×
NEW
35
        }
×
36

37
        /// <summary>
38
        /// Get the Members (users) who voted on a Card
39
        /// </summary>
40
        /// <param name="cardId">Id of the Card</param>
41
        /// <param name="cancellationToken">Cancellation Token</param>
42
        /// <returns>List of Members who voted</returns>
43
        public async Task<List<Member>> GetMembersWhoVotedOnCardAsync(string cardId, CancellationToken cancellationToken = default)
44
        {
45
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersWhoVotedOnOfCard(cardId), cancellationToken);
×
46
        }
×
47

48
        /// <summary>
49
        /// Get the Members (users) who voted on a Card
50
        /// </summary>
51
        /// <param name="cardId">Id of the Card</param>
52
        /// <param name="options">Option for what data to include on the Member</param>
53
        /// <param name="cancellationToken">Cancellation Token</param>
54
        /// <returns>List of Members who voted</returns>
55
        public async Task<List<Member>> GetMembersWhoVotedOnCardAsync(string cardId, GetMemberOptions options, CancellationToken cancellationToken = default)
56
        {
NEW
57
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersWhoVotedOnOfCard(cardId), cancellationToken, options.GetParameters());
×
NEW
58
        }
×
59

60
        /// <summary>
61
        /// Get the Members (users) of a Card
62
        /// </summary>
63
        /// <param name="cardId">Id of the Card</param>
64
        /// <param name="cancellationToken">Cancellation Token</param>
65
        /// <returns>List of Members</returns>
66
        public async Task<List<Member>> GetMembersOfCardAsync(string cardId, CancellationToken cancellationToken = default)
67
        {
68
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfCard(cardId), cancellationToken);
1✔
69
        }
1✔
70

71
        /// <summary>
72
        /// Get the Members (users) of a Card
73
        /// </summary>
74
        /// <param name="cardId">Id of the Card</param>
75
        /// <param name="options">Option for what data to include on the Member</param>
76
        /// <param name="cancellationToken">Cancellation Token</param>
77
        /// <returns>List of Members</returns>
78
        public async Task<List<Member>> GetMembersOfCardAsync(string cardId, GetMemberOptions options, CancellationToken cancellationToken = default)
79
        {
NEW
80
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfCard(cardId), cancellationToken, options.GetParameters());
×
NEW
81
        }
×
82

83
        /// <summary>
84
        /// Get a Member with a specific Id
85
        /// </summary>
86
        /// <param name="memberId">Id of the Member</param>
87
        /// <param name="cancellationToken">Cancellation Token</param>
88
        /// <returns>The Member</returns>
89
        public async Task<Member> GetMemberAsync(string memberId, CancellationToken cancellationToken = default)
90
        {
91
            return await _apiRequestController.Get<Member>(GetUrlBuilder.GetMember(memberId), cancellationToken);
1✔
92
        }
1✔
93

94
        /// <summary>
95
        /// Add one or more Members to a Card
96
        /// </summary>
97
        /// <param name="cardId">Id of the Card</param>
98
        /// <param name="memberIdsToAdd">One or more Ids of Members to add</param>
99
        public async Task<Card> AddMembersToCardAsync(string cardId, params string[] memberIdsToAdd)
100
        {
101
            return await AddMembersToCardAsync(cardId, CancellationToken.None, memberIdsToAdd);
5✔
102
        }
5✔
103

104
        /// <summary>
105
        /// Add one or more Members to a Card
106
        /// </summary>
107
        /// <param name="cardId">Id of the Card</param>
108
        /// <param name="cancellationToken">Cancellation Token</param>
109
        /// <param name="memberIdsToAdd">One or more Ids of Members to add</param>
110
        public async Task<Card> AddMembersToCardAsync(string cardId, CancellationToken cancellationToken = default, params string[] memberIdsToAdd)
111
        {
112
            var card = await GetCardAsync(cardId, cancellationToken);
5✔
113
            var missing = memberIdsToAdd.Where(x => !card.MemberIds.Contains(x)).ToList();
10✔
114

115
            if (missing.Count == 0)
5✔
116
            {
117
                return card; //Everyone already There
1✔
118
            }
119

120
            //Need update
121
            card.MemberIds.AddRange(missing);
4✔
122
            return await UpdateCardAsync(cardId, new List<QueryParameter>
4✔
123
            {
4✔
124
                new QueryParameter(CardFieldsType.MemberIds.GetJsonPropertyName(), card.MemberIds)
4✔
125
            }, cancellationToken);
4✔
126
        }
5✔
127

128
        /// <summary>
129
        /// Remove a Member of a Card
130
        /// </summary>
131
        /// <param name="cardId">Id of the Card</param>
132
        /// <param name="memberIdsToRemove">One or more Ids of Members to remove</param>
133
        public async Task<Card> RemoveMembersFromCardAsync(string cardId, params string[] memberIdsToRemove)
134
        {
135
            return await RemoveMembersFromCardAsync(cardId, CancellationToken.None, memberIdsToRemove);
3✔
136
        }
3✔
137

138
        /// <summary>
139
        /// Remove one or more Members from a Card
140
        /// </summary>
141
        /// <param name="cardId">Id of the Card</param>
142
        /// <param name="cancellationToken">Cancellation Token</param>
143
        /// <param name="memberIdsToRemove">One or more Ids of Members to remove</param>
144
        public async Task<Card> RemoveMembersFromCardAsync(string cardId, CancellationToken cancellationToken = default, params string[] memberIdsToRemove)
145
        {
146
            var card = await GetCardAsync(cardId, cancellationToken);
3✔
147
            var toRemove = memberIdsToRemove.Where(x => card.MemberIds.Contains(x)).ToList();
6✔
148
            if (toRemove.Count == 0)
3✔
149
            {
150
                return card; //Everyone not there
1✔
151
            }
152

153
            //Need update
154
            card.MemberIds = card.MemberIds.Except(toRemove).ToList();
2✔
155
            return await UpdateCardAsync(cardId, new List<QueryParameter>
2✔
156
            {
2✔
157
                new QueryParameter(CardFieldsType.MemberIds.GetJsonPropertyName(), card.MemberIds)
2✔
158
            }, cancellationToken);
2✔
159
        }
3✔
160

161
        /// <summary>
162
        /// Remove all Members from a Card
163
        /// </summary>
164
        /// <param name="cardId">Id of the Card</param>
165
        /// <param name="cancellationToken">Cancellation Token</param>
166
        public async Task<Card> RemoveAllMembersFromCardAsync(string cardId, CancellationToken cancellationToken = default)
167
        {
168
            return await UpdateCardAsync(cardId, new List<QueryParameter>
2✔
169
            {
2✔
170
                new QueryParameter(CardFieldsType.MemberIds.GetJsonPropertyName(), new List<string>())
2✔
171
            }, cancellationToken);
2✔
172
        }
2✔
173

174
        /// <summary>
175
        /// Add a Member to a board (aka give them access)
176
        /// </summary>
177
        /// <param name="boardId">Id of the Board to give access to</param>
178
        /// <param name="memberId">Id of the Member that need access</param>
179
        /// <param name="membershipType">What type of access the member should be given</param>
180
        /// <param name="allowBillableGuest">Optional param that allows organization admins to add multi-board guests onto a board.</param>
181
        /// <param name="cancellationToken">Cancellation Token</param>
182
        public async Task AddMemberToBoardAsync(string boardId, string memberId, MembershipType membershipType, bool allowBillableGuest = false, CancellationToken cancellationToken = default)
183
        {
184
            await _apiRequestController.Put($"{UrlPaths.Boards}/{boardId}/{UrlPaths.Members}/{memberId}", cancellationToken, 0,
1✔
185
                new QueryParameter("type", membershipType.GetJsonPropertyName()),
1✔
186
                new QueryParameter("allowBillableGuest", allowBillableGuest));
1✔
187
        }
1✔
188

189
        /// <summary>
190
        /// Invite a Member to a board via email (aka give them access)
191
        /// </summary>
192
        /// <param name="boardId">Id of the Board to give access to</param>
193
        /// <param name="email">Email to invite</param>
194
        /// <param name="membershipType">What type of access the member should be given</param>
195
        /// <param name="cancellationToken">Cancellation Token</param>
196
        public async Task InviteMemberToBoardViaEmailAsync(string boardId, string email, MembershipType membershipType, CancellationToken cancellationToken = default)
197
        {
198
            await _apiRequestController.Put($"{UrlPaths.Boards}/{boardId}/{UrlPaths.Members}", cancellationToken, 0,
1✔
199
                new QueryParameter("type", membershipType.GetJsonPropertyName()),
1✔
200
                new QueryParameter("email", email));
1✔
201
        }
1✔
202

203
        /// <summary>
204
        /// Remove a Member from a board (aka revoke access)
205
        /// </summary>
206
        /// <param name="boardId">Id of the Board the member should be removed from</param>
207
        /// <param name="memberId">Id of the Member that should be removed</param>
208
        /// <param name="cancellationToken">Cancellation Token</param>
209
        public async Task RemoveMemberFromBoardAsync(string boardId, string memberId, CancellationToken cancellationToken = default)
210
        {
211
            await _apiRequestController.Delete($"{UrlPaths.Boards}/{boardId}/{UrlPaths.Members}/{memberId}", cancellationToken, 0);
1✔
212
        }
1✔
213

214
        /// <summary>
215
        /// Get information about the Member that owns the token used by this TrelloClient
216
        /// </summary>
217
        /// <returns>The Member</returns>
218
        public async Task<Member> GetTokenMemberAsync(CancellationToken cancellationToken = default)
219
        {
220
            return await _apiRequestController.Get<Member>(GetUrlBuilder.GetTokenMember(_apiRequestController.Token), cancellationToken);
11✔
221
        }
11✔
222

223
        /// <summary>
224
        /// Get information about the Member that owns the token used by this TrelloClient
225
        /// <param name="options">Option for what data to include on the Member</param>
226
        /// <param name="cancellationToken">Cancellation Token</param>
227
        /// </summary>
228
        /// <returns>The Member</returns>
229
        public async Task<Member> GetTokenMemberAsync(GetMemberOptions options, CancellationToken cancellationToken = default)
230
        {
NEW
231
            return await _apiRequestController.Get<Member>(GetUrlBuilder.GetTokenMember(_apiRequestController.Token), cancellationToken, options.GetParameters());
×
NEW
232
        }
×
233

234
        /// <summary>
235
        /// Get the Members (users) of an Organization (aka Workspace)
236
        /// </summary>
237
        /// <param name="organizationId">Id of the Organization</param>
238
        /// <param name="cancellationToken">Cancellation Token</param>
239
        /// <returns>List of Members</returns>
240
        public async Task<List<Member>> GetMembersOfOrganizationAsync(string organizationId, CancellationToken cancellationToken = default)
241
        {
242
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfOrganization(organizationId), cancellationToken);
1✔
243
        }
1✔
244

245
        /// <summary>
246
        /// Get the Members (users) of an Organization (aka Workspace)
247
        /// </summary>
248
        /// <param name="organizationId">Id of the Organization</param>
249
        /// <param name="options">Option for what data to include on the Member</param>
250
        /// <param name="cancellationToken">Cancellation Token</param>
251
        /// <returns>List of Members</returns>
252
        public async Task<List<Member>> GetMembersOfOrganizationAsync(string organizationId, GetMemberOptions options, CancellationToken cancellationToken = default)
253
        {
NEW
254
            return await _apiRequestController.Get<List<Member>>(GetUrlBuilder.GetMembersOfOrganization(organizationId), cancellationToken, options.GetParameters());
×
NEW
255
        }
×
256

257
        /// <summary>
258
        /// Add a member vote to a card
259
        /// </summary>
260
        /// <param name="cardId">The cardId to add the vote to</param>
261
        /// <param name="memberId">The id of the member that cast the vote</param>
262
        /// <param name="cancellationToken">Cancellation Token</param>
263
        public async Task AddVoteToCardAsync(string cardId, string memberId, CancellationToken cancellationToken = default)
264
        {
265
            await _apiRequestController.Post($"{UrlPaths.Cards}/{cardId}/membersVoted", cancellationToken, 0, new QueryParameter("value", memberId));
×
266
        }
×
267

268
        /// <summary>
269
        /// Remove a member vote from a card
270
        /// </summary>
271
        /// <param name="cardId">The cardId to add the vote to</param>
272
        /// <param name="memberId">The id of the member that cast the vote</param>
273
        /// <param name="cancellationToken">Cancellation Token</param>
274
        public async Task RemoveVoteFromCardAsync(string cardId, string memberId, CancellationToken cancellationToken = default)
275
        {
276
            await _apiRequestController.Delete($"{UrlPaths.Cards}/{cardId}/membersVoted/{memberId}", cancellationToken, 0);
×
277
        }
×
278
    }
279
}
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