hab_rs_api_client/apis/
voice_api.rs

1/*
2 * openHAB REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 8
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{Error, configuration};
12use crate::apis::ContentType;
13use crate::{apis::ResponseContent, models};
14use async_trait::async_trait;
15#[cfg(feature = "mockall")]
16use mockall::automock;
17use reqwest;
18use serde::{Deserialize, Serialize, de::Error as _};
19use std::sync::Arc;
20
21#[cfg_attr(feature = "mockall", automock)]
22#[async_trait]
23pub trait VoiceApi: Send + Sync {
24    /// GET /voice/defaultvoice
25    ///
26    ///
27    async fn get_default_voice(&self) -> Result<models::VoiceDto, Error<GetDefaultVoiceError>>;
28
29    /// GET /voice/interpreters/{id}
30    ///
31    ///
32    async fn get_voice_interpreter_by_uid<'id, 'accept_language>(
33        &self,
34        id: &'id str,
35        accept_language: Option<&'accept_language str>,
36    ) -> Result<Vec<models::HumanLanguageInterpreterDto>, Error<GetVoiceInterpreterByUidError>>;
37
38    /// GET /voice/interpreters
39    ///
40    ///
41    async fn get_voice_interpreters<'accept_language>(
42        &self,
43        accept_language: Option<&'accept_language str>,
44    ) -> Result<Vec<models::HumanLanguageInterpreterDto>, Error<GetVoiceInterpretersError>>;
45
46    /// GET /voice/voices
47    ///
48    ///
49    async fn get_voices(&self) -> Result<Vec<models::VoiceDto>, Error<GetVoicesError>>;
50
51    /// POST /voice/interpreters/{ids}
52    ///
53    ///
54    async fn interpret_text<'ids, 'body, 'accept_language>(
55        &self,
56        ids: Vec<String>,
57        body: &'body str,
58        accept_language: Option<&'accept_language str>,
59    ) -> Result<String, Error<InterpretTextError>>;
60
61    /// POST /voice/interpreters
62    ///
63    ///
64    async fn interpret_text_by_default_interpreter<'body, 'accept_language>(
65        &self,
66        body: &'body str,
67        accept_language: Option<&'accept_language str>,
68    ) -> Result<String, Error<InterpretTextByDefaultInterpreterError>>;
69
70    /// POST /voice/listenandanswer
71    ///
72    ///
73    async fn listen_and_answer<
74        'accept_language,
75        'source_id,
76        'stt_id,
77        'tts_id,
78        'voice_id,
79        'hli_ids,
80        'sink_id,
81        'listening_item,
82    >(
83        &self,
84        accept_language: Option<&'accept_language str>,
85        source_id: Option<&'source_id str>,
86        stt_id: Option<&'stt_id str>,
87        tts_id: Option<&'tts_id str>,
88        voice_id: Option<&'voice_id str>,
89        hli_ids: Option<Vec<String>>,
90        sink_id: Option<&'sink_id str>,
91        listening_item: Option<&'listening_item str>,
92    ) -> Result<(), Error<ListenAndAnswerError>>;
93
94    /// POST /voice/dialog/start
95    ///
96    ///
97    async fn start_dialog<
98        'accept_language,
99        'source_id,
100        'ks_id,
101        'stt_id,
102        'tts_id,
103        'voice_id,
104        'hli_ids,
105        'sink_id,
106        'keyword,
107        'listening_item,
108    >(
109        &self,
110        accept_language: Option<&'accept_language str>,
111        source_id: Option<&'source_id str>,
112        ks_id: Option<&'ks_id str>,
113        stt_id: Option<&'stt_id str>,
114        tts_id: Option<&'tts_id str>,
115        voice_id: Option<&'voice_id str>,
116        hli_ids: Option<&'hli_ids str>,
117        sink_id: Option<&'sink_id str>,
118        keyword: Option<&'keyword str>,
119        listening_item: Option<&'listening_item str>,
120    ) -> Result<(), Error<StartDialogError>>;
121
122    /// POST /voice/dialog/stop
123    ///
124    ///
125    async fn stop_dialog<'source_id>(
126        &self,
127        source_id: Option<&'source_id str>,
128    ) -> Result<(), Error<StopDialogError>>;
129
130    /// POST /voice/say
131    ///
132    ///
133    async fn text_to_speech<'body, 'voiceid, 'sinkid, 'volume>(
134        &self,
135        body: &'body str,
136        voiceid: Option<&'voiceid str>,
137        sinkid: Option<&'sinkid str>,
138        volume: Option<&'volume str>,
139    ) -> Result<(), Error<TextToSpeechError>>;
140}
141
142pub struct VoiceApiClient {
143    configuration: Arc<configuration::Configuration>,
144}
145
146impl VoiceApiClient {
147    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
148        Self { configuration }
149    }
150}
151
152#[async_trait]
153impl VoiceApi for VoiceApiClient {
154    async fn get_default_voice(&self) -> Result<models::VoiceDto, Error<GetDefaultVoiceError>> {
155        let local_var_configuration = &self.configuration;
156
157        let local_var_client = &local_var_configuration.client;
158
159        let local_var_uri_str = format!("{}/voice/defaultvoice", local_var_configuration.base_path);
160        let mut local_var_req_builder =
161            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
162
163        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
164            local_var_req_builder = local_var_req_builder
165                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
166        }
167
168        let local_var_req = local_var_req_builder.build()?;
169        let local_var_resp = local_var_client.execute(local_var_req).await?;
170
171        let local_var_status = local_var_resp.status();
172        let local_var_content_type = local_var_resp
173            .headers()
174            .get("content-type")
175            .and_then(|v| v.to_str().ok())
176            .unwrap_or("application/octet-stream");
177        let local_var_content_type = super::ContentType::from(local_var_content_type);
178        let local_var_content = local_var_resp.text().await?;
179
180        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
181            match local_var_content_type {
182                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
183                ContentType::Text => {
184                    return Err(Error::from(serde_json::Error::custom(
185                        "Received `text/plain` content type response that cannot be converted to `models::VoiceDto`",
186                    )));
187                }
188                ContentType::Unsupported(local_var_unknown_type) => {
189                    return Err(Error::from(serde_json::Error::custom(format!(
190                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::VoiceDto`"
191                    ))));
192                }
193            }
194        } else {
195            let local_var_entity: Option<GetDefaultVoiceError> =
196                serde_json::from_str(&local_var_content).ok();
197            let local_var_error = ResponseContent {
198                status: local_var_status,
199                content: local_var_content,
200                entity: local_var_entity,
201            };
202            Err(Error::ResponseError(local_var_error))
203        }
204    }
205
206    async fn get_voice_interpreter_by_uid<'id, 'accept_language>(
207        &self,
208        id: &'id str,
209        accept_language: Option<&'accept_language str>,
210    ) -> Result<Vec<models::HumanLanguageInterpreterDto>, Error<GetVoiceInterpreterByUidError>>
211    {
212        let local_var_configuration = &self.configuration;
213
214        let local_var_client = &local_var_configuration.client;
215
216        let local_var_uri_str = format!(
217            "{}/voice/interpreters/{id}",
218            local_var_configuration.base_path,
219            id = crate::apis::urlencode(id)
220        );
221        let mut local_var_req_builder =
222            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
223
224        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
225            local_var_req_builder = local_var_req_builder
226                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
227        }
228        if let Some(local_var_param_value) = accept_language {
229            local_var_req_builder =
230                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
231        }
232
233        let local_var_req = local_var_req_builder.build()?;
234        let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236        let local_var_status = local_var_resp.status();
237        let local_var_content_type = local_var_resp
238            .headers()
239            .get("content-type")
240            .and_then(|v| v.to_str().ok())
241            .unwrap_or("application/octet-stream");
242        let local_var_content_type = super::ContentType::from(local_var_content_type);
243        let local_var_content = local_var_resp.text().await?;
244
245        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
246            match local_var_content_type {
247                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
248                ContentType::Text => {
249                    return Err(Error::from(serde_json::Error::custom(
250                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::HumanLanguageInterpreterDto&gt;`",
251                    )));
252                }
253                ContentType::Unsupported(local_var_unknown_type) => {
254                    return Err(Error::from(serde_json::Error::custom(format!(
255                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::HumanLanguageInterpreterDto&gt;`"
256                    ))));
257                }
258            }
259        } else {
260            let local_var_entity: Option<GetVoiceInterpreterByUidError> =
261                serde_json::from_str(&local_var_content).ok();
262            let local_var_error = ResponseContent {
263                status: local_var_status,
264                content: local_var_content,
265                entity: local_var_entity,
266            };
267            Err(Error::ResponseError(local_var_error))
268        }
269    }
270
271    async fn get_voice_interpreters<'accept_language>(
272        &self,
273        accept_language: Option<&'accept_language str>,
274    ) -> Result<Vec<models::HumanLanguageInterpreterDto>, Error<GetVoiceInterpretersError>> {
275        let local_var_configuration = &self.configuration;
276
277        let local_var_client = &local_var_configuration.client;
278
279        let local_var_uri_str = format!("{}/voice/interpreters", local_var_configuration.base_path);
280        let mut local_var_req_builder =
281            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
282
283        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
284            local_var_req_builder = local_var_req_builder
285                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
286        }
287        if let Some(local_var_param_value) = accept_language {
288            local_var_req_builder =
289                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
290        }
291
292        let local_var_req = local_var_req_builder.build()?;
293        let local_var_resp = local_var_client.execute(local_var_req).await?;
294
295        let local_var_status = local_var_resp.status();
296        let local_var_content_type = local_var_resp
297            .headers()
298            .get("content-type")
299            .and_then(|v| v.to_str().ok())
300            .unwrap_or("application/octet-stream");
301        let local_var_content_type = super::ContentType::from(local_var_content_type);
302        let local_var_content = local_var_resp.text().await?;
303
304        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
305            match local_var_content_type {
306                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
307                ContentType::Text => {
308                    return Err(Error::from(serde_json::Error::custom(
309                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::HumanLanguageInterpreterDto&gt;`",
310                    )));
311                }
312                ContentType::Unsupported(local_var_unknown_type) => {
313                    return Err(Error::from(serde_json::Error::custom(format!(
314                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::HumanLanguageInterpreterDto&gt;`"
315                    ))));
316                }
317            }
318        } else {
319            let local_var_entity: Option<GetVoiceInterpretersError> =
320                serde_json::from_str(&local_var_content).ok();
321            let local_var_error = ResponseContent {
322                status: local_var_status,
323                content: local_var_content,
324                entity: local_var_entity,
325            };
326            Err(Error::ResponseError(local_var_error))
327        }
328    }
329
330    async fn get_voices(&self) -> Result<Vec<models::VoiceDto>, Error<GetVoicesError>> {
331        let local_var_configuration = &self.configuration;
332
333        let local_var_client = &local_var_configuration.client;
334
335        let local_var_uri_str = format!("{}/voice/voices", local_var_configuration.base_path);
336        let mut local_var_req_builder =
337            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
338
339        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
340            local_var_req_builder = local_var_req_builder
341                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
342        }
343
344        let local_var_req = local_var_req_builder.build()?;
345        let local_var_resp = local_var_client.execute(local_var_req).await?;
346
347        let local_var_status = local_var_resp.status();
348        let local_var_content_type = local_var_resp
349            .headers()
350            .get("content-type")
351            .and_then(|v| v.to_str().ok())
352            .unwrap_or("application/octet-stream");
353        let local_var_content_type = super::ContentType::from(local_var_content_type);
354        let local_var_content = local_var_resp.text().await?;
355
356        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
357            match local_var_content_type {
358                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
359                ContentType::Text => {
360                    return Err(Error::from(serde_json::Error::custom(
361                        "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::VoiceDto&gt;`",
362                    )));
363                }
364                ContentType::Unsupported(local_var_unknown_type) => {
365                    return Err(Error::from(serde_json::Error::custom(format!(
366                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec&lt;models::VoiceDto&gt;`"
367                    ))));
368                }
369            }
370        } else {
371            let local_var_entity: Option<GetVoicesError> =
372                serde_json::from_str(&local_var_content).ok();
373            let local_var_error = ResponseContent {
374                status: local_var_status,
375                content: local_var_content,
376                entity: local_var_entity,
377            };
378            Err(Error::ResponseError(local_var_error))
379        }
380    }
381
382    async fn interpret_text<'ids, 'body, 'accept_language>(
383        &self,
384        ids: Vec<String>,
385        body: &'body str,
386        accept_language: Option<&'accept_language str>,
387    ) -> Result<String, Error<InterpretTextError>> {
388        let local_var_configuration = &self.configuration;
389
390        let local_var_client = &local_var_configuration.client;
391
392        let local_var_uri_str = format!(
393            "{}/voice/interpreters/{ids}",
394            local_var_configuration.base_path,
395            ids = ids.join(",")
396        );
397        let mut local_var_req_builder =
398            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
399
400        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
401            local_var_req_builder = local_var_req_builder
402                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
403        }
404        if let Some(local_var_param_value) = accept_language {
405            local_var_req_builder =
406                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
407        }
408        local_var_req_builder = local_var_req_builder.body(body.to_string());
409        local_var_req_builder = local_var_req_builder.header(
410            reqwest::header::CONTENT_TYPE,
411            reqwest::header::HeaderValue::from_static("text/plain"),
412        );
413
414        let local_var_req = local_var_req_builder.build()?;
415        let local_var_resp = local_var_client.execute(local_var_req).await?;
416
417        let local_var_status = local_var_resp.status();
418        let local_var_content_type = local_var_resp
419            .headers()
420            .get("content-type")
421            .and_then(|v| v.to_str().ok())
422            .unwrap_or("application/octet-stream");
423        let local_var_content_type = super::ContentType::from(local_var_content_type);
424        let local_var_content = local_var_resp.text().await?;
425
426        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
427            match local_var_content_type {
428                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
429                ContentType::Text => return Ok(local_var_content),
430                ContentType::Unsupported(local_var_unknown_type) => {
431                    return Err(Error::from(serde_json::Error::custom(format!(
432                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `String`"
433                    ))));
434                }
435            }
436        } else {
437            let local_var_entity: Option<InterpretTextError> =
438                serde_json::from_str(&local_var_content).ok();
439            let local_var_error = ResponseContent {
440                status: local_var_status,
441                content: local_var_content,
442                entity: local_var_entity,
443            };
444            Err(Error::ResponseError(local_var_error))
445        }
446    }
447
448    async fn interpret_text_by_default_interpreter<'body, 'accept_language>(
449        &self,
450        body: &'body str,
451        accept_language: Option<&'accept_language str>,
452    ) -> Result<String, Error<InterpretTextByDefaultInterpreterError>> {
453        let local_var_configuration = &self.configuration;
454
455        let local_var_client = &local_var_configuration.client;
456
457        let local_var_uri_str = format!("{}/voice/interpreters", local_var_configuration.base_path);
458        let mut local_var_req_builder =
459            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
460
461        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
462            local_var_req_builder = local_var_req_builder
463                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
464        }
465        if let Some(local_var_param_value) = accept_language {
466            local_var_req_builder =
467                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
468        }
469        local_var_req_builder = local_var_req_builder.body(body.to_string());
470        local_var_req_builder = local_var_req_builder.header(
471            reqwest::header::CONTENT_TYPE,
472            reqwest::header::HeaderValue::from_static("text/plain"),
473        );
474
475        let local_var_req = local_var_req_builder.build()?;
476        let local_var_resp = local_var_client.execute(local_var_req).await?;
477
478        let local_var_status = local_var_resp.status();
479        let local_var_content_type = local_var_resp
480            .headers()
481            .get("content-type")
482            .and_then(|v| v.to_str().ok())
483            .unwrap_or("application/octet-stream");
484        let local_var_content_type = super::ContentType::from(local_var_content_type);
485        let local_var_content = local_var_resp.text().await?;
486
487        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
488            match local_var_content_type {
489                ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
490                ContentType::Text => return Ok(local_var_content),
491                ContentType::Unsupported(local_var_unknown_type) => {
492                    return Err(Error::from(serde_json::Error::custom(format!(
493                        "Received `{local_var_unknown_type}` content type response that cannot be converted to `String`"
494                    ))));
495                }
496            }
497        } else {
498            let local_var_entity: Option<InterpretTextByDefaultInterpreterError> =
499                serde_json::from_str(&local_var_content).ok();
500            let local_var_error = ResponseContent {
501                status: local_var_status,
502                content: local_var_content,
503                entity: local_var_entity,
504            };
505            Err(Error::ResponseError(local_var_error))
506        }
507    }
508
509    async fn listen_and_answer<
510        'accept_language,
511        'source_id,
512        'stt_id,
513        'tts_id,
514        'voice_id,
515        'hli_ids,
516        'sink_id,
517        'listening_item,
518    >(
519        &self,
520        accept_language: Option<&'accept_language str>,
521        source_id: Option<&'source_id str>,
522        stt_id: Option<&'stt_id str>,
523        tts_id: Option<&'tts_id str>,
524        voice_id: Option<&'voice_id str>,
525        hli_ids: Option<Vec<String>>,
526        sink_id: Option<&'sink_id str>,
527        listening_item: Option<&'listening_item str>,
528    ) -> Result<(), Error<ListenAndAnswerError>> {
529        let local_var_configuration = &self.configuration;
530
531        let local_var_client = &local_var_configuration.client;
532
533        let local_var_uri_str = format!(
534            "{}/voice/listenandanswer",
535            local_var_configuration.base_path
536        );
537        let mut local_var_req_builder =
538            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
539
540        if let Some(ref local_var_str) = source_id {
541            local_var_req_builder =
542                local_var_req_builder.query(&[("sourceId", &local_var_str.to_string())]);
543        }
544        if let Some(ref local_var_str) = stt_id {
545            local_var_req_builder =
546                local_var_req_builder.query(&[("sttId", &local_var_str.to_string())]);
547        }
548        if let Some(ref local_var_str) = tts_id {
549            local_var_req_builder =
550                local_var_req_builder.query(&[("ttsId", &local_var_str.to_string())]);
551        }
552        if let Some(ref local_var_str) = voice_id {
553            local_var_req_builder =
554                local_var_req_builder.query(&[("voiceId", &local_var_str.to_string())]);
555        }
556        if let Some(ref local_var_str) = hli_ids {
557            local_var_req_builder = match "multi" {
558                "multi" => local_var_req_builder.query(
559                    &local_var_str
560                        .into_iter()
561                        .map(|p| ("hliIds".to_owned(), p.to_string()))
562                        .collect::<Vec<(std::string::String, std::string::String)>>(),
563                ),
564                _ => local_var_req_builder.query(&[(
565                    "hliIds",
566                    &local_var_str
567                        .into_iter()
568                        .map(|p| p.to_string())
569                        .collect::<Vec<String>>()
570                        .join(",")
571                        .to_string(),
572                )]),
573            };
574        }
575        if let Some(ref local_var_str) = sink_id {
576            local_var_req_builder =
577                local_var_req_builder.query(&[("sinkId", &local_var_str.to_string())]);
578        }
579        if let Some(ref local_var_str) = listening_item {
580            local_var_req_builder =
581                local_var_req_builder.query(&[("listeningItem", &local_var_str.to_string())]);
582        }
583        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
584            local_var_req_builder = local_var_req_builder
585                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
586        }
587        if let Some(local_var_param_value) = accept_language {
588            local_var_req_builder =
589                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
590        }
591
592        let local_var_req = local_var_req_builder.build()?;
593        let local_var_resp = local_var_client.execute(local_var_req).await?;
594
595        let local_var_status = local_var_resp.status();
596        let local_var_content = local_var_resp.text().await?;
597
598        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
599            Ok(())
600        } else {
601            let local_var_entity: Option<ListenAndAnswerError> =
602                serde_json::from_str(&local_var_content).ok();
603            let local_var_error = ResponseContent {
604                status: local_var_status,
605                content: local_var_content,
606                entity: local_var_entity,
607            };
608            Err(Error::ResponseError(local_var_error))
609        }
610    }
611
612    async fn start_dialog<
613        'accept_language,
614        'source_id,
615        'ks_id,
616        'stt_id,
617        'tts_id,
618        'voice_id,
619        'hli_ids,
620        'sink_id,
621        'keyword,
622        'listening_item,
623    >(
624        &self,
625        accept_language: Option<&'accept_language str>,
626        source_id: Option<&'source_id str>,
627        ks_id: Option<&'ks_id str>,
628        stt_id: Option<&'stt_id str>,
629        tts_id: Option<&'tts_id str>,
630        voice_id: Option<&'voice_id str>,
631        hli_ids: Option<&'hli_ids str>,
632        sink_id: Option<&'sink_id str>,
633        keyword: Option<&'keyword str>,
634        listening_item: Option<&'listening_item str>,
635    ) -> Result<(), Error<StartDialogError>> {
636        let local_var_configuration = &self.configuration;
637
638        let local_var_client = &local_var_configuration.client;
639
640        let local_var_uri_str = format!("{}/voice/dialog/start", local_var_configuration.base_path);
641        let mut local_var_req_builder =
642            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
643
644        if let Some(ref local_var_str) = source_id {
645            local_var_req_builder =
646                local_var_req_builder.query(&[("sourceId", &local_var_str.to_string())]);
647        }
648        if let Some(ref local_var_str) = ks_id {
649            local_var_req_builder =
650                local_var_req_builder.query(&[("ksId", &local_var_str.to_string())]);
651        }
652        if let Some(ref local_var_str) = stt_id {
653            local_var_req_builder =
654                local_var_req_builder.query(&[("sttId", &local_var_str.to_string())]);
655        }
656        if let Some(ref local_var_str) = tts_id {
657            local_var_req_builder =
658                local_var_req_builder.query(&[("ttsId", &local_var_str.to_string())]);
659        }
660        if let Some(ref local_var_str) = voice_id {
661            local_var_req_builder =
662                local_var_req_builder.query(&[("voiceId", &local_var_str.to_string())]);
663        }
664        if let Some(ref local_var_str) = hli_ids {
665            local_var_req_builder =
666                local_var_req_builder.query(&[("hliIds", &local_var_str.to_string())]);
667        }
668        if let Some(ref local_var_str) = sink_id {
669            local_var_req_builder =
670                local_var_req_builder.query(&[("sinkId", &local_var_str.to_string())]);
671        }
672        if let Some(ref local_var_str) = keyword {
673            local_var_req_builder =
674                local_var_req_builder.query(&[("keyword", &local_var_str.to_string())]);
675        }
676        if let Some(ref local_var_str) = listening_item {
677            local_var_req_builder =
678                local_var_req_builder.query(&[("listeningItem", &local_var_str.to_string())]);
679        }
680        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
681            local_var_req_builder = local_var_req_builder
682                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
683        }
684        if let Some(local_var_param_value) = accept_language {
685            local_var_req_builder =
686                local_var_req_builder.header("Accept-Language", local_var_param_value.to_string());
687        }
688
689        let local_var_req = local_var_req_builder.build()?;
690        let local_var_resp = local_var_client.execute(local_var_req).await?;
691
692        let local_var_status = local_var_resp.status();
693        let local_var_content = local_var_resp.text().await?;
694
695        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
696            Ok(())
697        } else {
698            let local_var_entity: Option<StartDialogError> =
699                serde_json::from_str(&local_var_content).ok();
700            let local_var_error = ResponseContent {
701                status: local_var_status,
702                content: local_var_content,
703                entity: local_var_entity,
704            };
705            Err(Error::ResponseError(local_var_error))
706        }
707    }
708
709    async fn stop_dialog<'source_id>(
710        &self,
711        source_id: Option<&'source_id str>,
712    ) -> Result<(), Error<StopDialogError>> {
713        let local_var_configuration = &self.configuration;
714
715        let local_var_client = &local_var_configuration.client;
716
717        let local_var_uri_str = format!("{}/voice/dialog/stop", local_var_configuration.base_path);
718        let mut local_var_req_builder =
719            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
720
721        if let Some(ref local_var_str) = source_id {
722            local_var_req_builder =
723                local_var_req_builder.query(&[("sourceId", &local_var_str.to_string())]);
724        }
725        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
726            local_var_req_builder = local_var_req_builder
727                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
728        }
729
730        let local_var_req = local_var_req_builder.build()?;
731        let local_var_resp = local_var_client.execute(local_var_req).await?;
732
733        let local_var_status = local_var_resp.status();
734        let local_var_content = local_var_resp.text().await?;
735
736        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
737            Ok(())
738        } else {
739            let local_var_entity: Option<StopDialogError> =
740                serde_json::from_str(&local_var_content).ok();
741            let local_var_error = ResponseContent {
742                status: local_var_status,
743                content: local_var_content,
744                entity: local_var_entity,
745            };
746            Err(Error::ResponseError(local_var_error))
747        }
748    }
749
750    async fn text_to_speech<'body, 'voiceid, 'sinkid, 'volume>(
751        &self,
752        body: &'body str,
753        voiceid: Option<&'voiceid str>,
754        sinkid: Option<&'sinkid str>,
755        volume: Option<&'volume str>,
756    ) -> Result<(), Error<TextToSpeechError>> {
757        let local_var_configuration = &self.configuration;
758
759        let local_var_client = &local_var_configuration.client;
760
761        let local_var_uri_str = format!("{}/voice/say", local_var_configuration.base_path);
762        let mut local_var_req_builder =
763            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
764
765        if let Some(ref local_var_str) = voiceid {
766            local_var_req_builder =
767                local_var_req_builder.query(&[("voiceid", &local_var_str.to_string())]);
768        }
769        if let Some(ref local_var_str) = sinkid {
770            local_var_req_builder =
771                local_var_req_builder.query(&[("sinkid", &local_var_str.to_string())]);
772        }
773        if let Some(ref local_var_str) = volume {
774            local_var_req_builder =
775                local_var_req_builder.query(&[("volume", &local_var_str.to_string())]);
776        }
777        if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
778            local_var_req_builder = local_var_req_builder
779                .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
780        }
781        local_var_req_builder = local_var_req_builder.body(body.to_string());
782        local_var_req_builder = local_var_req_builder.header(
783            reqwest::header::CONTENT_TYPE,
784            reqwest::header::HeaderValue::from_static("text/plain"),
785        );
786
787        let local_var_req = local_var_req_builder.build()?;
788        let local_var_resp = local_var_client.execute(local_var_req).await?;
789
790        let local_var_status = local_var_resp.status();
791        let local_var_content = local_var_resp.text().await?;
792
793        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
794            Ok(())
795        } else {
796            let local_var_entity: Option<TextToSpeechError> =
797                serde_json::from_str(&local_var_content).ok();
798            let local_var_error = ResponseContent {
799                status: local_var_status,
800                content: local_var_content,
801                entity: local_var_entity,
802            };
803            Err(Error::ResponseError(local_var_error))
804        }
805    }
806}
807
808/// struct for typed errors of method [VoiceApi::get_default_voice]
809#[derive(Debug, Clone, Serialize, Deserialize)]
810#[serde(untagged)]
811pub enum GetDefaultVoiceError {
812    Status404(),
813    UnknownValue(serde_json::Value),
814}
815
816/// struct for typed errors of method [VoiceApi::get_voice_interpreter_by_uid]
817#[derive(Debug, Clone, Serialize, Deserialize)]
818#[serde(untagged)]
819pub enum GetVoiceInterpreterByUidError {
820    Status404(),
821    UnknownValue(serde_json::Value),
822}
823
824/// struct for typed errors of method [VoiceApi::get_voice_interpreters]
825#[derive(Debug, Clone, Serialize, Deserialize)]
826#[serde(untagged)]
827pub enum GetVoiceInterpretersError {
828    UnknownValue(serde_json::Value),
829}
830
831/// struct for typed errors of method [VoiceApi::get_voices]
832#[derive(Debug, Clone, Serialize, Deserialize)]
833#[serde(untagged)]
834pub enum GetVoicesError {
835    UnknownValue(serde_json::Value),
836}
837
838/// struct for typed errors of method [VoiceApi::interpret_text]
839#[derive(Debug, Clone, Serialize, Deserialize)]
840#[serde(untagged)]
841pub enum InterpretTextError {
842    Status400(),
843    Status404(),
844    UnknownValue(serde_json::Value),
845}
846
847/// struct for typed errors of method [VoiceApi::interpret_text_by_default_interpreter]
848#[derive(Debug, Clone, Serialize, Deserialize)]
849#[serde(untagged)]
850pub enum InterpretTextByDefaultInterpreterError {
851    Status400(),
852    Status404(),
853    UnknownValue(serde_json::Value),
854}
855
856/// struct for typed errors of method [VoiceApi::listen_and_answer]
857#[derive(Debug, Clone, Serialize, Deserialize)]
858#[serde(untagged)]
859pub enum ListenAndAnswerError {
860    Status400(),
861    Status404(),
862    UnknownValue(serde_json::Value),
863}
864
865/// struct for typed errors of method [VoiceApi::start_dialog]
866#[derive(Debug, Clone, Serialize, Deserialize)]
867#[serde(untagged)]
868pub enum StartDialogError {
869    Status400(),
870    Status404(),
871    UnknownValue(serde_json::Value),
872}
873
874/// struct for typed errors of method [VoiceApi::stop_dialog]
875#[derive(Debug, Clone, Serialize, Deserialize)]
876#[serde(untagged)]
877pub enum StopDialogError {
878    Status400(),
879    Status404(),
880    UnknownValue(serde_json::Value),
881}
882
883/// struct for typed errors of method [VoiceApi::text_to_speech]
884#[derive(Debug, Clone, Serialize, Deserialize)]
885#[serde(untagged)]
886pub enum TextToSpeechError {
887    UnknownValue(serde_json::Value),
888}