1#![allow(clippy::too_many_arguments)]
8use super::inputs::*;
9use crate::client::Client;
10use crate::error::LinearError;
11pub async fn file_upload(
13 client: &Client,
14 meta_data: Option<serde_json::Value>,
15 make_public: Option<bool>,
16 size: i64,
17 content_type: String,
18 filename: String,
19) -> Result<serde_json::Value, LinearError> {
20 let variables = serde_json::json!(
21 { "metaData" : meta_data, "makePublic" : make_public, "size" : size,
22 "contentType" : content_type, "filename" : filename }
23 );
24 let mut response_parts: Vec<String> = vec!["success".to_string()];
25 response_parts.push(format!(
26 "{} {{ {} }}",
27 "uploadFile",
28 <super::types::UploadFile as crate::field_selection::GraphQLFields>::selection()
29 ));
30 let query = String::from(
31 "mutation FileUpload($metaData: JSON, $makePublic: Boolean, $size: Int!, $contentType: String!, $filename: String!) { fileUpload(metaData: $metaData, makePublic: $makePublic, size: $size, contentType: $contentType, filename: $filename) { ",
32 ) + &response_parts.join(" ") + " } }";
33 client
34 .execute::<serde_json::Value>(&query, variables, "fileUpload")
35 .await
36}
37pub async fn image_upload_from_url(
39 client: &Client,
40 url: String,
41) -> Result<serde_json::Value, LinearError> {
42 let variables = serde_json::json!({ "url" : url });
43 let response_parts: Vec<String> = vec!["url".to_string(), "success".to_string()];
44 let query = String::from(
45 "mutation ImageUploadFromUrl($url: String!) { imageUploadFromUrl(url: $url) { ",
46 ) + &response_parts.join(" ")
47 + " } }";
48 client
49 .execute::<serde_json::Value>(&query, variables, "imageUploadFromUrl")
50 .await
51}
52pub async fn comment_create<
56 T: serde::de::DeserializeOwned
57 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
58>(
59 client: &Client,
60 input: CommentCreateInput,
61) -> Result<T, LinearError> {
62 let variables = serde_json::json!({ "input" : input });
63 let query = String::from(
64 "mutation CommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { ",
65 ) + &T::selection() + " } } }";
66 client
67 .execute_mutation::<T>(&query, variables, "commentCreate", "comment")
68 .await
69}
70pub async fn project_create<
74 T: serde::de::DeserializeOwned
75 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
76>(
77 client: &Client,
78 slack_channel_name: Option<String>,
79 input: ProjectCreateInput,
80) -> Result<T, LinearError> {
81 let variables = serde_json::json!(
82 { "slackChannelName" : slack_channel_name, "input" : input }
83 );
84 let query = String::from(
85 "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
86 ) + &T::selection() + " } } }";
87 client
88 .execute_mutation::<T>(&query, variables, "projectCreate", "project")
89 .await
90}
91pub async fn project_update<
95 T: serde::de::DeserializeOwned
96 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
97>(
98 client: &Client,
99 input: ProjectUpdateInput,
100 id: String,
101) -> Result<T, LinearError> {
102 let variables = serde_json::json!({ "input" : input, "id" : id });
103 let query = String::from(
104 "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
105 ) + &T::selection() + " } } }";
106 client
107 .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
108 .await
109}
110pub async fn project_delete<
114 T: serde::de::DeserializeOwned
115 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
116>(
117 client: &Client,
118 id: String,
119) -> Result<T, LinearError> {
120 let variables = serde_json::json!({ "id" : id });
121 let query = String::from(
122 "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
123 ) + &T::selection()
124 + " } } }";
125 client
126 .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
127 .await
128}
129pub async fn project_milestone_create<
133 T: serde::de::DeserializeOwned
134 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
135>(
136 client: &Client,
137 input: ProjectMilestoneCreateInput,
138) -> Result<T, LinearError> {
139 let variables = serde_json::json!({ "input" : input });
140 let query = String::from(
141 "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
142 ) + &T::selection() + " } } }";
143 client
144 .execute_mutation::<T>(
145 &query,
146 variables,
147 "projectMilestoneCreate",
148 "projectMilestone",
149 )
150 .await
151}
152pub async fn project_milestone_update<
156 T: serde::de::DeserializeOwned
157 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
158>(
159 client: &Client,
160 input: ProjectMilestoneUpdateInput,
161 id: String,
162) -> Result<T, LinearError> {
163 let variables = serde_json::json!({ "input" : input, "id" : id });
164 let query = String::from(
165 "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
166 ) + &T::selection() + " } } }";
167 client
168 .execute_mutation::<T>(
169 &query,
170 variables,
171 "projectMilestoneUpdate",
172 "projectMilestone",
173 )
174 .await
175}
176pub async fn project_milestone_delete(
178 client: &Client,
179 id: String,
180) -> Result<serde_json::Value, LinearError> {
181 let variables = serde_json::json!({ "id" : id });
182 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
183 let query = String::from(
184 "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
185 ) + &response_parts.join(" ")
186 + " } }";
187 client
188 .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
189 .await
190}
191pub async fn issue_create<
195 T: serde::de::DeserializeOwned
196 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
197>(
198 client: &Client,
199 input: IssueCreateInput,
200) -> Result<T, LinearError> {
201 let variables = serde_json::json!({ "input" : input });
202 let query = String::from(
203 "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
204 ) + &T::selection() + " } } }";
205 client
206 .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
207 .await
208}
209pub async fn issue_update<
213 T: serde::de::DeserializeOwned
214 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
215>(
216 client: &Client,
217 input: IssueUpdateInput,
218 id: String,
219) -> Result<T, LinearError> {
220 let variables = serde_json::json!({ "input" : input, "id" : id });
221 let query = String::from(
222 "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
223 ) + &T::selection() + " } } }";
224 client
225 .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
226 .await
227}
228pub async fn issue_archive<
232 T: serde::de::DeserializeOwned
233 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
234>(
235 client: &Client,
236 trash: Option<bool>,
237 id: String,
238) -> Result<T, LinearError> {
239 let variables = serde_json::json!({ "trash" : trash, "id" : id });
240 let query = String::from(
241 "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
242 ) + &T::selection() + " } } }";
243 client
244 .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
245 .await
246}
247pub async fn issue_unarchive<
251 T: serde::de::DeserializeOwned
252 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
253>(
254 client: &Client,
255 id: String,
256) -> Result<T, LinearError> {
257 let variables = serde_json::json!({ "id" : id });
258 let query = String::from(
259 "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
260 ) + &T::selection()
261 + " } } }";
262 client
263 .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
264 .await
265}
266pub async fn issue_delete<
270 T: serde::de::DeserializeOwned
271 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
272>(
273 client: &Client,
274 permanently_delete: Option<bool>,
275 id: String,
276) -> Result<T, LinearError> {
277 let variables = serde_json::json!(
278 { "permanentlyDelete" : permanently_delete, "id" : id }
279 );
280 let query = String::from(
281 "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
282 ) + &T::selection() + " } } }";
283 client
284 .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
285 .await
286}
287pub async fn issue_relation_create<
291 T: serde::de::DeserializeOwned
292 + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
293>(
294 client: &Client,
295 override_created_at: Option<serde_json::Value>,
296 input: IssueRelationCreateInput,
297) -> Result<T, LinearError> {
298 let variables = serde_json::json!(
299 { "overrideCreatedAt" : override_created_at, "input" : input }
300 );
301 let query = String::from(
302 "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
303 ) + &T::selection() + " } } }";
304 client
305 .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
306 .await
307}
308pub async fn document_create<
312 T: serde::de::DeserializeOwned
313 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
314>(
315 client: &Client,
316 input: DocumentCreateInput,
317) -> Result<T, LinearError> {
318 let variables = serde_json::json!({ "input" : input });
319 let query = String::from(
320 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
321 ) + &T::selection() + " } } }";
322 client
323 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
324 .await
325}
326pub async fn document_update<
330 T: serde::de::DeserializeOwned
331 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
332>(
333 client: &Client,
334 input: DocumentUpdateInput,
335 id: String,
336) -> Result<T, LinearError> {
337 let variables = serde_json::json!({ "input" : input, "id" : id });
338 let query = String::from(
339 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
340 ) + &T::selection() + " } } }";
341 client
342 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
343 .await
344}
345pub async fn document_delete<
349 T: serde::de::DeserializeOwned
350 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
351>(
352 client: &Client,
353 id: String,
354) -> Result<T, LinearError> {
355 let variables = serde_json::json!({ "id" : id });
356 let query = String::from(
357 "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
358 ) + &T::selection()
359 + " } } }";
360 client
361 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
362 .await
363}