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
67
68
use serde::{Deserialize, Serialize};

use super::{
    issues::{Label, StateType},
    repos::Repository,
    user::User,
};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PullRequest {
    pub additions: i64,
    pub allow_maintainer_edit: bool,
    pub assignees: Vec<User>,
    pub base: PrBranchInfo,
    pub body: String,
    pub changed_files: i64,
    pub closed_at: String,
    pub comments: i64,
    pub created_at: String,
    pub deletions: i64,
    pub diff_url: String,
    pub draft: bool,
    pub due_date: String,
    pub head: PrBranchInfo,
    pub html_url: String,
    pub id: i64,
    pub is_locked: bool,
    pub labels: Vec<Label>,
    pub merge_base: String,
    pub merge_commit_sha: String,
    pub mergeable: bool,
    pub merged: bool,
    pub merged_at: String,
    pub merged_by: Option<User>,
    // TODO: pub milestone: Option<Milestone>,
    pub number: i64,
    pub patch_url: String,
    pub pin_order: i64,
    pub requested_reviewers: Vec<User>,
    /// Number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
    pub review_comments: i64,
    pub state: StateType,
    pub title: String,
    // TODO: Make this a DateTime<Utc>
    pub updated_at: String,
    pub url: String,
    pub user: User,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrBranchInfo {
    pub label: String,
    pub r#ref: String,
    pub repo: Repository,
    pub repo_id: i64,
    pub sha: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Sort {
    Oldest,
    RecentUpdate,
    LeastUpdate,
    MostComment,
    LeastComment,
    Priority,
}