summary refs log tree commit diff
path: root/extra/admin-api/Models/Spacebar.Models.Generic/Role.cs
blob: 6c49f85eed3d00f512684e86485705b64aba2d59 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Text.Json.Serialization;
using Spacebar.Models.Generic.Constants;

namespace Spacebar.Models.Generic;

public class Role {
    [JsonPropertyName("id"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
    public required long Id { get; set; }

    [JsonPropertyName("color"), Obsolete("See Colors instead")]
    public int Color { get; set; }

    [JsonPropertyName("colors")]
    public RoleColors Colors { get; set; }

    [JsonPropertyName("flags")]
    public int Flags { get; set; }

    [JsonPropertyName("guild_id"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
    public required long GuildId { get; set; }

    [JsonPropertyName("hoist")]
    public bool Hoist { get; set; }

    [JsonPropertyName("icon")]
    public string Icon { get; set; }

    [JsonPropertyName("managed")]
    public bool Managed { get; set; }

    [JsonPropertyName("mentionable")]
    public bool Mentionable { get; set; }

    [JsonPropertyName("name")]
    public string Name { get; set; }

    [JsonPropertyName("permissions"), JsonNumberHandling(JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString)]
    public required ulong RawPermissions { get; set; }

    [JsonIgnore]
    public Permissions Permissions {
        get => (Permissions)RawPermissions;
        set => RawPermissions = (ulong)value;
    }

    [JsonPropertyName("position")]
    public int Position { get; set; }

    [JsonPropertyName("unicode_emoji")]
    public string UnicodeEmoji { get; set; }

    public class RoleColors {
        [JsonPropertyName("primary_color")]
        public required int PrimaryColor { get; set; }

        [JsonPropertyName("secondary_color")]
        public int? SecondaryColor { get; set; }

        [JsonPropertyName("tertiary_color")]
        public int? TertiaryColor { get; set; }
    }
}