Skip to main content

gitee_rs/issues/
models.rs

1use serde::{Deserialize, Serialize};
2use crate::users::User;
3use crate::labels::Label;
4use crate::utils::deserialize_string_or_int;
5
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct Issue {
8    #[serde(deserialize_with = "deserialize_string_or_int")]
9    pub id: String,  // Gitee API may return string or integer IDs
10    #[serde(deserialize_with = "deserialize_string_or_int")]
11    pub number: String,
12    pub title: String,
13    pub body: Option<String>,
14    pub state: String, // "open" or "closed"
15    pub html_url: String,
16    #[serde(default)]
17    pub api_url: String,
18    pub created_at: Option<String>,
19    pub updated_at: Option<String>,
20    #[serde(default)]
21    pub user: Option<User>,
22    #[serde(default)]
23    pub assignee: Option<User>,
24    #[serde(default)]
25    pub labels: Vec<Label>,
26    #[serde(default)]
27    pub milestone: Option<Milestone>,
28}
29
30#[derive(Debug, Clone, Deserialize, Serialize)]
31pub struct Milestone {
32    #[serde(deserialize_with = "deserialize_string_or_int")]
33    pub id: String,  // Gitee API may return string or integer IDs
34    pub title: String,
35    #[serde(default)]
36    pub description: Option<String>,
37    #[serde(default)]
38    pub state: String,
39}
40
41#[derive(Debug, Clone, Deserialize, Serialize)]
42pub struct Comment {
43    #[serde(deserialize_with = "deserialize_string_or_int")]
44    pub id: String,  // Gitee API may return string or integer IDs
45    pub body: String,
46    #[serde(default)]
47    pub user: Option<User>,
48    pub created_at: String,
49    pub updated_at: String,
50}
51
52#[derive(Debug, Clone, Default, serde::Serialize)]
53pub struct IssueListOptions {
54    pub state: Option<String>,
55    pub labels: Option<String>,
56    pub sort: Option<String>,
57    pub direction: Option<String>,
58    pub since: Option<String>,
59    pub schedule: Option<String>,
60    pub deadline: Option<String>,
61    pub created_at: Option<String>,
62    pub finished_at: Option<String>,
63    pub filter: Option<String>,
64    pub page: Option<i32>,
65    pub per_page: Option<i32>,
66    pub q: Option<String>,
67}