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
68
69
70
71
use crate::model::{apps::events::nested::RepoInfo, prelude::*, user::SimpleUser};

/// <https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InstallationEvent {
    pub action: InstallationAction,
    pub repositories: Vec<RepoInfo>,
    pub installation: Value,
    pub sender: SimpleUser,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum InstallationAction {
    Created,
    Deleted,
    Suspend,
    Unsuspend,
    NewPermissionsAccepted,
}

pub mod nested {
    use crate::model::prelude::*;

    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct RepoInfo {
        pub id: usize,
        pub node: String,
        pub name: String,
        pub full_name: String,
        pub private: bool,
    }
}

/// <https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#installation_repositories>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct InstallationRepositoriesEvent {
    pub action: InstallationRepositoriesAction,
    pub repository_selection: RepositorySelection,
    pub repositories_added: Vec<RepoInfo>,
    pub repositories_removed: Vec<RepoInfo>,
    pub installation: Value,
    pub sender: SimpleUser,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum InstallationRepositoriesAction {
    Added,
    Removed,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum RepositorySelection {
    Selected,
    All,
}

/// <https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#github_app_authorization>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AppAuthorizationEvent {
    pub action: String,
    pub sender: SimpleUser,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum AppAuthorizationAction {
    Revoked,
}