use giterated_models::{operation::GiteratedOperation, repository::Repository, user::User}; use serde::{Deserialize, Serialize}; use crate::Issue; /// Create an [`Issue`] on a [`Repository`]. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CreateIssueRequest { pub name: String, pub contents: String, pub author: User, } impl GiteratedOperation for CreateIssueRequest { type Success = Issue; type Failure = IssueCreationError; } #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)] #[error("failed to create issue")] pub struct IssueCreationError; /// Query for [`Issue`]s on a [`Repository`]. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct QueryIssuesRequest {} impl GiteratedOperation for QueryIssuesRequest { type Success = Vec; type Failure = IssueQueryError; } #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)] #[error("failed to query issues")] pub struct IssueQueryError; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssueEditRequest { // Might not be needed :) } impl GiteratedOperation for IssueEditRequest { type Success = (); type Failure = IssueEditError; } #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)] #[error("failed to edit issue")] pub struct IssueEditError; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct IssuePostCommentRequest { pub contents: String, pub visibility: CommentVisibility, } impl GiteratedOperation for IssuePostCommentRequest { type Success = u32; type Failure = IssuePostCommentError; } #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)] #[error("failed to post comment")] pub struct IssuePostCommentError; #[derive(PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Clone, sqlx::Type)] #[sqlx(type_name = "comment_visibility", rename_all = "lowercase")] pub enum CommentVisibility { Public, Maintainers, Private, }