use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "lowercase")]
pub enum PullRequestState {
Open,
Closed,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct PullRequestEventPayload {
pub pull_request: PullRequestInfo,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct PullRequestInfo {
pub draft: bool,
pub locked: bool,
pub number: u64,
pub state: PullRequestState,
}
#[derive(Debug, Serialize)]
pub struct FullReview {
pub event: String,
pub body: String,
pub comments: Vec<ReviewDiffComment>,
}
#[derive(Debug, Serialize)]
pub struct ReviewDiffComment {
pub body: String,
pub line: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_line: Option<i64>,
pub path: String,
}
impl From<&crate::ReviewComment> for ReviewDiffComment {
fn from(comment: &crate::ReviewComment) -> Self {
Self {
body: comment.comment.clone(),
line: comment.line_end as i64,
start_line: comment.line_start.map(|i| i as i64),
path: comment.path.clone(),
}
}
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ReviewState {
ChangesRequested,
Pending,
Dismissed,
Approved,
Comment,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ReviewSummary {
pub body: Option<String>,
pub id: i64,
pub node_id: String,
pub state: ReviewState,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ThreadComment {
pub id: i64,
pub body: String,
pub user: User,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct User {
pub login: String,
pub id: u64,
}
#[cfg(feature = "file-changes")]
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct GithubChangedFile {
pub filename: String,
pub previous_filename: Option<String>,
pub patch: Option<String>,
pub changes: i64,
}
#[cfg(feature = "file-changes")]
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct PushEventFiles {
pub files: Vec<GithubChangedFile>,
}