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
63
64
65
66
67
use super::*;

/// Various information about integrations.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct Integration {
    pub id: IntegrationId,
    pub guild_id: GuildId,
    pub account: IntegrationAccount,
    pub enabled: bool,
    #[serde(rename = "expire_behaviour")]
    pub expire_behaviour: Option<IntegrationExpireBehaviour>,
    pub expire_grace_period: Option<u64>,
    #[serde(rename = "type")]
    pub kind: String,
    pub name: String,
    pub role_id: Option<RoleId>,
    pub synced_at: Option<u64>,
    pub syncing: Option<bool>,
    pub user: Option<User>,
    pub enable_emoticons: Option<bool>,
    pub subscriber_count: Option<u64>,
    pub revoked: Option<bool>,
    pub application: Option<IntegrationApplication>,
}

/// The behavior once the integration expires.
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum IntegrationExpireBehaviour {
    RemoveRole = 0,
    Kick = 1,
    Unknown = !0,
}

enum_number!(IntegrationExpireBehaviour {
    RemoveRole,
    Kick
});

impl From<Integration> for IntegrationId {
    /// Gets the Id of integration.
    fn from(integration: Integration) -> IntegrationId {
        integration.id
    }
}

/// Integration account object.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct IntegrationAccount {
    pub id: String,
    pub name: String,
}

/// Integration application object.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct IntegrationApplication {
    pub id: ApplicationId,
    pub name: String,
    pub icon: Option<String>,
    pub description: String,
    pub summary: String,
    pub bot: Option<User>,
}