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 issue_create<
56 T: serde::de::DeserializeOwned
57 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
58>(
59 client: &Client,
60 input: IssueCreateInput,
61) -> Result<T, LinearError> {
62 let variables = serde_json::json!({ "input" : input });
63 let query = String::from(
64 "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
65 ) + &T::selection() + " } } }";
66 client
67 .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
68 .await
69}
70pub async fn issue_update<
74 T: serde::de::DeserializeOwned
75 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
76>(
77 client: &Client,
78 input: IssueUpdateInput,
79 id: String,
80) -> Result<T, LinearError> {
81 let variables = serde_json::json!({ "input" : input, "id" : id });
82 let query = String::from(
83 "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
84 ) + &T::selection() + " } } }";
85 client
86 .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
87 .await
88}
89pub async fn issue_archive<
93 T: serde::de::DeserializeOwned
94 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
95>(
96 client: &Client,
97 trash: Option<bool>,
98 id: String,
99) -> Result<T, LinearError> {
100 let variables = serde_json::json!({ "trash" : trash, "id" : id });
101 let query = String::from(
102 "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
103 ) + &T::selection() + " } } }";
104 client
105 .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
106 .await
107}
108pub async fn issue_unarchive<
112 T: serde::de::DeserializeOwned
113 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
114>(
115 client: &Client,
116 id: String,
117) -> Result<T, LinearError> {
118 let variables = serde_json::json!({ "id" : id });
119 let query = String::from(
120 "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
121 ) + &T::selection()
122 + " } } }";
123 client
124 .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
125 .await
126}
127pub async fn issue_delete<
131 T: serde::de::DeserializeOwned
132 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
133>(
134 client: &Client,
135 permanently_delete: Option<bool>,
136 id: String,
137) -> Result<T, LinearError> {
138 let variables = serde_json::json!(
139 { "permanentlyDelete" : permanently_delete, "id" : id }
140 );
141 let query = String::from(
142 "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
143 ) + &T::selection() + " } } }";
144 client
145 .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
146 .await
147}
148pub async fn issue_relation_create<
152 T: serde::de::DeserializeOwned
153 + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
154>(
155 client: &Client,
156 override_created_at: Option<serde_json::Value>,
157 input: IssueRelationCreateInput,
158) -> Result<T, LinearError> {
159 let variables = serde_json::json!(
160 { "overrideCreatedAt" : override_created_at, "input" : input }
161 );
162 let query = String::from(
163 "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
164 ) + &T::selection() + " } } }";
165 client
166 .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
167 .await
168}
169pub async fn document_create<
173 T: serde::de::DeserializeOwned
174 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
175>(
176 client: &Client,
177 input: DocumentCreateInput,
178) -> Result<T, LinearError> {
179 let variables = serde_json::json!({ "input" : input });
180 let query = String::from(
181 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
182 ) + &T::selection() + " } } }";
183 client
184 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
185 .await
186}
187pub async fn document_update<
191 T: serde::de::DeserializeOwned
192 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
193>(
194 client: &Client,
195 input: DocumentUpdateInput,
196 id: String,
197) -> Result<T, LinearError> {
198 let variables = serde_json::json!({ "input" : input, "id" : id });
199 let query = String::from(
200 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
201 ) + &T::selection() + " } } }";
202 client
203 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
204 .await
205}
206pub async fn document_delete<
210 T: serde::de::DeserializeOwned
211 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
212>(
213 client: &Client,
214 id: String,
215) -> Result<T, LinearError> {
216 let variables = serde_json::json!({ "id" : id });
217 let query = String::from(
218 "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
219 ) + &T::selection()
220 + " } } }";
221 client
222 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
223 .await
224}
225pub async fn comment_create<
229 T: serde::de::DeserializeOwned
230 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
231>(
232 client: &Client,
233 input: CommentCreateInput,
234) -> Result<T, LinearError> {
235 let variables = serde_json::json!({ "input" : input });
236 let query = String::from(
237 "mutation CommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { ",
238 ) + &T::selection() + " } } }";
239 client
240 .execute_mutation::<T>(&query, variables, "commentCreate", "comment")
241 .await
242}