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 project_create<
56 T: serde::de::DeserializeOwned
57 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
58>(
59 client: &Client,
60 slack_channel_name: Option<String>,
61 input: ProjectCreateInput,
62) -> Result<T, LinearError> {
63 let variables = serde_json::json!(
64 { "slackChannelName" : slack_channel_name, "input" : input }
65 );
66 let query = String::from(
67 "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
68 ) + &T::selection() + " } } }";
69 client
70 .execute_mutation::<T>(&query, variables, "projectCreate", "project")
71 .await
72}
73pub async fn project_update<
77 T: serde::de::DeserializeOwned
78 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
79>(
80 client: &Client,
81 input: ProjectUpdateInput,
82 id: String,
83) -> Result<T, LinearError> {
84 let variables = serde_json::json!({ "input" : input, "id" : id });
85 let query = String::from(
86 "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
87 ) + &T::selection() + " } } }";
88 client
89 .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
90 .await
91}
92pub async fn project_delete<
96 T: serde::de::DeserializeOwned
97 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
98>(
99 client: &Client,
100 id: String,
101) -> Result<T, LinearError> {
102 let variables = serde_json::json!({ "id" : id });
103 let query = String::from(
104 "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
105 ) + &T::selection()
106 + " } } }";
107 client
108 .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
109 .await
110}
111pub async fn project_milestone_create<
115 T: serde::de::DeserializeOwned
116 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
117>(
118 client: &Client,
119 input: ProjectMilestoneCreateInput,
120) -> Result<T, LinearError> {
121 let variables = serde_json::json!({ "input" : input });
122 let query = String::from(
123 "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
124 ) + &T::selection() + " } } }";
125 client
126 .execute_mutation::<T>(
127 &query,
128 variables,
129 "projectMilestoneCreate",
130 "projectMilestone",
131 )
132 .await
133}
134pub async fn project_milestone_update<
138 T: serde::de::DeserializeOwned
139 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
140>(
141 client: &Client,
142 input: ProjectMilestoneUpdateInput,
143 id: String,
144) -> Result<T, LinearError> {
145 let variables = serde_json::json!({ "input" : input, "id" : id });
146 let query = String::from(
147 "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
148 ) + &T::selection() + " } } }";
149 client
150 .execute_mutation::<T>(
151 &query,
152 variables,
153 "projectMilestoneUpdate",
154 "projectMilestone",
155 )
156 .await
157}
158pub async fn project_milestone_delete(
160 client: &Client,
161 id: String,
162) -> Result<serde_json::Value, LinearError> {
163 let variables = serde_json::json!({ "id" : id });
164 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
165 let query = String::from(
166 "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
167 ) + &response_parts.join(" ")
168 + " } }";
169 client
170 .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
171 .await
172}
173pub async fn issue_create<
177 T: serde::de::DeserializeOwned
178 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
179>(
180 client: &Client,
181 input: IssueCreateInput,
182) -> Result<T, LinearError> {
183 let variables = serde_json::json!({ "input" : input });
184 let query = String::from(
185 "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
186 ) + &T::selection() + " } } }";
187 client
188 .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
189 .await
190}
191pub async fn issue_update<
195 T: serde::de::DeserializeOwned
196 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
197>(
198 client: &Client,
199 input: IssueUpdateInput,
200 id: String,
201) -> Result<T, LinearError> {
202 let variables = serde_json::json!({ "input" : input, "id" : id });
203 let query = String::from(
204 "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
205 ) + &T::selection() + " } } }";
206 client
207 .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
208 .await
209}
210pub async fn issue_archive<
214 T: serde::de::DeserializeOwned
215 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
216>(
217 client: &Client,
218 trash: Option<bool>,
219 id: String,
220) -> Result<T, LinearError> {
221 let variables = serde_json::json!({ "trash" : trash, "id" : id });
222 let query = String::from(
223 "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
224 ) + &T::selection() + " } } }";
225 client
226 .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
227 .await
228}
229pub async fn issue_unarchive<
233 T: serde::de::DeserializeOwned
234 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
235>(
236 client: &Client,
237 id: String,
238) -> Result<T, LinearError> {
239 let variables = serde_json::json!({ "id" : id });
240 let query = String::from(
241 "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
242 ) + &T::selection()
243 + " } } }";
244 client
245 .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
246 .await
247}
248pub async fn issue_delete<
252 T: serde::de::DeserializeOwned
253 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
254>(
255 client: &Client,
256 permanently_delete: Option<bool>,
257 id: String,
258) -> Result<T, LinearError> {
259 let variables = serde_json::json!(
260 { "permanentlyDelete" : permanently_delete, "id" : id }
261 );
262 let query = String::from(
263 "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
264 ) + &T::selection() + " } } }";
265 client
266 .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
267 .await
268}
269pub async fn issue_relation_create<
273 T: serde::de::DeserializeOwned
274 + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
275>(
276 client: &Client,
277 override_created_at: Option<serde_json::Value>,
278 input: IssueRelationCreateInput,
279) -> Result<T, LinearError> {
280 let variables = serde_json::json!(
281 { "overrideCreatedAt" : override_created_at, "input" : input }
282 );
283 let query = String::from(
284 "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
285 ) + &T::selection() + " } } }";
286 client
287 .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
288 .await
289}
290pub async fn document_create<
294 T: serde::de::DeserializeOwned
295 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
296>(
297 client: &Client,
298 input: DocumentCreateInput,
299) -> Result<T, LinearError> {
300 let variables = serde_json::json!({ "input" : input });
301 let query = String::from(
302 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
303 ) + &T::selection() + " } } }";
304 client
305 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
306 .await
307}
308pub async fn document_update<
312 T: serde::de::DeserializeOwned
313 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
314>(
315 client: &Client,
316 input: DocumentUpdateInput,
317 id: String,
318) -> Result<T, LinearError> {
319 let variables = serde_json::json!({ "input" : input, "id" : id });
320 let query = String::from(
321 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
322 ) + &T::selection() + " } } }";
323 client
324 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
325 .await
326}
327pub async fn document_delete<
331 T: serde::de::DeserializeOwned
332 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
333>(
334 client: &Client,
335 id: String,
336) -> Result<T, LinearError> {
337 let variables = serde_json::json!({ "id" : id });
338 let query = String::from(
339 "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
340 ) + &T::selection()
341 + " } } }";
342 client
343 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
344 .await
345}
346pub async fn comment_create<
350 T: serde::de::DeserializeOwned
351 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
352>(
353 client: &Client,
354 input: CommentCreateInput,
355) -> Result<T, LinearError> {
356 let variables = serde_json::json!({ "input" : input });
357 let query = String::from(
358 "mutation CommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { ",
359 ) + &T::selection() + " } } }";
360 client
361 .execute_mutation::<T>(&query, variables, "commentCreate", "comment")
362 .await
363}