Skip to content

Commit 1c48379

Browse files
committed
Some commentary improvements and attachment id is public
1 parent c75ce71 commit 1c48379

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

WebUntisAPI.Client/Models/Messages/Attachment.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ namespace WebUntisAPI.Client.Models.Messages
2020
public struct Attachment
2121
{
2222
/// <summary>
23-
/// The file name of the attachment
23+
/// The attachment id
2424
/// </summary>
25-
[JsonProperty("name")]
26-
public string Name { get; set; }
25+
[JsonProperty("id")]
26+
public string Id { get; set; }
2727

2828
/// <summary>
29-
/// The attachment id
29+
/// The file name of the attachment
3030
/// </summary>
31-
[JsonProperty("id")]
32-
internal readonly string _id;
31+
[JsonProperty("name")]
32+
public string Name { get; set; }
3333

3434
/// <summary>
3535
/// Get the content of the attachment as stream with a progress report
@@ -44,7 +44,7 @@ public struct Attachment
4444
/// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
4545
public async Task<Stream> DownloadContentAsStreamAsync(WebUntisClient client, TimeSpan timeout, IProgress<double> progress = null, CancellationToken ct = default)
4646
{
47-
string storageResponseString = await client.MakeAPIGetRequestAsync($"/WebUntis/api/rest/view/v1/messages/{_id}/attachmentstorageurl", ct);
47+
string storageResponseString = await client.MakeAPIGetRequestAsync($"/WebUntis/api/rest/view/v1/messages/{Id}/attachmentstorageurl", ct);
4848

4949
JObject data = JObject.Parse(storageResponseString);
5050
JArray headerArray = data.Value<JArray>("additionalHeaders");
@@ -85,7 +85,7 @@ public async Task<Stream> DownloadContentAsStreamAsync(WebUntisClient client, Ti
8585

8686
content.Write(buffer, 0, bytesRead);
8787
totalRecievedBytes += bytesRead;
88-
progress.Report((double)totalRecievedBytes / totalBytes * 100d);
88+
progress?.Report((double)totalRecievedBytes / totalBytes * 100d);
8989
}
9090
}
9191

WebUntisAPI.Client/Models/Messages/MessagePermissions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ public class MessagePermissions
3838
public bool ShowSentTab { get; set; }
3939

4040
/// <summary>
41-
/// Can you forbid replies
41+
/// Can you forbid replies of a message
4242
/// </summary>
4343
[JsonProperty("canForbidReplies")]
4444
public bool CanForbidReplies { get; set; }
4545

4646
/// <summary>
47-
/// The maximum size of a file you could attach in bytes
47+
/// The maximum size of a file you could attach to a message in bytes
4848
/// </summary>
4949
[JsonProperty("maxFileSize")]
5050
public long MaxFileSize { get; set; }
5151

5252
/// <summary>
53-
/// The maximum count of files you could attach
53+
/// The maximum count of files you could attach to one message
5454
/// </summary>
5555
[JsonProperty("maxFileCount")]
5656
public int MaxFileCount { get; set; }

WebUntisAPI.Client/Models/Timegrid.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace WebUntisAPI.Client.Models
1010
/// <summary>
1111
/// A timegrid for a school
1212
/// </summary>
13-
[DebuggerDisplay("Days = {SchoolDays}")]
13+
[DebuggerDisplay("Days = {SchoolDays, nq}")]
1414
[JsonConverter(typeof(TimegridJsonConverter))]
15-
public class Timegrid : IEnumerable<(Day, SchoolHour[])>
15+
public class Timegrid : IEnumerable<KeyValuePair<Day, SchoolHour[]>>
1616
{
1717
/// <summary>
1818
/// All the school days with their school hours
@@ -26,7 +26,7 @@ public class Timegrid : IEnumerable<(Day, SchoolHour[])>
2626

2727
#region IEnumerable<SchoolHour[]>
2828
/// <inheritdoc/>
29-
public IEnumerator<(Day, SchoolHour[])> GetEnumerator() => SchoolDays.Keys.Zip(SchoolDays.Values, (day, schoolHours) => (day, schoolHours)).GetEnumerator();
29+
public IEnumerator<KeyValuePair<Day, SchoolHour[]>> GetEnumerator() => SchoolDays.GetEnumerator();
3030

3131
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
3232
#endregion

WebUntisAPI.Client/WebUntisClient.Messages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public async Task<DraftPreview> UpdateDraftAsync(Draft draft, Tuple<string, Stre
575575
writer.WritePropertyName("attachmentIdsToDelete");
576576
writer.WriteStartArray();
577577
foreach (Attachment attachment in attachmentToDelete ?? new Attachment[0])
578-
writer.WriteValue(attachment._id);
578+
writer.WriteValue(attachment.Id);
579579
writer.WriteEndArray();
580580

581581
writer.WritePropertyName("forbidReply");

0 commit comments

Comments
 (0)