1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct Issue {
7 pub id: String,
8 pub identifier: String,
9 pub title: String,
10 pub description: Option<String>,
11 pub priority: i32,
12 pub state: Option<IssueState>,
13 pub assignee: Option<User>,
14 pub project: Option<Project>,
15 pub team: Option<Team>,
16 pub labels: Option<LabelConnection>,
17 pub created_at: String,
18 pub updated_at: String,
19 pub completed_at: Option<String>,
20 pub url: String,
21}
22
23#[derive(Debug, Clone, Deserialize)]
25#[serde(rename_all = "camelCase")]
26pub struct IssueState {
27 pub id: String,
28 pub name: String,
29 pub color: String,
30 #[serde(rename = "type")]
31 pub state_type: String,
32}
33
34#[derive(Debug, Clone, Deserialize)]
36#[serde(rename_all = "camelCase")]
37pub struct User {
38 pub id: String,
39 pub name: String,
40 pub email: String,
41 pub display_name: String,
42 pub avatar_url: Option<String>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct Project {
49 pub id: String,
50 pub name: String,
51 pub description: Option<String>,
52 pub state: String,
53 pub url: String,
54 pub created_at: String,
55 pub updated_at: String,
56}
57
58#[derive(Debug, Clone, Deserialize)]
60#[serde(rename_all = "camelCase")]
61pub struct Team {
62 pub id: String,
63 pub name: String,
64 pub key: String,
65 pub description: Option<String>,
66}
67
68#[derive(Debug, Clone, Deserialize)]
70#[serde(rename_all = "camelCase")]
71pub struct Label {
72 pub id: String,
73 pub name: String,
74 pub color: String,
75}
76
77#[derive(Debug, Clone, Deserialize)]
79pub struct LabelConnection {
80 pub nodes: Vec<Label>,
81}
82
83#[derive(Debug, Clone, Deserialize)]
85#[serde(rename_all = "camelCase")]
86pub struct Cycle {
87 pub id: String,
88 pub number: i32,
89 pub name: Option<String>,
90 pub starts_at: String,
91 pub ends_at: String,
92 pub completed_at: Option<String>,
93}
94
95#[derive(Debug, Clone, Deserialize)]
97#[serde(rename_all = "camelCase")]
98pub struct IssueConnection {
99 pub nodes: Vec<Issue>,
100 pub page_info: PageInfo,
101}
102
103#[derive(Debug, Clone, Deserialize)]
105#[serde(rename_all = "camelCase")]
106pub struct PageInfo {
107 pub has_next_page: bool,
108 pub has_previous_page: bool,
109 pub start_cursor: Option<String>,
110 pub end_cursor: Option<String>,
111}
112
113#[derive(Debug, Clone, Default, Serialize)]
115#[serde(rename_all = "camelCase")]
116pub struct IssueCreateInput {
117 pub title: String,
118 pub team_id: String,
119 #[serde(skip_serializing_if = "Option::is_none")]
120 pub description: Option<String>,
121 #[serde(skip_serializing_if = "Option::is_none")]
122 pub assignee_id: Option<String>,
123 #[serde(skip_serializing_if = "Option::is_none")]
124 pub project_id: Option<String>,
125 #[serde(skip_serializing_if = "Option::is_none")]
126 pub state_id: Option<String>,
127 #[serde(skip_serializing_if = "Option::is_none")]
128 pub priority: Option<i32>,
129 #[serde(skip_serializing_if = "Option::is_none")]
130 pub label_ids: Option<Vec<String>>,
131}
132
133impl IssueCreateInput {
134 pub fn new(title: impl Into<String>, team_id: impl Into<String>) -> Self {
135 Self {
136 title: title.into(),
137 team_id: team_id.into(),
138 ..Default::default()
139 }
140 }
141
142 pub fn description(mut self, desc: impl Into<String>) -> Self {
143 self.description = Some(desc.into());
144 self
145 }
146
147 pub fn assignee(mut self, id: impl Into<String>) -> Self {
148 self.assignee_id = Some(id.into());
149 self
150 }
151
152 pub fn project(mut self, id: impl Into<String>) -> Self {
153 self.project_id = Some(id.into());
154 self
155 }
156
157 pub fn priority(mut self, priority: i32) -> Self {
158 self.priority = Some(priority);
159 self
160 }
161}
162
163#[derive(Debug, Clone, Default, Serialize)]
165#[serde(rename_all = "camelCase")]
166pub struct IssueUpdateInput {
167 #[serde(skip_serializing_if = "Option::is_none")]
168 pub title: Option<String>,
169 #[serde(skip_serializing_if = "Option::is_none")]
170 pub description: Option<String>,
171 #[serde(skip_serializing_if = "Option::is_none")]
172 pub assignee_id: Option<String>,
173 #[serde(skip_serializing_if = "Option::is_none")]
174 pub state_id: Option<String>,
175 #[serde(skip_serializing_if = "Option::is_none")]
176 pub priority: Option<i32>,
177 #[serde(skip_serializing_if = "Option::is_none")]
178 pub project_id: Option<String>,
179 #[serde(skip_serializing_if = "Option::is_none")]
180 pub label_ids: Option<Vec<String>>,
181}
182
183impl IssueUpdateInput {
184 pub fn new() -> Self {
185 Self::default()
186 }
187
188 pub fn title(mut self, title: impl Into<String>) -> Self {
189 self.title = Some(title.into());
190 self
191 }
192
193 pub fn description(mut self, desc: impl Into<String>) -> Self {
194 self.description = Some(desc.into());
195 self
196 }
197
198 pub fn state(mut self, id: impl Into<String>) -> Self {
199 self.state_id = Some(id.into());
200 self
201 }
202
203 pub fn assignee(mut self, id: impl Into<String>) -> Self {
204 self.assignee_id = Some(id.into());
205 self
206 }
207
208 pub fn priority(mut self, priority: i32) -> Self {
209 self.priority = Some(priority);
210 self
211 }
212}
213
214#[derive(Debug, Clone, Default, Serialize)]
216#[serde(rename_all = "camelCase")]
217pub struct IssueFilter {
218 #[serde(skip_serializing_if = "Option::is_none")]
219 pub team: Option<TeamFilter>,
220 #[serde(skip_serializing_if = "Option::is_none")]
221 pub project: Option<ProjectFilter>,
222 #[serde(skip_serializing_if = "Option::is_none")]
223 pub state: Option<StateFilter>,
224 #[serde(skip_serializing_if = "Option::is_none")]
225 pub assignee: Option<UserFilter>,
226}
227
228#[derive(Debug, Clone, Serialize)]
229pub struct TeamFilter {
230 pub id: IdComparator,
231}
232
233#[derive(Debug, Clone, Serialize)]
234pub struct ProjectFilter {
235 pub id: IdComparator,
236}
237
238#[derive(Debug, Clone, Serialize)]
239pub struct StateFilter {
240 pub name: StringComparator,
241}
242
243#[derive(Debug, Clone, Serialize)]
244pub struct UserFilter {
245 pub id: IdComparator,
246}
247
248#[derive(Debug, Clone, Serialize)]
249pub struct IdComparator {
250 pub eq: String,
251}
252
253#[derive(Debug, Clone, Serialize)]
254pub struct StringComparator {
255 pub eq: String,
256}
257
258#[derive(Debug, Clone, Deserialize)]
260#[serde(rename_all = "camelCase")]
261pub struct IssuePayload {
262 pub success: bool,
263 pub issue: Option<Issue>,
264}