use chrono::{DateTime, Utc}; use serde::Deserialize; #[derive(Deserialize, Debug)] pub struct CommitAuthor { pub name: String, pub email: String, pub username: String, } #[derive(Deserialize, Debug)] pub struct User { pub id: u32, pub login: String, pub full_name: String, pub email: String, pub avatar_url: String, pub username: String, } #[derive(Deserialize, Debug)] pub struct Commit { pub id: String, pub message: String, pub url: String, pub author: CommitAuthor, pub committer: CommitAuthor, pub timestamp: DateTime, } #[derive(Deserialize, Debug)] pub struct Perms { admin: bool, push: bool, pull: bool, } #[derive(Deserialize, Debug)] pub struct InternalTracker { enable_time_tracker: bool, allow_only_contributors_to_track_time: bool, enable_issue_dependencies: bool, } #[derive(Deserialize, Debug)] pub struct Repository { pub id: u32, pub owner: User, pub name: String, pub full_name: String, pub description: String, pub private: bool, pub fork: bool, pub html_url: String, pub ssh_url: String, pub clone_url: String, pub website: String, pub stars_count: u32, pub forks_count: u32, pub watchers_count: u32, pub open_issues_count: u32, pub default_branch: String, pub created_at: DateTime, pub updated_at: DateTime, } #[derive(Deserialize, Debug)] pub struct RepositoryFull { pub id: u32, pub owner: RepositoryOwner, pub name: String, pub full_name: String, pub description: String, pub empty: bool, pub private: bool, pub fork: bool, pub template: bool, pub parent: Option>, pub mirror: bool, pub size: u32, pub language: String, pub languages_url: String, pub html_url: String, pub url: String, pub link: String, pub ssh_url: String, pub clone_url: String, pub website: String, pub stars_count: u32, pub forks_count: u32, pub watchers_count: u32, pub open_issues_count: u32, pub open_pr_counter: u32, pub default_branch: String, pub created_at: DateTime, pub updated_at: DateTime, pub archived_at: DateTime, pub permissions: Perms, pub has_issues: bool, pub internal_tracker: InternalTracker, pub has_wiki: bool, pub has_pull_requests: bool, pub has_projects: bool, pub has_releases: bool, pub has_actions: bool, pub ignore_whitespace_conflicts: bool, pub allow_merge_commits: bool, pub allow_rebase: bool, pub allow_rebase_explicit: bool, pub allow_squash_merge: bool, pub allow_rebase_update: bool, pub default_delete_branch_after_merge: bool, pub default_merge_style: String, pub default_allow_maintainer_edit: bool, pub avatar_url: String, pub internal: bool, pub mirror_internal: String, pub mirror_updated: DateTime, pub repo_transfer: Option, } #[derive(Deserialize, Debug)] pub struct RepositoryOwner { pub id: u32, pub login: String, pub login_name: String, pub full_name: String, pub email: String, pub avatar_url: String, pub language: String, pub is_admin: bool, pub last_login: DateTime, pub created: DateTime, pub restricted: bool, pub active: bool, pub prohibit_login: bool, pub location: String, pub website: String, pub description: String, pub visibility: String, pub followers_count: u32, pub following_count: u32, pub starred_repos_count: u32, pub username: String, } #[derive(Deserialize, Debug)] pub struct Push { #[serde(rename(deserialize = "ref"))] pub ref_: String, pub before: String, pub compare_url: String, pub commits: Vec, pub repository: Repository, pub pusher: User, pub sender: User, } #[derive(Deserialize, Debug)] pub enum RefType { Branch, } #[derive(Deserialize, Debug)] pub struct AddedBranch { pub sha: String, pub ref_type: String, pub repository: Repository, pub sender: RepositoryOwner, } #[derive(Deserialize, Debug)] pub struct RemovedBranch { pub sha: String, pub ref_type: String, pub pusher_type: String, pub repository: Repository, pub sender: RepositoryOwner, } #[derive(Deserialize, Debug)] #[serde(untagged)] pub enum Hook { Push(Push), AddedBranch(AddedBranch), RemovedBranch(RemovedBranch), }