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

rwjdk / TrelloDotNet / 9191886850

22 May 2024 01:06PM UTC coverage: 61.525% (-0.7%) from 62.198%
9191886850

push

github

rwjdk
Version 1.10.2

890 of 1809 branches covered (49.2%)

Branch coverage included in aggregate %.

0 of 32 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

2329 of 3423 relevant lines covered (68.04%)

51.73 hits per line

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

89.06
/TrelloDotNet/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
namespace TrelloDotNet.Model
9
{
10
    /// <summary>
11
    /// Represent a Trello Card
12
    /// </summary>
13
    [DebuggerDisplay("{Name} (Id: {Id})")]
14
    public class Card
15
    {
16
        /// <summary>
17
        /// Id of the card (Long unique variant)
18
        /// </summary>
19
        [JsonPropertyName("id")]
20
        [JsonInclude]
21
        public string Id { get; private set; }
525✔
22

23
        /// <summary>
24
        /// Id of the card in short form (only unique to the specific board)
25
        /// </summary>
26
        [JsonPropertyName("idShort")]
27
        [JsonInclude]
28
        public int IdShort { get; private set; }
191✔
29

30
        /// <summary>
31
        /// Id of the board the card is on
32
        /// </summary>
33
        /// <remarks>
34
        /// If you move board make sure ListId, MemberIds and LabelsId are valid for the new board
35
        /// </remarks>
36
        [JsonPropertyName("idBoard")]
37
        [QueryParameter]
38
        public string BoardId { get; set; }
258✔
39

40
        /// <summary>
41
        /// Name of the card
42
        /// </summary>
43
        [JsonPropertyName("name")]
44
        [QueryParameter]
45
        public string Name { get; set; }
365✔
46

47
        /// <summary>
48
        /// Description of the card
49
        /// </summary>
50
        [JsonPropertyName("desc")]
51
        [QueryParameter]
52
        public string Description { get; set; }
365✔
53

54
        /// <summary>
55
        /// If the card is Archived (closed)
56
        /// </summary>
57
        [JsonPropertyName("closed")]
58
        [QueryParameter]
59
        public bool Closed { get; set; }
262✔
60

61
        /// <summary>
62
        /// The position of the card in the current list
63
        /// </summary>
64
        [JsonPropertyName("pos")]
65
        [QueryParameter]
66
        public decimal Position { get; set; }
287✔
67

68
        /// <summary>
69
        /// If the card is Watched (subscribed) by the owner of the Token used against the API
70
        /// </summary>
71
        [JsonPropertyName("subscribed")]
72
        [QueryParameter]
73
        public bool Subscribed { get; set; }
258✔
74

75
        /// <summary>
76
        /// Id of the List the Card belong to
77
        /// </summary>
78
        /// <remarks>
79
        /// NB: If you move the card to another board set this to null (aka first column of new board) or a valid listId on the new board
80
        /// </remarks>
81
        [JsonPropertyName("idList")]
82
        [QueryParameter(false)]
83
        public string ListId { get; set; }
326✔
84

85
        /// <summary>
86
        /// When the Card was created [stored in UTC]
87
        /// </summary>
88
        [JsonIgnore]
89
        public DateTimeOffset? Created => IdToCreatedHelper.GetCreatedFromId(Id);
1✔
90

91
        /// <summary>
92
        /// When there was last activity on the card (aka update date) [stored UTC]
93
        /// </summary>
94
        [JsonPropertyName("dateLastActivity")]
95
        [JsonInclude]
96
        public DateTimeOffset LastActivity { get; private set; }
191✔
97

98
        /// <summary>
99
        /// The Start-date of the work on the card (not to be confused with Created property as this can be null) [stored in UTC]
100
        /// </summary>
101
        [JsonPropertyName("start")]
102
        [QueryParameter]
103
        public DateTimeOffset? Start { get; set; }
282✔
104

105
        /// <summary>
106
        /// The Due-date of the work on the card should be finished [stored in UTC]
107
        /// </summary>
108
        [JsonPropertyName("due")]
109
        [QueryParameter]
110
        public DateTimeOffset? Due { get; set; }
294✔
111

112
        /// <summary>
113
        /// If the due work is completed
114
        /// </summary>
115
        [JsonPropertyName("dueComplete")]
116
        [QueryParameter]
117
        public bool DueComplete { get; set; }
306✔
118

119
        /// <summary>
120
        /// The labels (in details) that are on the card
121
        /// </summary>
122
        /// <remarks>
123
        /// NB: This is not updateable. Instead update what labels should be included via the 'LabelIds' property in update scenarios
124
        /// </remarks>
125
        [JsonPropertyName("labels")]
126
        [JsonInclude]
127
        public List<Label> Labels { get; private set; }
207✔
128

129
        /// <summary>
130
        /// Ids of the Labels that are on the Card
131
        /// </summary>
132
        [JsonPropertyName("idLabels")]
133
        [QueryParameter]
134
        public List<string> LabelIds { get; set; }
412✔
135

136
        /// <summary>
137
        /// Ids of the Checklists on the card
138
        /// </summary>
139
        /// <remarks>
140
        /// NB: This is not Updateable here. Instead use the dedicated methods for the action
141
        /// </remarks>
142
        [JsonPropertyName("idChecklists")]
143
        [JsonInclude]
144
        public List<string> ChecklistIds { get; private set; }
192✔
145

146
        /// <summary>
147
        /// Ids of members that should be assigned to the card
148
        /// </summary>
149
        [JsonPropertyName("idMembers")]
150
        [QueryParameter]
151
        public List<string> MemberIds { get; set; }
378✔
152

153
        /// <summary>
154
        /// Ids of members that voted on this card
155
        /// </summary>
156
        [JsonPropertyName("idMembersVoted")]
157
        [JsonInclude]
158
        public List<string> MembersVotedIds { get; private set; }
190✔
159

160
        /// <summary>
161
        /// Id of the image attachment of this card to use as its cover
162
        /// </summary>
163
        [JsonPropertyName("idAttachmentCover")]
164
        [QueryParameter]
165
        [JsonInclude]
166
        public string AttachmentCover { get; set; }
259✔
167

168
        /// <summary>
169
        /// Url you can use to get to the card
170
        /// </summary>
171
        [JsonPropertyName("url")]
172
        [JsonInclude]
173
        public string Url { get; private set; }
192✔
174

175
        /// <summary>
176
        /// Short Url you can use to get to the card
177
        /// </summary>
178
        [JsonPropertyName("shortUrl")]
179
        [JsonInclude]
180
        public string ShortUrl { get; private set; }
192✔
181

182
        /// <summary>
183
        /// Cover of the Card (set to null in update scenario if you wish to remove it)
184
        /// </summary>
185
        [JsonPropertyName("cover")]
186
        public CardCover Cover { get; set; }
324✔
187

188
        /// <summary>
189
        /// Custom Fields of the Card (Only populated in Get Methods and if enabled in TrelloClientOptions)
190
        /// </summary>
191
        /// <remarks>Tip: Use Extension methods GetCustomFieldValueAsXYZ on the list for a handy way to get values</remarks>
192
        [JsonPropertyName("customFieldItems")]
193
        [JsonInclude]
194
        public List<CustomFieldItem> CustomFieldItems { get; private set; }
74✔
195

196
        /// <summary>
197
        /// Attachments of the Card (Only populated in Get Methods and if enabled in TrelloClientOptions or if GetCardOptions.IncludeAttachments is used)
198
        /// </summary>
199
        [JsonPropertyName("attachments")]
200
        [JsonInclude]
201
        public List<Attachment> Attachments { get; private set; }
64✔
202

203
        /// <summary>
204
        /// Members of the Card (Only populated if GetCardOptions.IncludeMembers is used)
205
        /// </summary>
206
        [JsonPropertyName("members")]
207
        [JsonInclude]
208
        public List<Member> Members { get; private set; }
×
209

210
        /// <summary>
211
        /// Members that voted for the Card (Only populated if GetCardOptions.IncludeMemberVotes is used)
212
        /// </summary>
213
        [JsonPropertyName("membersVoted")]
214
        [JsonInclude]
215
        public List<Member> MembersVoted { get; private set; }
×
216

217
        /// <summary>
218
        /// Board the Card is on (Only populated if GetCardOptions.IncludeBoard is used)
219
        /// </summary>
220
        [JsonPropertyName("board")]
221
        [JsonInclude]
NEW
222
        public Board Board { get; internal set; }
×
223

224
        /// <summary>
225
        /// List of the Card (Only populated if GetCardOptions.IncludeList is used)
226
        /// </summary>
227
        [JsonPropertyName("list")]
228
        [JsonInclude]
229
        public List List { get; internal set; }
×
230

231
        /// <summary>
232
        /// Actions of the Card (Only populated if 'ActionTypes' in GetCardOptions is included)
233
        /// </summary>
234
        [JsonPropertyName("actions")]
235
        [JsonInclude]
236
        public List<TrelloAction> Actions { get; private set; }
×
237

238
        /// <summary>
239
        /// Checklists of the Card (Only populated if GetCardOptions.IncludeChecklist is used)
240
        /// </summary>
241
        [JsonPropertyName("checklists")]
242
        [JsonInclude]
243
        public List<Checklist> Checklists { get; private set; }
×
244

245
        /// <summary>
246
        /// Plugin data of the Card (Only populated if GetCardOptions.IncludePluginData is used)
247
        /// </summary>
248
        [JsonPropertyName("pluginData")]
249
        [JsonInclude]
250
        public List<PluginData> PluginData { get; private set; }
×
251

252
        /// <summary>
253
        /// Stickers of the Card (Only populated if GetCardOptions.IncludeStickers is used)
254
        /// </summary>
255
        [JsonPropertyName("stickers")]
256
        [JsonInclude]
257
        public List<Sticker> Stickers { get; private set; }
60✔
258

259

260
        /// <summary>
261
        /// The named position of the Card in the list: Top or Bottom
262
        /// </summary>
263
        [JsonIgnore]
264
        public NamedPosition? NamedPosition { internal get; set; }
68✔
265

266
        /// <summary>
267
        /// Constructor (Common Card fields)
268
        /// </summary>
269
        /// <param name="listId">Id of list to add the card to</param>
270
        /// <param name="name">Name/Title of the card</param>
271
        /// <param name="description">Description on the card</param>
272
        public Card(string listId, string name, string description = null)
58✔
273
        {
274
            Name = name;
58✔
275
            Description = description;
58✔
276
            ListId = listId;
58✔
277
            InitializeLists();
58✔
278
        }
58✔
279

280
        /// <summary>
281
        /// Constructor (All supported fields for add/update)
282
        /// </summary>
283
        /// <param name="listId">Id of list to add the card to</param>
284
        /// <param name="name">Name/Title of the card</param>
285
        /// <param name="description">Description on the card</param>
286
        /// <param name="start">Start-date (should be given in UTC)</param>
287
        /// <param name="due">Due-date (should be given in UTC)</param>
288
        /// <param name="dueComplete">If due-date is complete (normally false when you create a card)</param>
289
        /// <param name="labelIds">Labels set on the card</param>
290
        /// <param name="memberIds">Members (user) assigned to the card</param>
291
        public Card(string listId, string name, string description, DateTimeOffset? start, DateTimeOffset? due, bool dueComplete = false, List<string> labelIds = null, List<string> memberIds = null)
1✔
292
        {
293
            Name = name;
1✔
294
            Description = description;
1✔
295
            ListId = listId;
1✔
296
            Start = start;
1✔
297
            Due = due;
1✔
298
            DueComplete = dueComplete;
1✔
299
            LabelIds = labelIds;
1✔
300
            MemberIds = memberIds;
1✔
301
            InitializeLists();
1✔
302
            if (memberIds != null)
1✔
303
            {
304
                MemberIds = memberIds;
1✔
305
            }
306

307
            if (labelIds != null)
1✔
308
            {
309
                LabelIds = labelIds;
1✔
310
            }
311
        }
1✔
312

313
        /// <summary>
314
        /// Constructor
315
        /// </summary>
316
        public Card()
249✔
317
        {
318
            //Serialization
319
        }
249✔
320

321
        private void InitializeLists()
322
        {
323
            LabelIds = new List<string>();
59✔
324
            MemberIds = new List<string>();
59✔
325
        }
59✔
326
    }
327
}
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