roark_rs/apis/
call_operations_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetCallEvaluationRunsError {
22 Status401(models::ErrorResponse),
23 Status403(models::ErrorResponse),
24 Status404(models::ErrorResponse),
25 Status429(models::ErrorResponse),
26 Status500(models::ErrorResponse),
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GetCallSentimentAnalysisError {
34 Status401(models::ErrorResponse),
35 Status403(models::ErrorResponse),
36 Status404(models::ErrorResponse),
37 Status429(models::ErrorResponse),
38 Status500(models::ErrorResponse),
39 UnknownValue(serde_json::Value),
40}
41
42
43pub async fn get_call_evaluation_runs(configuration: &configuration::Configuration, call_id: &str) -> Result<models::GetCallEvaluationRuns200Response, Error<GetCallEvaluationRunsError>> {
45 let p_call_id = call_id;
47
48 let uri_str = format!("{}/v1/call/{call_id}/evaluation-run", configuration.base_path, call_id=crate::apis::urlencode(p_call_id));
49 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
50
51 if let Some(ref user_agent) = configuration.user_agent {
52 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
53 }
54 if let Some(ref token) = configuration.bearer_access_token {
55 req_builder = req_builder.bearer_auth(token.to_owned());
56 };
57
58 let req = req_builder.build()?;
59 let resp = configuration.client.execute(req).await?;
60
61 let status = resp.status();
62 let content_type = resp
63 .headers()
64 .get("content-type")
65 .and_then(|v| v.to_str().ok())
66 .unwrap_or("application/octet-stream");
67 let content_type = super::ContentType::from(content_type);
68
69 if !status.is_client_error() && !status.is_server_error() {
70 let content = resp.text().await?;
71 match content_type {
72 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
73 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCallEvaluationRuns200Response`"))),
74 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::GetCallEvaluationRuns200Response`")))),
75 }
76 } else {
77 let content = resp.text().await?;
78 let entity: Option<GetCallEvaluationRunsError> = serde_json::from_str(&content).ok();
79 Err(Error::ResponseError(ResponseContent { status, content, entity }))
80 }
81}
82
83pub async fn get_call_sentiment_analysis(configuration: &configuration::Configuration, call_id: &str) -> Result<models::GetCallSentimentAnalysis200Response, Error<GetCallSentimentAnalysisError>> {
85 let p_call_id = call_id;
87
88 let uri_str = format!("{}/v1/call/{call_id}/sentiment-run", configuration.base_path, call_id=crate::apis::urlencode(p_call_id));
89 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
90
91 if let Some(ref user_agent) = configuration.user_agent {
92 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
93 }
94 if let Some(ref token) = configuration.bearer_access_token {
95 req_builder = req_builder.bearer_auth(token.to_owned());
96 };
97
98 let req = req_builder.build()?;
99 let resp = configuration.client.execute(req).await?;
100
101 let status = resp.status();
102 let content_type = resp
103 .headers()
104 .get("content-type")
105 .and_then(|v| v.to_str().ok())
106 .unwrap_or("application/octet-stream");
107 let content_type = super::ContentType::from(content_type);
108
109 if !status.is_client_error() && !status.is_server_error() {
110 let content = resp.text().await?;
111 match content_type {
112 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
113 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCallSentimentAnalysis200Response`"))),
114 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::GetCallSentimentAnalysis200Response`")))),
115 }
116 } else {
117 let content = resp.text().await?;
118 let entity: Option<GetCallSentimentAnalysisError> = serde_json::from_str(&content).ok();
119 Err(Error::ResponseError(ResponseContent { status, content, entity }))
120 }
121}
122