Skip to main content

roark_rs/apis/
evaluation_api.rs

1/*
2 * Roark Analytics API
3 *
4 * # Roark Analytics API - Voice AI Analytics Platform  The Roark Analytics API provides comprehensive monitoring, evaluation, and analytics capabilities for voice AI agents. This API allows developers to seamlessly integrate with the Roark platform to track call quality, analyze agent performance, and extract insights from voice interactions.  ## Key Features  - **Real-time Call Analysis**: Upload and analyze voice call recordings with AI-powered insights - **Sentiment Analysis**: Extract emotional tone, key phrases, and sentiment scores across 64+ emotions - **Agent Performance Evaluation**: Create custom evaluation jobs with configurable metrics and scoring - **Platform Integrations**: Native support for VAPI and Retell AI with webhook-based data ingestion - **Custom Analytics**: Build custom analytics pipelines with flexible data models and properties  ## Authentication  All API endpoints require Bearer token authentication. Include your API token in the Authorization header:  ``` Authorization: Bearer YOUR_API_TOKEN ```  ## Rate Limiting  The API implements rate limiting to ensure service stability. Rate limit headers are included in responses.  ## Error Handling  The API uses standard HTTP status codes and returns structured error responses with detailed error information including error types, codes, and human-readable messages.  ## Rust Code Generation  This OpenAPI specification has been optimized for Rust code generation with: - Snake_case field naming conventions - Proper nullable field handling with Option<T> - Comprehensive documentation for generated code - Type-safe enum definitions - Structured error handling
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: support@roark.ai
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_evaluation_job`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateEvaluationJobError {
22    Status400(models::ErrorResponse),
23    Status401(models::ErrorResponse),
24    Status403(models::ErrorResponse),
25    Status429(models::ErrorResponse),
26    Status500(models::ErrorResponse),
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`get_evaluation_job`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GetEvaluationJobError {
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/// struct for typed errors of method [`get_evaluation_job_runs`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum GetEvaluationJobRunsError {
46    Status401(models::ErrorResponse),
47    Status403(models::ErrorResponse),
48    Status404(models::ErrorResponse),
49    Status429(models::ErrorResponse),
50    Status500(models::ErrorResponse),
51    UnknownValue(serde_json::Value),
52}
53
54
55/// Create an evaluation job to assess a single call or dataset of calls using specified evaluators. This allows for comprehensive analysis of agent performance and call quality.
56pub async fn create_evaluation_job(configuration: &configuration::Configuration, evaluation_job_create_request: models::EvaluationJobCreateRequest) -> Result<models::CreateEvaluationJob201Response, Error<CreateEvaluationJobError>> {
57    // add a prefix to parameters to efficiently prevent name collisions
58    let p_evaluation_job_create_request = evaluation_job_create_request;
59
60    let uri_str = format!("{}/v1/evaluation/job", configuration.base_path);
61    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
62
63    if let Some(ref user_agent) = configuration.user_agent {
64        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
65    }
66    if let Some(ref token) = configuration.bearer_access_token {
67        req_builder = req_builder.bearer_auth(token.to_owned());
68    };
69    req_builder = req_builder.json(&p_evaluation_job_create_request);
70
71    let req = req_builder.build()?;
72    let resp = configuration.client.execute(req).await?;
73
74    let status = resp.status();
75    let content_type = resp
76        .headers()
77        .get("content-type")
78        .and_then(|v| v.to_str().ok())
79        .unwrap_or("application/octet-stream");
80    let content_type = super::ContentType::from(content_type);
81
82    if !status.is_client_error() && !status.is_server_error() {
83        let content = resp.text().await?;
84        match content_type {
85            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
86            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateEvaluationJob201Response`"))),
87            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::CreateEvaluationJob201Response`")))),
88        }
89    } else {
90        let content = resp.text().await?;
91        let entity: Option<CreateEvaluationJobError> = serde_json::from_str(&content).ok();
92        Err(Error::ResponseError(ResponseContent { status, content, entity }))
93    }
94}
95
96/// Retrieve details of a specific evaluation job, including its current status and configuration.
97pub async fn get_evaluation_job(configuration: &configuration::Configuration, job_id: &str) -> Result<models::GetEvaluationJob200Response, Error<GetEvaluationJobError>> {
98    // add a prefix to parameters to efficiently prevent name collisions
99    let p_job_id = job_id;
100
101    let uri_str = format!("{}/v1/evaluation/job/{job_id}", configuration.base_path, job_id=crate::apis::urlencode(p_job_id));
102    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
103
104    if let Some(ref user_agent) = configuration.user_agent {
105        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
106    }
107    if let Some(ref token) = configuration.bearer_access_token {
108        req_builder = req_builder.bearer_auth(token.to_owned());
109    };
110
111    let req = req_builder.build()?;
112    let resp = configuration.client.execute(req).await?;
113
114    let status = resp.status();
115    let content_type = resp
116        .headers()
117        .get("content-type")
118        .and_then(|v| v.to_str().ok())
119        .unwrap_or("application/octet-stream");
120    let content_type = super::ContentType::from(content_type);
121
122    if !status.is_client_error() && !status.is_server_error() {
123        let content = resp.text().await?;
124        match content_type {
125            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
126            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEvaluationJob200Response`"))),
127            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::GetEvaluationJob200Response`")))),
128        }
129    } else {
130        let content = resp.text().await?;
131        let entity: Option<GetEvaluationJobError> = serde_json::from_str(&content).ok();
132        Err(Error::ResponseError(ResponseContent { status, content, entity }))
133    }
134}
135
136/// Retrieve paginated details of evaluation runs for a specific job, including scores, metrics, and evidence for each evaluator.
137pub async fn get_evaluation_job_runs(configuration: &configuration::Configuration, job_id: &str, next_cursor: Option<&str>, limit: Option<u8>) -> Result<models::GetEvaluationJobRuns200Response, Error<GetEvaluationJobRunsError>> {
138    // add a prefix to parameters to efficiently prevent name collisions
139    let p_job_id = job_id;
140    let p_next_cursor = next_cursor;
141    let p_limit = limit;
142
143    let uri_str = format!("{}/v1/evaluation/job/{job_id}/runs", configuration.base_path, job_id=crate::apis::urlencode(p_job_id));
144    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
145
146    if let Some(ref param_value) = p_next_cursor {
147        req_builder = req_builder.query(&[("next_cursor", &param_value.to_string())]);
148    }
149    if let Some(ref param_value) = p_limit {
150        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
151    }
152    if let Some(ref user_agent) = configuration.user_agent {
153        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
154    }
155    if let Some(ref token) = configuration.bearer_access_token {
156        req_builder = req_builder.bearer_auth(token.to_owned());
157    };
158
159    let req = req_builder.build()?;
160    let resp = configuration.client.execute(req).await?;
161
162    let status = resp.status();
163    let content_type = resp
164        .headers()
165        .get("content-type")
166        .and_then(|v| v.to_str().ok())
167        .unwrap_or("application/octet-stream");
168    let content_type = super::ContentType::from(content_type);
169
170    if !status.is_client_error() && !status.is_server_error() {
171        let content = resp.text().await?;
172        match content_type {
173            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
174            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEvaluationJobRuns200Response`"))),
175            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::GetEvaluationJobRuns200Response`")))),
176        }
177    } else {
178        let content = resp.text().await?;
179        let entity: Option<GetEvaluationJobRunsError> = serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent { status, content, entity }))
181    }
182}
183