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
use crate::model::{prelude::*, user::SimpleUser};
use std::collections::HashMap;

/// <https://docs.github.com/en/rest/gists/gists#list-gists-for-the-authenticated-user=>
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SimpleGist {
    pub id: String,
    pub node_id: String,
    pub url: String,
    pub forks_url: String,
    pub commits_url: String,
    pub git_pull_url: String,
    pub git_push_url: String,
    pub html_url: String,
    pub comments_url: String,
    pub public: bool,
    pub description: Option<String>,
    pub comments: usize,
    pub user: Option<SimpleUser>,
    pub files: HashMap<String, File>,
    pub created_at: String,
    pub updated_at: String,
}

/// <https://docs.github.com/en/rest/gists/gists#get-a-gist=>
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Gist {
    pub owner: SimpleUser,
    pub truncated: bool,
    #[serde(flatten)]
    pub shared: SimpleGist,
}

as_ref_and_deref!(Gist, SimpleGist, shared);

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct File {
    pub filename: String,
    #[serde(rename = "type")]
    pub type_field: String,
    pub language: Option<String>,
    pub raw_url: String,
    pub size: i64,
    pub content: Option<String>,
}