use crate::model::{
event_types::{macros::repo_origin, RepoEventInfo},
prelude::*,
releases::Release,
};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseEvent {
pub action: ReleaseAction,
pub release: Release,
#[serde(flatten)]
pub event_info: RepoEventInfo,
}
as_ref_and_deref!(ReleaseEvent, RepoEventInfo, event_info);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum ReleaseAction {
Published,
Unpublished,
Created,
Edited,
Deleted,
#[strum(serialize = "prereleased")]
PreReleased,
Released,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreateEvent {
#[serde(rename = "ref")]
pub ref_field: String,
pub ref_type: RefType,
pub master_branch: String,
pub description: String,
pub pusher_type: String,
#[serde(flatten)]
pub event_info: RepoEventInfo,
}
as_ref_and_deref!(CreateEvent, RepoEventInfo, event_info);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeleteEvent {
#[serde(rename = "ref")]
pub ref_field: String,
pub ref_type: RefType,
pub pusher_type: String,
#[serde(flatten)]
pub event_info: RepoEventInfo,
}
as_ref_and_deref!(DeleteEvent, RepoEventInfo, event_info);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, EnumString, EnumVariantNames)]
#[strum(serialize_all = "snake_case")]
pub enum RefType {
Branch,
Tag,
}
repo_origin!(ReleaseEvent);
repo_origin!(CreateEvent);
repo_origin!(DeleteEvent);