1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17#[derive(Clone, Debug, Default)]
19pub struct AddScreenTabFieldParams {
20 pub screen_id: i64,
22 pub tab_id: i64,
24 pub add_field_bean: crate::models::AddFieldBean
25}
26
27#[derive(Clone, Debug, Default)]
29pub struct GetAllScreenTabFieldsParams {
30 pub screen_id: i64,
32 pub tab_id: i64,
34 pub project_key: Option<String>
36}
37
38#[derive(Clone, Debug, Default)]
40pub struct MoveScreenTabFieldParams {
41 pub screen_id: i64,
43 pub tab_id: i64,
45 pub id: String,
47 pub move_field_bean: crate::models::MoveFieldBean
48}
49
50#[derive(Clone, Debug, Default)]
52pub struct RemoveScreenTabFieldParams {
53 pub screen_id: i64,
55 pub tab_id: i64,
57 pub id: String
59}
60
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum AddScreenTabFieldError {
66 Status400(),
67 Status401(),
68 Status403(),
69 Status404(),
70 UnknownValue(serde_json::Value),
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(untagged)]
76pub enum GetAllScreenTabFieldsError {
77 Status401(),
78 Status403(),
79 Status404(),
80 UnknownValue(serde_json::Value),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum MoveScreenTabFieldError {
87 Status400(),
88 Status401(),
89 Status403(),
90 Status404(),
91 UnknownValue(serde_json::Value),
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum RemoveScreenTabFieldError {
98 Status400(),
99 Status401(),
100 Status403(),
101 Status404(),
102 UnknownValue(serde_json::Value),
103}
104
105
106pub async fn add_screen_tab_field(configuration: &configuration::Configuration, params: AddScreenTabFieldParams) -> Result<crate::models::ScreenableField, Error<AddScreenTabFieldError>> {
108 let local_var_configuration = configuration;
109
110 let screen_id = params.screen_id;
112 let tab_id = params.tab_id;
113 let add_field_bean = params.add_field_bean;
114
115
116 let local_var_client = &local_var_configuration.client;
117
118 let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id);
119 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123 }
124 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
125 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
126 };
127 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
128 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
129 };
130 local_var_req_builder = local_var_req_builder.json(&add_field_bean);
131
132 let local_var_req = local_var_req_builder.build()?;
133 let local_var_resp = local_var_client.execute(local_var_req).await?;
134
135 let local_var_status = local_var_resp.status();
136 let local_var_content = local_var_resp.text().await?;
137
138 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
139 serde_json::from_str(&local_var_content).map_err(Error::from)
140 } else {
141 let local_var_entity: Option<AddScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
142 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
143 Err(Error::ResponseError(local_var_error))
144 }
145}
146
147pub async fn get_all_screen_tab_fields(configuration: &configuration::Configuration, params: GetAllScreenTabFieldsParams) -> Result<Vec<crate::models::ScreenableField>, Error<GetAllScreenTabFieldsError>> {
149 let local_var_configuration = configuration;
150
151 let screen_id = params.screen_id;
153 let tab_id = params.tab_id;
154 let project_key = params.project_key;
155
156
157 let local_var_client = &local_var_configuration.client;
158
159 let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id);
160 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
161
162 if let Some(ref local_var_str) = project_key {
163 local_var_req_builder = local_var_req_builder.query(&[("projectKey", &local_var_str.to_string())]);
164 }
165 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
166 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
167 }
168 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
169 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
170 };
171 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
172 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
173 };
174
175 let local_var_req = local_var_req_builder.build()?;
176 let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178 let local_var_status = local_var_resp.status();
179 let local_var_content = local_var_resp.text().await?;
180
181 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182 serde_json::from_str(&local_var_content).map_err(Error::from)
183 } else {
184 let local_var_entity: Option<GetAllScreenTabFieldsError> = serde_json::from_str(&local_var_content).ok();
185 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186 Err(Error::ResponseError(local_var_error))
187 }
188}
189
190pub async fn move_screen_tab_field(configuration: &configuration::Configuration, params: MoveScreenTabFieldParams) -> Result<serde_json::Value, Error<MoveScreenTabFieldError>> {
192 let local_var_configuration = configuration;
193
194 let screen_id = params.screen_id;
196 let tab_id = params.tab_id;
197 let id = params.id;
198 let move_field_bean = params.move_field_bean;
199
200
201 let local_var_client = &local_var_configuration.client;
202
203 let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}/move", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id, id=crate::apis::urlencode(id));
204 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
205
206 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
207 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
208 }
209 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
210 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
211 };
212 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
213 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
214 };
215 local_var_req_builder = local_var_req_builder.json(&move_field_bean);
216
217 let local_var_req = local_var_req_builder.build()?;
218 let local_var_resp = local_var_client.execute(local_var_req).await?;
219
220 let local_var_status = local_var_resp.status();
221 let local_var_content = local_var_resp.text().await?;
222
223 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
224 serde_json::from_str(&local_var_content).map_err(Error::from)
225 } else {
226 let local_var_entity: Option<MoveScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
227 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
228 Err(Error::ResponseError(local_var_error))
229 }
230}
231
232pub async fn remove_screen_tab_field(configuration: &configuration::Configuration, params: RemoveScreenTabFieldParams) -> Result<(), Error<RemoveScreenTabFieldError>> {
234 let local_var_configuration = configuration;
235
236 let screen_id = params.screen_id;
238 let tab_id = params.tab_id;
239 let id = params.id;
240
241
242 let local_var_client = &local_var_configuration.client;
243
244 let local_var_uri_str = format!("{}/rest/api/2/screens/{screenId}/tabs/{tabId}/fields/{id}", local_var_configuration.base_path, screenId=screen_id, tabId=tab_id, id=crate::apis::urlencode(id));
245 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
246
247 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
248 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
249 }
250 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
251 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
252 };
253 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
254 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
255 };
256
257 let local_var_req = local_var_req_builder.build()?;
258 let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260 let local_var_status = local_var_resp.status();
261 let local_var_content = local_var_resp.text().await?;
262
263 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264 Ok(())
265 } else {
266 let local_var_entity: Option<RemoveScreenTabFieldError> = serde_json::from_str(&local_var_content).ok();
267 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
268 Err(Error::ResponseError(local_var_error))
269 }
270}
271