about summary refs log tree commit diff
path: root/LibMatrix/Responses/UserProfileResponse.cs
blob: 30e4c32d9a474ea71b295f5d407259df0661c7f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Text.Json;
using System.Text.Json.Serialization;

namespace LibMatrix.Responses;

public class UserProfileResponse {
    [JsonPropertyName("avatar_url")]
    public string? AvatarUrl { get; set; }

    [JsonPropertyName("displayname")]
    public string? DisplayName { get; set; }

    // MSC 4133 - Extending User Profile API with Key:Value pairs
    [JsonExtensionData]
    public Dictionary<string, JsonElement>? CustomKeys { get; set; }

    public JsonElement? this[string key] {
        get => CustomKeys?[key];
        set {
            if (value is null)
                CustomKeys?.Remove(key);
            else
                (CustomKeys ??= [])[key] = value.Value;
        }
    }
}