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

rwjdk / TrelloDotNet / 16099027285

06 Jul 2025 12:29PM UTC coverage: 79.551% (-0.4%) from 79.911%
16099027285

push

github

rwjdk
Version 2.1.0

2539 of 3464 branches covered (73.3%)

Branch coverage included in aggregate %.

0 of 22 new or added lines in 3 files covered. (0.0%)

11 existing lines in 3 files now uncovered.

4479 of 5358 relevant lines covered (83.59%)

113.35 hits per line

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

56.52
/src/TrelloDotNet/Model/Card.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics;
4
using System.Text.Json.Serialization;
5
using TrelloDotNet.Control;
6
using TrelloDotNet.Model.Actions;
7

8
// ReSharper disable UnusedMember.Global
9

10
namespace TrelloDotNet.Model
11
{
12
    /// <summary>
13
    /// Represents a Card.
14
    /// </summary>
15
    [DebuggerDisplay("{Name} (Id: {Id})")]
16
    public class Card
17
    {
18
        /// <summary>
19
        /// The ID of the card (globally unique across all boards).
20
        /// </summary>
21
        [JsonPropertyName("id")]
22
        [JsonInclude]
23
        public string Id { get; private set; }
2,103✔
24

25
        /// <summary>
26
        /// The short ID of the card (unique within its board).
27
        /// </summary>
28
        [JsonPropertyName("idShort")]
29
        [JsonInclude]
30
        public int IdShort { get; private set; }
490✔
31

32
        /// <summary>
33
        /// The ID of the board this card belongs to.
34
        /// </summary>
35
        /// <remarks>
36
        /// If you move the card to another board, ensure ListId, MemberIds, and LabelIds are valid for the new board.
37
        /// </remarks>
38
        [JsonPropertyName("idBoard")]
39
        [QueryParameter]
40
        public string BoardId { get; set; }
825✔
41

42
        /// <summary>
43
        /// The name (title) of the card.
44
        /// </summary>
45
        [JsonPropertyName("name")]
46
        [QueryParameter]
47
        public string Name { get; set; }
1,976✔
48

49
        /// <summary>
50
        /// The description of the card.
51
        /// </summary>
52
        [JsonPropertyName("desc")]
53
        [QueryParameter]
54
        public string Description { get; set; }
969✔
55

56
        /// <summary>
57
        /// Indicates whether the card is archived (closed).
58
        /// </summary>
59
        [JsonPropertyName("closed")]
60
        [QueryParameter]
61
        public bool Closed { get; set; }
625✔
62

63
        /// <summary>
64
        /// The position of the card within its current list. Lower numbers are higher in the list.
65
        /// </summary>
66
        [JsonPropertyName("pos")]
67
        [QueryParameter]
68
        public decimal Position { get; set; }
662✔
69

70
        /// <summary>
71
        /// Indicates if the card is watched (subscribed) by the owner of the API token.
72
        /// </summary>
73
        [JsonPropertyName("subscribed")]
74
        [QueryParameter]
75
        public bool Subscribed { get; set; }
618✔
76

77
        /// <summary>
78
        /// The ID of the list this card currently belongs to.
79
        /// </summary>
80
        /// <remarks>
81
        /// If you move the card to another board, set this to null (to place in the first column of the new board) or to a valid list ID on the new board.
82
        /// </remarks>
83
        [JsonPropertyName("idList")]
84
        [QueryParameter(false)]
85
        public string ListId { get; set; }
2,149✔
86

87
        /// <summary>
88
        /// The date and time when the card was created, derived from the card's ID. Stored in UTC.
89
        /// </summary>
90
        [JsonIgnore]
91
        public DateTimeOffset? Created => IdToCreatedHelper.GetCreatedFromId(Id);
184✔
92

93
        /// <summary>
94
        /// The date and time of the last activity on the card (such as an update or comment). Stored in UTC.
95
        /// <remarks>
96
        /// This property is also affected by the Position property, so moving another card to the same list can affect this timestamp.
97
        /// </remarks>
98
        /// </summary>
99
        [JsonPropertyName("dateLastActivity")]
100
        [JsonInclude]
101
        public DateTimeOffset LastActivity { get; private set; }
490✔
102

103
        /// <summary>
104
        /// The start date for work on the card. Not the same as Created. Stored in UTC.
105
        /// </summary>
106
        [JsonPropertyName("start")]
107
        [QueryParameter]
108
        public DateTimeOffset? Start { get; set; }
850✔
109

110
        /// <summary>
111
        /// The due date of the card. Stored in UTC.
112
        /// </summary>
113
        [JsonPropertyName("due")]
114
        [QueryParameter]
115
        public DateTimeOffset? Due { get; set; }
1,054✔
116

117
        /// <summary>
118
        /// Indicates whether the card is marked as complete.
119
        /// </summary>
120
        [JsonPropertyName("dueComplete")]
121
        [QueryParameter]
122
        public bool DueComplete { get; set; }
950✔
123

124
        /// <summary>
125
        /// The detailed label objects currently assigned to the card. Read-only; to update labels, use the LabelIds property.
126
        /// </summary>
127
        /// <remarks>
128
        /// This property is not updateable. To change labels, update the LabelIds property instead.
129
        /// </remarks>
130
        [JsonPropertyName("labels")]
131
        [JsonInclude]
132
        public List<Label> Labels { get; private set; }
741✔
133

134
        /// <summary>
135
        /// The list of label IDs currently assigned to the card.
136
        /// </summary>
137
        [JsonPropertyName("idLabels")]
138
        [QueryParameter]
139
        public List<string> LabelIds { get; set; }
1,176✔
140

141
        /// <summary>
142
        /// The list of checklist IDs attached to the card. Read-only; use dedicated methods to modify checklists.
143
        /// </summary>
144
        /// <remarks>
145
        /// This property is not updateable here. Use dedicated methods to add or remove checklists.
146
        /// </remarks>
147
        [JsonPropertyName("idChecklists")]
148
        [JsonInclude]
149
        public List<string> ChecklistIds { get; private set; }
491✔
150

151
        /// <summary>
152
        /// The list of member IDs assigned to the card.
153
        /// </summary>
154
        [JsonPropertyName("idMembers")]
155
        [QueryParameter]
156
        public List<string> MemberIds { get; set; }
1,065✔
157

158
        /// <summary>
159
        /// The list of member IDs who have voted on this card.
160
        /// </summary>
161
        [JsonPropertyName("idMembersVoted")]
162
        [JsonInclude]
163
        public List<string> MembersVotedIds { get; private set; }
493✔
164

165
        /// <summary>
166
        /// The ID of the image attachment to use as the card's cover image.
167
        /// </summary>
168
        [JsonPropertyName("idAttachmentCover")]
169
        [QueryParameter]
170
        [JsonInclude]
171
        public string AttachmentCover { get; set; }
619✔
172

173
        /// <summary>
174
        /// The full URL to access this card directly in Trello.
175
        /// </summary>
176
        [JsonPropertyName("url")]
177
        [JsonInclude]
178
        public string Url { get; private set; }
491✔
179

180
        /// <summary>
181
        /// The short URL to access this card directly in Trello.
182
        /// </summary>
183
        [JsonPropertyName("shortUrl")]
184
        [JsonInclude]
185
        public string ShortUrl { get; private set; }
494✔
186

187
        /// <summary>
188
        /// The cover of the card, which can be a color or an image.
189
        /// </summary>
190
        [JsonPropertyName("cover")]
191
        public CardCover Cover { get; set; }
549✔
192

193
        /// <summary>
194
        /// The custom field items assigned to the card. Only populated if GetCardOptions.IncludeCustomFieldItems is used.
195
        /// </summary>
196
        /// <remarks>Use extension methods such as GetCustomFieldValueAsXYZ for convenient value retrieval.</remarks>
197
        [JsonPropertyName("customFieldItems")]
198
        [JsonInclude]
199
        public List<CustomFieldItem> CustomFieldItems { get; private set; }
213✔
200

201
        /// <summary>
202
        /// The list of attachments on the card. Only populated if GetCardOptions.IncludeAttachments is used.
203
        /// </summary>
204
        [JsonPropertyName("attachments")]
205
        [JsonInclude]
206
        public List<Attachment> Attachments { get; internal set; }
360✔
207

208
        /// <summary>
209
        /// The list of members assigned to the card. Only populated if GetCardOptions.IncludeMembers is used.
210
        /// </summary>
211
        [JsonPropertyName("members")]
212
        [JsonInclude]
213
        public List<Member> Members { get; private set; }
213✔
214

215
        /// <summary>
216
        /// The list of members who have voted for the card. Only populated if GetCardOptions.IncludeMemberVotes is used.
217
        /// </summary>
218
        [JsonPropertyName("membersVoted")]
219
        [JsonInclude]
220
        public List<Member> MembersVoted { get; private set; }
3✔
221

222
        /// <summary>
223
        /// The board this card is on. Only populated if GetCardOptions.IncludeBoard is used.
224
        /// </summary>
225
        [JsonPropertyName("board")]
226
        [JsonInclude]
227
        public Board Board { get; internal set; }
97✔
228

229
        /// <summary>
230
        /// The list this card is in. Only populated if GetCardOptions.IncludeList is used.
231
        /// </summary>
232
        [JsonPropertyName("list")]
233
        [JsonInclude]
234
        public List List { get; internal set; }
253✔
235

236
        /// <summary>
237
        /// The list of actions performed on this card. Only populated if 'ActionTypes' in GetCardOptions is included.
238
        /// </summary>
239
        [JsonPropertyName("actions")]
240
        [JsonInclude]
241
        public List<TrelloAction> Actions { get; private set; }
97✔
242

243
        /// <summary>
244
        /// The list of checklists attached to the card. Only populated if GetCardOptions.IncludeChecklist is used.
245
        /// </summary>
246
        [JsonPropertyName("checklists")]
247
        [JsonInclude]
248
        public List<Checklist> Checklists { get; internal set; }
223✔
249

250
        /// <summary>
251
        /// The plugin data associated with the card. Only populated if GetCardOptions.IncludePluginData is used.
252
        /// </summary>
253
        [JsonPropertyName("pluginData")]
254
        [JsonInclude]
255
        public List<PluginData> PluginData { get; private set; }
47✔
256

257
        /// <summary>
258
        /// The list of stickers attached to the card. Only populated if GetCardOptions.IncludeStickers is used.
259
        /// </summary>
260
        [JsonPropertyName("stickers")]
261
        [JsonInclude]
262
        public List<Sticker> Stickers { get; private set; }
227✔
263

264
        /// <summary>
265
        /// The role of the card, used to indicate if the card is a mirror, separator or other special function.
266
        /// </summary>
267
        [JsonPropertyName("cardRole")]
268
        [JsonInclude]
269
        public string CardRole { get; private set; }
488✔
270

271
        /// <summary>
272
        /// If the card is a mirror, this contains the ID of the original card being mirrored.
273
        /// </summary>
274
        [JsonPropertyName("mirrorSourceId")]
275
        [JsonInclude]
276
        public string MirrorSourceId { get; private set; }
488✔
277

278
        /// <summary>
279
        /// Indicates whether this card is a mirror of another card.
280
        /// </summary>
281
        public bool IsCardMirror => CardRole == "mirror";
×
282

283
        /// <summary>
284
        /// Indicates whether this card is a Separator
285
        /// </summary>
NEW
286
        public bool IsSeparator => CardRole == "separator";
×
287

288
        /// <summary>
289
        /// The named position of the card in the list, such as Top or Bottom. Used for positioning cards by name instead of numeric value.
290
        /// </summary>
291
        [JsonIgnore]
292
        public NamedPosition? NamedPosition { internal get; set; }
258✔
293

294
        /// <summary>
295
        /// Indicates whether this card is a template card, which can be used as a reusable pattern for new cards.
296
        /// </summary>
297
        [JsonPropertyName("isTemplate")]
298
        [QueryParameter]
299
        public bool IsTemplate { get; set; }
747✔
300

301
        /// <summary>
302
        /// Initializes a new instance of the Card class with the most common fields.
303
        /// </summary>
304
        /// <param name="listId">The ID of the list to add the card to.</param>
305
        /// <param name="name">The name or title of the card.</param>
306
        /// <param name="description">The description of the card (optional).</param>
307
        [Obsolete("Should not be used anymore. Instead use 'AddCardOptions' or Object initializer")]
308
        public Card(string listId, string name, string description = null)
×
309
        {
310
            Name = name;
×
311
            Description = description;
×
312
            ListId = listId;
×
313
            InitializeLists();
×
314
        }
×
315

316
        /// <summary>
317
        /// Initializes a new instance of the Card class with all supported fields for add or update operations.
318
        /// </summary>
319
        /// <param name="listId">The ID of the list to add the card to.</param>
320
        /// <param name="name">The name or title of the card.</param>
321
        /// <param name="description">The description of the card.</param>
322
        /// <param name="start">The start date for the card (should be in UTC).</param>
323
        /// <param name="due">The due date for the card (should be in UTC).</param>
324
        /// <param name="dueComplete">Indicates if the card is complete (usually false when creating a new card).</param>
325
        /// <param name="labelIds">The list of label IDs to assign to the card.</param>
326
        /// <param name="memberIds">The list of member IDs to assign to the card.</param>
327
        [Obsolete("Should not be used anymore. Instead use 'AddCardOptions' or Object initializer")]
328
        public Card(string listId, string name, string description, DateTimeOffset? start, DateTimeOffset? due, bool dueComplete = false, List<string> labelIds = null, List<string> memberIds = null)
×
329
        {
330
            Name = name;
×
331
            Description = description;
×
332
            ListId = listId;
×
333
            Start = start;
×
334
            Due = due;
×
335
            DueComplete = dueComplete;
×
336
            LabelIds = labelIds;
×
337
            MemberIds = memberIds;
×
338
            InitializeLists();
×
339
            if (memberIds != null)
×
340
            {
341
                MemberIds = memberIds;
×
342
            }
343

344
            if (labelIds != null)
×
345
            {
346
                LabelIds = labelIds;
×
347
            }
348
        }
×
349

350
        /// <summary>
351
        /// Initializes a new instance of the Card class for serialization purposes.
352
        /// </summary>
353
        public Card()
1,478✔
354
        {
355
            //Serialization
356
        }
1,478✔
357

358
        private void InitializeLists()
359
        {
360
            LabelIds = new List<string>();
×
361
            MemberIds = new List<string>();
×
362
        }
×
363
    }
364
}
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