diff --git a/src/issue.rs b/src/issue.rs index 4d4b8d2..25126b1 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -1,75 +1,139 @@ use super::*; impl Forgejo { - pub async fn get_repo_issues(&self, owner: &str, repo: &str, query: IssueQuery) -> Result, ForgejoError> { + pub async fn get_repo_issues( + &self, + owner: &str, + repo: &str, + query: IssueQuery, + ) -> Result, ForgejoError> { self.get(&query.to_string(owner, repo)).await } - pub async fn create_issue(&self, owner: &str, repo: &str, opts: CreateIssueOption) -> Result { - self.post(&format!("repos/{owner}/{repo}/issues"), &opts).await + pub async fn create_issue( + &self, + owner: &str, + repo: &str, + opts: CreateIssueOption, + ) -> Result { + self.post(&format!("repos/{owner}/{repo}/issues"), &opts) + .await } - pub async fn get_issue(&self, owner: &str, repo: &str, id: u64) -> Result, ForgejoError> { - self.get_opt(&format!("repos/{owner}/{repo}/issues/{id}")).await + pub async fn get_issue( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + self.get_opt(&format!("repos/{owner}/{repo}/issues/{id}")) + .await } pub async fn delete_issue(&self, owner: &str, repo: &str, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("repos/{owner}/{repo}/issues/{id}")).await + self.delete(&format!("repos/{owner}/{repo}/issues/{id}")) + .await } - pub async fn edit_issue(&self, owner: &str, repo: &str, id: u64, opts: EditIssueOption) -> Result { - self.patch(&format!("repos/{owner}/{repo}/issues/{id}"), &opts).await + pub async fn edit_issue( + &self, + owner: &str, + repo: &str, + id: u64, + opts: EditIssueOption, + ) -> Result { + self.patch(&format!("repos/{owner}/{repo}/issues/{id}"), &opts) + .await } - - pub async fn get_repo_comments(&self, owner: &str, repo: &str, query: RepoCommentQuery) -> Result, ForgejoError> { + pub async fn get_repo_comments( + &self, + owner: &str, + repo: &str, + query: RepoCommentQuery, + ) -> Result, ForgejoError> { self.get(&query.to_string(owner, repo)).await } - pub async fn get_issue_comments(&self, owner: &str, repo: &str, issue_id: u64, query: IssueCommentQuery) -> Result, ForgejoError> { + pub async fn get_issue_comments( + &self, + owner: &str, + repo: &str, + issue_id: u64, + query: IssueCommentQuery, + ) -> Result, ForgejoError> { self.get(&query.to_string(owner, repo, issue_id)).await } - pub async fn create_comment(&self, owner: &str, repo: &str, issue_id: u64, opts: CreateIssueCommentOption) -> Result { - self.post(&format!("repos/{owner}/{repo}/issues/{issue_id}/comments"), &opts).await + pub async fn create_comment( + &self, + owner: &str, + repo: &str, + issue_id: u64, + opts: CreateIssueCommentOption, + ) -> Result { + self.post( + &format!("repos/{owner}/{repo}/issues/{issue_id}/comments"), + &opts, + ) + .await } - pub async fn get_comment(&self, owner: &str, repo: &str, id: u64) -> Result, ForgejoError> { - self.get_opt(&format!("repos/{owner}/{repo}/issues/comments/{id}")).await + pub async fn get_comment( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result, ForgejoError> { + self.get_opt(&format!("repos/{owner}/{repo}/issues/comments/{id}")) + .await } - pub async fn delete_comment(&self, owner: &str, repo: &str, id: u64) -> Result<(), ForgejoError> { - self.delete(&format!("repos/{owner}/{repo}/issues/comments/{id}")).await + pub async fn delete_comment( + &self, + owner: &str, + repo: &str, + id: u64, + ) -> Result<(), ForgejoError> { + self.delete(&format!("repos/{owner}/{repo}/issues/comments/{id}")) + .await } - pub async fn edit_comment(&self, owner: &str, repo: &str, id: u64, opts: EditIssueCommentOption) -> Result { - self.patch(&format!("repos/{owner}/{repo}/issues/comments/{id}"), &opts).await + pub async fn edit_comment( + &self, + owner: &str, + repo: &str, + id: u64, + opts: EditIssueCommentOption, + ) -> Result { + self.patch(&format!("repos/{owner}/{repo}/issues/comments/{id}"), &opts) + .await } } #[derive(serde::Deserialize, Debug, PartialEq)] pub struct Issue { pub assets: Vec, - pub assignee: User, - pub assignees: Vec, + pub assignee: Option, + pub assignees: Option>, pub body: String, - #[serde(with = "time::serde::rfc3339")] - pub closed_at: time::OffsetDateTime, + #[serde(with = "time::serde::rfc3339::option")] + pub closed_at: Option, pub comments: u64, #[serde(with = "time::serde::rfc3339")] pub created_at: time::OffsetDateTime, - #[serde(with = "time::serde::rfc3339")] - pub due_date: time::OffsetDateTime, + #[serde(with = "time::serde::rfc3339::option")] + pub due_date: Option, pub html_url: Url, pub id: u64, pub is_locked: bool, pub labels: Vec