Skip to main content

gitee_rs/pulls/
models.rs

1use serde::{Deserialize, Serialize};
2use crate::users::User;
3use crate::repos::Repository;
4use crate::utils::deserialize_string_or_int;
5
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct PullRequest {
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", "closed", "merged"
15    pub html_url: String,
16    pub created_at: String,
17    pub updated_at: String,
18    #[serde(default)]
19    pub user: Option<User>,
20    #[serde(default)]
21    pub assignee: Option<User>,
22    pub head: BranchRef,
23    pub base: BranchRef,
24}
25
26#[derive(Debug, Clone, Deserialize, Serialize)]
27pub struct BranchRef {
28    pub label: String,
29    #[serde(rename = "ref")]
30    pub ref_name: String, // "ref" is a reserved keyword in Rust
31    pub sha: String,
32    pub user: User,
33    #[serde(default)]
34    pub repo: Option<Repository>,
35}
36
37#[derive(Debug, Clone, Deserialize, Serialize)]
38pub struct Comment {
39    #[serde(deserialize_with = "deserialize_string_or_int")]
40    pub id: String,  // Gitee API may return string or integer IDs
41    pub body: String,
42    #[serde(default)]
43    pub user: Option<User>,
44    pub created_at: String,
45    pub updated_at: String,
46}
47
48#[derive(Debug, Clone, Deserialize, Serialize)]
49pub struct FileDiff {
50    pub sha: String,
51    pub filename: String,
52    pub status: String, // "added", "removed", "modified"
53    pub additions: i32,
54    pub deletions: i32,
55    pub changes: i32,
56    #[serde(rename = "blob_url")]
57    pub blob_url: String,
58    #[serde(rename = "raw_url")]
59    pub raw_url: String,
60}
61
62#[derive(Debug, Clone, Default, serde::Serialize)]
63pub struct PullListOptions {
64    pub state: Option<String>,
65    pub head: Option<String>,
66    pub base: Option<String>,
67    pub sort: Option<String>,
68    pub direction: Option<String>,
69    pub milestone_number: Option<i32>,
70    pub labels: Option<String>,
71    pub page: Option<i32>,
72    pub per_page: Option<i32>,
73}