Skip to main content

linkbreakers/apis/
analytics_dashboard_api.rs

1/*
2 * Linkbreakers API
3 *
4 * This is a documentation of all the APIs of Linkbreakers
5 *
6 * The version of the OpenAPI document: 1.131.8
7 * 
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 [`analytics_dashboard_service_create_dashboard`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AnalyticsDashboardServiceCreateDashboardError {
22    DefaultResponse(models::ErrorResponse),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`analytics_dashboard_service_delete_dashboard`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AnalyticsDashboardServiceDeleteDashboardError {
30    DefaultResponse(models::ErrorResponse),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`analytics_dashboard_service_generate_widget_summary`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AnalyticsDashboardServiceGenerateWidgetSummaryError {
38    DefaultResponse(models::ErrorResponse),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`analytics_dashboard_service_get_widget_summary`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum AnalyticsDashboardServiceGetWidgetSummaryError {
46    DefaultResponse(models::ErrorResponse),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`analytics_dashboard_service_list_dashboards`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum AnalyticsDashboardServiceListDashboardsError {
54    DefaultResponse(models::ErrorResponse),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`analytics_dashboard_service_update_dashboard`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum AnalyticsDashboardServiceUpdateDashboardError {
62    DefaultResponse(models::ErrorResponse),
63    UnknownValue(serde_json::Value),
64}
65
66
67pub async fn analytics_dashboard_service_create_dashboard(configuration: &configuration::Configuration, create_dashboard_request: models::CreateDashboardRequest) -> Result<models::CreateDashboardResponse, Error<AnalyticsDashboardServiceCreateDashboardError>> {
68    // add a prefix to parameters to efficiently prevent name collisions
69    let p_body_create_dashboard_request = create_dashboard_request;
70
71    let uri_str = format!("{}/v1/analytics/dashboards", configuration.base_path);
72    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
73
74    if let Some(ref user_agent) = configuration.user_agent {
75        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
76    }
77    if let Some(ref token) = configuration.bearer_access_token {
78        req_builder = req_builder.bearer_auth(token.to_owned());
79    };
80    req_builder = req_builder.json(&p_body_create_dashboard_request);
81
82    let req = req_builder.build()?;
83    let resp = configuration.client.execute(req).await?;
84
85    let status = resp.status();
86    let content_type = resp
87        .headers()
88        .get("content-type")
89        .and_then(|v| v.to_str().ok())
90        .unwrap_or("application/octet-stream");
91    let content_type = super::ContentType::from(content_type);
92
93    if !status.is_client_error() && !status.is_server_error() {
94        let content = resp.text().await?;
95        match content_type {
96            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
97            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateDashboardResponse`"))),
98            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::CreateDashboardResponse`")))),
99        }
100    } else {
101        let content = resp.text().await?;
102        let entity: Option<AnalyticsDashboardServiceCreateDashboardError> = serde_json::from_str(&content).ok();
103        Err(Error::ResponseError(ResponseContent { status, content, entity }))
104    }
105}
106
107/// Delete a dashboard and its associated agent conversation.
108pub async fn analytics_dashboard_service_delete_dashboard(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<AnalyticsDashboardServiceDeleteDashboardError>> {
109    // add a prefix to parameters to efficiently prevent name collisions
110    let p_path_id = id;
111
112    let uri_str = format!("{}/v1/analytics/dashboards/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
113    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
114
115    if let Some(ref user_agent) = configuration.user_agent {
116        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
117    }
118    if let Some(ref token) = configuration.bearer_access_token {
119        req_builder = req_builder.bearer_auth(token.to_owned());
120    };
121
122    let req = req_builder.build()?;
123    let resp = configuration.client.execute(req).await?;
124
125    let status = resp.status();
126    let content_type = resp
127        .headers()
128        .get("content-type")
129        .and_then(|v| v.to_str().ok())
130        .unwrap_or("application/octet-stream");
131    let content_type = super::ContentType::from(content_type);
132
133    if !status.is_client_error() && !status.is_server_error() {
134        let content = resp.text().await?;
135        match content_type {
136            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
137            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
138            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
139        }
140    } else {
141        let content = resp.text().await?;
142        let entity: Option<AnalyticsDashboardServiceDeleteDashboardError> = serde_json::from_str(&content).ok();
143        Err(Error::ResponseError(ResponseContent { status, content, entity }))
144    }
145}
146
147/// Analyses the widget's current values and stores the result. Consumes platform credits, so it runs only when requested.
148pub async fn analytics_dashboard_service_generate_widget_summary(configuration: &configuration::Configuration, dashboard_id: &str, widget_id: &str, analytics_dashboard_service_generate_widget_summary_body: models::AnalyticsDashboardServiceGenerateWidgetSummaryBody) -> Result<models::GenerateWidgetSummaryResponse, Error<AnalyticsDashboardServiceGenerateWidgetSummaryError>> {
149    // add a prefix to parameters to efficiently prevent name collisions
150    let p_path_dashboard_id = dashboard_id;
151    let p_path_widget_id = widget_id;
152    let p_body_analytics_dashboard_service_generate_widget_summary_body = analytics_dashboard_service_generate_widget_summary_body;
153
154    let uri_str = format!("{}/v1/analytics/dashboards/{dashboardId}/widgets/{widgetId}/summary", configuration.base_path, dashboardId=crate::apis::urlencode(p_path_dashboard_id), widgetId=crate::apis::urlencode(p_path_widget_id));
155    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
156
157    if let Some(ref user_agent) = configuration.user_agent {
158        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
159    }
160    if let Some(ref token) = configuration.bearer_access_token {
161        req_builder = req_builder.bearer_auth(token.to_owned());
162    };
163    req_builder = req_builder.json(&p_body_analytics_dashboard_service_generate_widget_summary_body);
164
165    let req = req_builder.build()?;
166    let resp = configuration.client.execute(req).await?;
167
168    let status = resp.status();
169    let content_type = resp
170        .headers()
171        .get("content-type")
172        .and_then(|v| v.to_str().ok())
173        .unwrap_or("application/octet-stream");
174    let content_type = super::ContentType::from(content_type);
175
176    if !status.is_client_error() && !status.is_server_error() {
177        let content = resp.text().await?;
178        match content_type {
179            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
180            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GenerateWidgetSummaryResponse`"))),
181            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::GenerateWidgetSummaryResponse`")))),
182        }
183    } else {
184        let content = resp.text().await?;
185        let entity: Option<AnalyticsDashboardServiceGenerateWidgetSummaryError> = serde_json::from_str(&content).ok();
186        Err(Error::ResponseError(ResponseContent { status, content, entity }))
187    }
188}
189
190/// Returns the last generated analysis, and whether the underlying values have changed since.
191pub async fn analytics_dashboard_service_get_widget_summary(configuration: &configuration::Configuration, dashboard_id: &str, widget_id: &str) -> Result<models::GetWidgetSummaryResponse, Error<AnalyticsDashboardServiceGetWidgetSummaryError>> {
192    // add a prefix to parameters to efficiently prevent name collisions
193    let p_path_dashboard_id = dashboard_id;
194    let p_path_widget_id = widget_id;
195
196    let uri_str = format!("{}/v1/analytics/dashboards/{dashboardId}/widgets/{widgetId}/summary", configuration.base_path, dashboardId=crate::apis::urlencode(p_path_dashboard_id), widgetId=crate::apis::urlencode(p_path_widget_id));
197    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
198
199    if let Some(ref user_agent) = configuration.user_agent {
200        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201    }
202    if let Some(ref token) = configuration.bearer_access_token {
203        req_builder = req_builder.bearer_auth(token.to_owned());
204    };
205
206    let req = req_builder.build()?;
207    let resp = configuration.client.execute(req).await?;
208
209    let status = resp.status();
210    let content_type = resp
211        .headers()
212        .get("content-type")
213        .and_then(|v| v.to_str().ok())
214        .unwrap_or("application/octet-stream");
215    let content_type = super::ContentType::from(content_type);
216
217    if !status.is_client_error() && !status.is_server_error() {
218        let content = resp.text().await?;
219        match content_type {
220            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetWidgetSummaryResponse`"))),
222            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::GetWidgetSummaryResponse`")))),
223        }
224    } else {
225        let content = resp.text().await?;
226        let entity: Option<AnalyticsDashboardServiceGetWidgetSummaryError> = serde_json::from_str(&content).ok();
227        Err(Error::ResponseError(ResponseContent { status, content, entity }))
228    }
229}
230
231pub async fn analytics_dashboard_service_list_dashboards(configuration: &configuration::Configuration, link_id: Option<&str>, scope: Option<&str>, page_size: Option<i64>, page_token: Option<&str>) -> Result<models::ListDashboardsResponse, Error<AnalyticsDashboardServiceListDashboardsError>> {
232    // add a prefix to parameters to efficiently prevent name collisions
233    let p_query_link_id = link_id;
234    let p_query_scope = scope;
235    let p_query_page_size = page_size;
236    let p_query_page_token = page_token;
237
238    let uri_str = format!("{}/v1/analytics/dashboards", configuration.base_path);
239    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
240
241    if let Some(ref param_value) = p_query_link_id {
242        req_builder = req_builder.query(&[("linkId", &param_value.to_string())]);
243    }
244    if let Some(ref param_value) = p_query_scope {
245        req_builder = req_builder.query(&[("scope", &param_value.to_string())]);
246    }
247    if let Some(ref param_value) = p_query_page_size {
248        req_builder = req_builder.query(&[("pageSize", &param_value.to_string())]);
249    }
250    if let Some(ref param_value) = p_query_page_token {
251        req_builder = req_builder.query(&[("pageToken", &param_value.to_string())]);
252    }
253    if let Some(ref user_agent) = configuration.user_agent {
254        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255    }
256    if let Some(ref token) = configuration.bearer_access_token {
257        req_builder = req_builder.bearer_auth(token.to_owned());
258    };
259
260    let req = req_builder.build()?;
261    let resp = configuration.client.execute(req).await?;
262
263    let status = resp.status();
264    let content_type = resp
265        .headers()
266        .get("content-type")
267        .and_then(|v| v.to_str().ok())
268        .unwrap_or("application/octet-stream");
269    let content_type = super::ContentType::from(content_type);
270
271    if !status.is_client_error() && !status.is_server_error() {
272        let content = resp.text().await?;
273        match content_type {
274            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListDashboardsResponse`"))),
276            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::ListDashboardsResponse`")))),
277        }
278    } else {
279        let content = resp.text().await?;
280        let entity: Option<AnalyticsDashboardServiceListDashboardsError> = serde_json::from_str(&content).ok();
281        Err(Error::ResponseError(ResponseContent { status, content, entity }))
282    }
283}
284
285pub async fn analytics_dashboard_service_update_dashboard(configuration: &configuration::Configuration, id: &str, analytics_dashboard_service_update_dashboard_body: models::AnalyticsDashboardServiceUpdateDashboardBody) -> Result<models::UpdateDashboardResponse, Error<AnalyticsDashboardServiceUpdateDashboardError>> {
286    // add a prefix to parameters to efficiently prevent name collisions
287    let p_path_id = id;
288    let p_body_analytics_dashboard_service_update_dashboard_body = analytics_dashboard_service_update_dashboard_body;
289
290    let uri_str = format!("{}/v1/analytics/dashboards/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
291    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
292
293    if let Some(ref user_agent) = configuration.user_agent {
294        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295    }
296    if let Some(ref token) = configuration.bearer_access_token {
297        req_builder = req_builder.bearer_auth(token.to_owned());
298    };
299    req_builder = req_builder.json(&p_body_analytics_dashboard_service_update_dashboard_body);
300
301    let req = req_builder.build()?;
302    let resp = configuration.client.execute(req).await?;
303
304    let status = resp.status();
305    let content_type = resp
306        .headers()
307        .get("content-type")
308        .and_then(|v| v.to_str().ok())
309        .unwrap_or("application/octet-stream");
310    let content_type = super::ContentType::from(content_type);
311
312    if !status.is_client_error() && !status.is_server_error() {
313        let content = resp.text().await?;
314        match content_type {
315            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
316            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateDashboardResponse`"))),
317            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::UpdateDashboardResponse`")))),
318        }
319    } else {
320        let content = resp.text().await?;
321        let entity: Option<AnalyticsDashboardServiceUpdateDashboardError> = serde_json::from_str(&content).ok();
322        Err(Error::ResponseError(ResponseContent { status, content, entity }))
323    }
324}
325