1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum DeleteInstagramIceBreakersError {
20 Status401(models::InlineObject),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum DeleteMessengerMenuError {
28 Status401(models::InlineObject),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteTelegramCommandsError {
36 Status401(models::InlineObject),
37 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetInstagramIceBreakersError {
44 Status400(),
45 Status401(models::InlineObject),
46 UnknownValue(serde_json::Value),
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum GetMessengerMenuError {
53 Status400(),
54 Status401(models::InlineObject),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetTelegramCommandsError {
62 Status400(),
63 Status401(models::InlineObject),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum SetInstagramIceBreakersError {
71 Status400(),
72 Status401(models::InlineObject),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum SetMessengerMenuError {
80 Status400(),
81 Status401(models::InlineObject),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum SetTelegramCommandsError {
89 Status400(),
90 Status401(models::InlineObject),
91 UnknownValue(serde_json::Value),
92}
93
94pub async fn delete_instagram_ice_breakers(
96 configuration: &configuration::Configuration,
97 account_id: &str,
98) -> Result<(), Error<DeleteInstagramIceBreakersError>> {
99 let p_path_account_id = account_id;
101
102 let uri_str = format!(
103 "{}/v1/accounts/{accountId}/instagram-ice-breakers",
104 configuration.base_path,
105 accountId = crate::apis::urlencode(p_path_account_id)
106 );
107 let mut req_builder = configuration
108 .client
109 .request(reqwest::Method::DELETE, &uri_str);
110
111 if let Some(ref user_agent) = configuration.user_agent {
112 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113 }
114 if let Some(ref token) = configuration.bearer_access_token {
115 req_builder = req_builder.bearer_auth(token.to_owned());
116 };
117
118 let req = req_builder.build()?;
119 let resp = configuration.client.execute(req).await?;
120
121 let status = resp.status();
122
123 if !status.is_client_error() && !status.is_server_error() {
124 Ok(())
125 } else {
126 let content = resp.text().await?;
127 let entity: Option<DeleteInstagramIceBreakersError> = serde_json::from_str(&content).ok();
128 Err(Error::ResponseError(ResponseContent {
129 status,
130 content,
131 entity,
132 }))
133 }
134}
135
136pub async fn delete_messenger_menu(
138 configuration: &configuration::Configuration,
139 account_id: &str,
140) -> Result<(), Error<DeleteMessengerMenuError>> {
141 let p_path_account_id = account_id;
143
144 let uri_str = format!(
145 "{}/v1/accounts/{accountId}/messenger-menu",
146 configuration.base_path,
147 accountId = crate::apis::urlencode(p_path_account_id)
148 );
149 let mut req_builder = configuration
150 .client
151 .request(reqwest::Method::DELETE, &uri_str);
152
153 if let Some(ref user_agent) = configuration.user_agent {
154 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155 }
156 if let Some(ref token) = configuration.bearer_access_token {
157 req_builder = req_builder.bearer_auth(token.to_owned());
158 };
159
160 let req = req_builder.build()?;
161 let resp = configuration.client.execute(req).await?;
162
163 let status = resp.status();
164
165 if !status.is_client_error() && !status.is_server_error() {
166 Ok(())
167 } else {
168 let content = resp.text().await?;
169 let entity: Option<DeleteMessengerMenuError> = serde_json::from_str(&content).ok();
170 Err(Error::ResponseError(ResponseContent {
171 status,
172 content,
173 entity,
174 }))
175 }
176}
177
178pub async fn delete_telegram_commands(
180 configuration: &configuration::Configuration,
181 account_id: &str,
182) -> Result<(), Error<DeleteTelegramCommandsError>> {
183 let p_path_account_id = account_id;
185
186 let uri_str = format!(
187 "{}/v1/accounts/{accountId}/telegram-commands",
188 configuration.base_path,
189 accountId = crate::apis::urlencode(p_path_account_id)
190 );
191 let mut req_builder = configuration
192 .client
193 .request(reqwest::Method::DELETE, &uri_str);
194
195 if let Some(ref user_agent) = configuration.user_agent {
196 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
197 }
198 if let Some(ref token) = configuration.bearer_access_token {
199 req_builder = req_builder.bearer_auth(token.to_owned());
200 };
201
202 let req = req_builder.build()?;
203 let resp = configuration.client.execute(req).await?;
204
205 let status = resp.status();
206
207 if !status.is_client_error() && !status.is_server_error() {
208 Ok(())
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<DeleteTelegramCommandsError> = serde_json::from_str(&content).ok();
212 Err(Error::ResponseError(ResponseContent {
213 status,
214 content,
215 entity,
216 }))
217 }
218}
219
220pub async fn get_instagram_ice_breakers(
222 configuration: &configuration::Configuration,
223 account_id: &str,
224) -> Result<models::GetMessengerMenu200Response, Error<GetInstagramIceBreakersError>> {
225 let p_path_account_id = account_id;
227
228 let uri_str = format!(
229 "{}/v1/accounts/{accountId}/instagram-ice-breakers",
230 configuration.base_path,
231 accountId = crate::apis::urlencode(p_path_account_id)
232 );
233 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
234
235 if let Some(ref user_agent) = configuration.user_agent {
236 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
237 }
238 if let Some(ref token) = configuration.bearer_access_token {
239 req_builder = req_builder.bearer_auth(token.to_owned());
240 };
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246 let content_type = resp
247 .headers()
248 .get("content-type")
249 .and_then(|v| v.to_str().ok())
250 .unwrap_or("application/octet-stream");
251 let content_type = super::ContentType::from(content_type);
252
253 if !status.is_client_error() && !status.is_server_error() {
254 let content = resp.text().await?;
255 match content_type {
256 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
257 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMessengerMenu200Response`"))),
258 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMessengerMenu200Response`")))),
259 }
260 } else {
261 let content = resp.text().await?;
262 let entity: Option<GetInstagramIceBreakersError> = serde_json::from_str(&content).ok();
263 Err(Error::ResponseError(ResponseContent {
264 status,
265 content,
266 entity,
267 }))
268 }
269}
270
271pub async fn get_messenger_menu(
273 configuration: &configuration::Configuration,
274 account_id: &str,
275) -> Result<models::GetMessengerMenu200Response, Error<GetMessengerMenuError>> {
276 let p_path_account_id = account_id;
278
279 let uri_str = format!(
280 "{}/v1/accounts/{accountId}/messenger-menu",
281 configuration.base_path,
282 accountId = crate::apis::urlencode(p_path_account_id)
283 );
284 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
285
286 if let Some(ref user_agent) = configuration.user_agent {
287 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
288 }
289 if let Some(ref token) = configuration.bearer_access_token {
290 req_builder = req_builder.bearer_auth(token.to_owned());
291 };
292
293 let req = req_builder.build()?;
294 let resp = configuration.client.execute(req).await?;
295
296 let status = resp.status();
297 let content_type = resp
298 .headers()
299 .get("content-type")
300 .and_then(|v| v.to_str().ok())
301 .unwrap_or("application/octet-stream");
302 let content_type = super::ContentType::from(content_type);
303
304 if !status.is_client_error() && !status.is_server_error() {
305 let content = resp.text().await?;
306 match content_type {
307 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
308 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMessengerMenu200Response`"))),
309 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetMessengerMenu200Response`")))),
310 }
311 } else {
312 let content = resp.text().await?;
313 let entity: Option<GetMessengerMenuError> = serde_json::from_str(&content).ok();
314 Err(Error::ResponseError(ResponseContent {
315 status,
316 content,
317 entity,
318 }))
319 }
320}
321
322pub async fn get_telegram_commands(
324 configuration: &configuration::Configuration,
325 account_id: &str,
326) -> Result<models::GetTelegramCommands200Response, Error<GetTelegramCommandsError>> {
327 let p_path_account_id = account_id;
329
330 let uri_str = format!(
331 "{}/v1/accounts/{accountId}/telegram-commands",
332 configuration.base_path,
333 accountId = crate::apis::urlencode(p_path_account_id)
334 );
335 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
336
337 if let Some(ref user_agent) = configuration.user_agent {
338 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339 }
340 if let Some(ref token) = configuration.bearer_access_token {
341 req_builder = req_builder.bearer_auth(token.to_owned());
342 };
343
344 let req = req_builder.build()?;
345 let resp = configuration.client.execute(req).await?;
346
347 let status = resp.status();
348 let content_type = resp
349 .headers()
350 .get("content-type")
351 .and_then(|v| v.to_str().ok())
352 .unwrap_or("application/octet-stream");
353 let content_type = super::ContentType::from(content_type);
354
355 if !status.is_client_error() && !status.is_server_error() {
356 let content = resp.text().await?;
357 match content_type {
358 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
359 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTelegramCommands200Response`"))),
360 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTelegramCommands200Response`")))),
361 }
362 } else {
363 let content = resp.text().await?;
364 let entity: Option<GetTelegramCommandsError> = serde_json::from_str(&content).ok();
365 Err(Error::ResponseError(ResponseContent {
366 status,
367 content,
368 entity,
369 }))
370 }
371}
372
373pub async fn set_instagram_ice_breakers(
375 configuration: &configuration::Configuration,
376 account_id: &str,
377 set_instagram_ice_breakers_request: models::SetInstagramIceBreakersRequest,
378) -> Result<(), Error<SetInstagramIceBreakersError>> {
379 let p_path_account_id = account_id;
381 let p_body_set_instagram_ice_breakers_request = set_instagram_ice_breakers_request;
382
383 let uri_str = format!(
384 "{}/v1/accounts/{accountId}/instagram-ice-breakers",
385 configuration.base_path,
386 accountId = crate::apis::urlencode(p_path_account_id)
387 );
388 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
389
390 if let Some(ref user_agent) = configuration.user_agent {
391 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
392 }
393 if let Some(ref token) = configuration.bearer_access_token {
394 req_builder = req_builder.bearer_auth(token.to_owned());
395 };
396 req_builder = req_builder.json(&p_body_set_instagram_ice_breakers_request);
397
398 let req = req_builder.build()?;
399 let resp = configuration.client.execute(req).await?;
400
401 let status = resp.status();
402
403 if !status.is_client_error() && !status.is_server_error() {
404 Ok(())
405 } else {
406 let content = resp.text().await?;
407 let entity: Option<SetInstagramIceBreakersError> = serde_json::from_str(&content).ok();
408 Err(Error::ResponseError(ResponseContent {
409 status,
410 content,
411 entity,
412 }))
413 }
414}
415
416pub async fn set_messenger_menu(
418 configuration: &configuration::Configuration,
419 account_id: &str,
420 set_messenger_menu_request: models::SetMessengerMenuRequest,
421) -> Result<(), Error<SetMessengerMenuError>> {
422 let p_path_account_id = account_id;
424 let p_body_set_messenger_menu_request = set_messenger_menu_request;
425
426 let uri_str = format!(
427 "{}/v1/accounts/{accountId}/messenger-menu",
428 configuration.base_path,
429 accountId = crate::apis::urlencode(p_path_account_id)
430 );
431 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
432
433 if let Some(ref user_agent) = configuration.user_agent {
434 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
435 }
436 if let Some(ref token) = configuration.bearer_access_token {
437 req_builder = req_builder.bearer_auth(token.to_owned());
438 };
439 req_builder = req_builder.json(&p_body_set_messenger_menu_request);
440
441 let req = req_builder.build()?;
442 let resp = configuration.client.execute(req).await?;
443
444 let status = resp.status();
445
446 if !status.is_client_error() && !status.is_server_error() {
447 Ok(())
448 } else {
449 let content = resp.text().await?;
450 let entity: Option<SetMessengerMenuError> = serde_json::from_str(&content).ok();
451 Err(Error::ResponseError(ResponseContent {
452 status,
453 content,
454 entity,
455 }))
456 }
457}
458
459pub async fn set_telegram_commands(
461 configuration: &configuration::Configuration,
462 account_id: &str,
463 set_telegram_commands_request: models::SetTelegramCommandsRequest,
464) -> Result<(), Error<SetTelegramCommandsError>> {
465 let p_path_account_id = account_id;
467 let p_body_set_telegram_commands_request = set_telegram_commands_request;
468
469 let uri_str = format!(
470 "{}/v1/accounts/{accountId}/telegram-commands",
471 configuration.base_path,
472 accountId = crate::apis::urlencode(p_path_account_id)
473 );
474 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
475
476 if let Some(ref user_agent) = configuration.user_agent {
477 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
478 }
479 if let Some(ref token) = configuration.bearer_access_token {
480 req_builder = req_builder.bearer_auth(token.to_owned());
481 };
482 req_builder = req_builder.json(&p_body_set_telegram_commands_request);
483
484 let req = req_builder.build()?;
485 let resp = configuration.client.execute(req).await?;
486
487 let status = resp.status();
488
489 if !status.is_client_error() && !status.is_server_error() {
490 Ok(())
491 } else {
492 let content = resp.text().await?;
493 let entity: Option<SetTelegramCommandsError> = serde_json::from_str(&content).ok();
494 Err(Error::ResponseError(ResponseContent {
495 status,
496 content,
497 entity,
498 }))
499 }
500}