1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use crate::model::{
    commits::association::Association,
    issues::{
        milestones::Milestone,
        nested::{StringOrLabel, *},
    },
    prelude::*,
    user::SimpleUser,
};

pub type Issues = Vec<Issue>;

/// <https://docs.github.com/en/rest/issues/issues#get-an-issue=>
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Issue {
    pub assignee: Option<SimpleUser>,
    pub closed_at: Option<String>,
    pub comments: i64,
    pub comments_url: String,
    pub events_url: String,
    pub html_url: String,
    pub id: i64,
    pub node_id: String,
    pub labels: Vec<StringOrLabel>,
    pub labels_url: String,
    pub milestone: Option<Milestone>,
    pub number: i64,
    pub repository_url: String,
    pub state: IssueState,
    pub locked: bool,
    pub title: String,
    pub url: String,
    pub user: Option<SimpleUser>,
    pub author_association: Association,
    pub created_at: String,
    pub updated_at: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Label {
    pub id: i64,
    pub node_id: String,
    pub url: String,
    pub name: String,
    pub description: Option<String>,
    pub color: String,
    pub default: bool,
}

pub mod nested {
    use crate::model::{issues::Label, prelude::*};

    #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
    #[serde(rename_all = "lowercase")]
    pub enum IssueState {
        Open,
        Closed,
    }

    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    #[serde(untagged)]
    pub enum StringOrLabel {
        String(String),
        Label(Label),
    }
}