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

rwjdk / TrelloDotNet / 15361499730

31 May 2025 07:28AM UTC coverage: 80.301% (-0.1%) from 80.419%
15361499730

push

github

rwjdk
AI Review of ReadMe

2535 of 3449 branches covered (73.5%)

Branch coverage included in aggregate %.

4460 of 5262 relevant lines covered (84.76%)

102.52 hits per line

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

57.35
/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
using TrelloDotNet.Model.Options.AddCardOptions;
8

9
// ReSharper disable UnusedMember.Global
10

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

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

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

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

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

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

64
        /// <summary>
65
        /// The position of the card within its current list, used for ordering cards (the lower the number the higher up it is on the list).
66
        /// </summary>
67
        [JsonPropertyName("pos")]
68
        [QueryParameter]
69
        public decimal Position { get; set; }
653✔
70

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

78
        /// <summary>
79
        /// The ID of the list this card currently belongs to.
80
        /// </summary>
81
        /// <remarks>
82
        /// 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.
83
        /// </remarks>
84
        [JsonPropertyName("idList")]
85
        [QueryParameter(false)]
86
        public string ListId { get; set; }
1,590✔
87

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

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

104
        /// <summary>
105
        /// The start date for work on the card. This is not the same as the Created property and can be null. Stored in UTC.
106
        /// </summary>
107
        [JsonPropertyName("start")]
108
        [QueryParameter]
109
        public DateTimeOffset? Start { get; set; }
842✔
110

111
        /// <summary>
112
        /// The due date of the card (aka when it should be completed). Stored in UTC.
113
        /// </summary>
114
        [JsonPropertyName("due")]
115
        [QueryParameter]
116
        public DateTimeOffset? Due { get; set; }
1,046✔
117

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

340
            if (labelIds != null)
×
341
            {
342
                LabelIds = labelIds;
×
343
            }
344
        }
×
345

346
        /// <summary>
347
        /// Initializes a new instance of the Card class for serialization purposes.
348
        /// </summary>
349
        public Card()
1,464✔
350
        {
351
            //Serialization
352
        }
1,464✔
353

354
        private void InitializeLists()
355
        {
356
            LabelIds = new List<string>();
×
357
            MemberIds = new List<string>();
×
358
        }
×
359
    }
360
}
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