vapi_client/apis/
logs_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 LoggingControllerLogsDeleteQueryError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum LoggingControllerLogsQueryError {
29 UnknownValue(serde_json::Value),
30}
31
32
33pub async fn logging_controller_logs_delete_query(configuration: &configuration::Configuration, r#type: Option<&str>, assistant_id: Option<&str>, phone_number_id: Option<&str>, customer_id: Option<&str>, squad_id: Option<&str>, call_id: Option<&str>) -> Result<(), Error<LoggingControllerLogsDeleteQueryError>> {
34 let p_type = r#type;
36 let p_assistant_id = assistant_id;
37 let p_phone_number_id = phone_number_id;
38 let p_customer_id = customer_id;
39 let p_squad_id = squad_id;
40 let p_call_id = call_id;
41
42 let uri_str = format!("{}/logs", configuration.base_path);
43 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
44
45 if let Some(ref param_value) = p_type {
46 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
47 }
48 if let Some(ref param_value) = p_assistant_id {
49 req_builder = req_builder.query(&[("assistantId", ¶m_value.to_string())]);
50 }
51 if let Some(ref param_value) = p_phone_number_id {
52 req_builder = req_builder.query(&[("phoneNumberId", ¶m_value.to_string())]);
53 }
54 if let Some(ref param_value) = p_customer_id {
55 req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
56 }
57 if let Some(ref param_value) = p_squad_id {
58 req_builder = req_builder.query(&[("squadId", ¶m_value.to_string())]);
59 }
60 if let Some(ref param_value) = p_call_id {
61 req_builder = req_builder.query(&[("callId", ¶m_value.to_string())]);
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
70 let req = req_builder.build()?;
71 let resp = configuration.client.execute(req).await?;
72
73 let status = resp.status();
74
75 if !status.is_client_error() && !status.is_server_error() {
76 Ok(())
77 } else {
78 let content = resp.text().await?;
79 let entity: Option<LoggingControllerLogsDeleteQueryError> = serde_json::from_str(&content).ok();
80 Err(Error::ResponseError(ResponseContent { status, content, entity }))
81 }
82}
83
84pub async fn logging_controller_logs_query(configuration: &configuration::Configuration, r#type: Option<&str>, webhook_type: Option<&str>, assistant_id: Option<&str>, phone_number_id: Option<&str>, customer_id: Option<&str>, squad_id: Option<&str>, call_id: Option<&str>, page: Option<f64>, sort_order: Option<&str>, limit: Option<f64>, created_at_gt: Option<String>, created_at_lt: Option<String>, created_at_ge: Option<String>, created_at_le: Option<String>, updated_at_gt: Option<String>, updated_at_lt: Option<String>, updated_at_ge: Option<String>, updated_at_le: Option<String>) -> Result<models::LogsPaginatedResponse, Error<LoggingControllerLogsQueryError>> {
85 let p_type = r#type;
87 let p_webhook_type = webhook_type;
88 let p_assistant_id = assistant_id;
89 let p_phone_number_id = phone_number_id;
90 let p_customer_id = customer_id;
91 let p_squad_id = squad_id;
92 let p_call_id = call_id;
93 let p_page = page;
94 let p_sort_order = sort_order;
95 let p_limit = limit;
96 let p_created_at_gt = created_at_gt;
97 let p_created_at_lt = created_at_lt;
98 let p_created_at_ge = created_at_ge;
99 let p_created_at_le = created_at_le;
100 let p_updated_at_gt = updated_at_gt;
101 let p_updated_at_lt = updated_at_lt;
102 let p_updated_at_ge = updated_at_ge;
103 let p_updated_at_le = updated_at_le;
104
105 let uri_str = format!("{}/logs", configuration.base_path);
106 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
107
108 if let Some(ref param_value) = p_type {
109 req_builder = req_builder.query(&[("type", ¶m_value.to_string())]);
110 }
111 if let Some(ref param_value) = p_webhook_type {
112 req_builder = req_builder.query(&[("webhookType", ¶m_value.to_string())]);
113 }
114 if let Some(ref param_value) = p_assistant_id {
115 req_builder = req_builder.query(&[("assistantId", ¶m_value.to_string())]);
116 }
117 if let Some(ref param_value) = p_phone_number_id {
118 req_builder = req_builder.query(&[("phoneNumberId", ¶m_value.to_string())]);
119 }
120 if let Some(ref param_value) = p_customer_id {
121 req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
122 }
123 if let Some(ref param_value) = p_squad_id {
124 req_builder = req_builder.query(&[("squadId", ¶m_value.to_string())]);
125 }
126 if let Some(ref param_value) = p_call_id {
127 req_builder = req_builder.query(&[("callId", ¶m_value.to_string())]);
128 }
129 if let Some(ref param_value) = p_page {
130 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
131 }
132 if let Some(ref param_value) = p_sort_order {
133 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
134 }
135 if let Some(ref param_value) = p_limit {
136 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
137 }
138 if let Some(ref param_value) = p_created_at_gt {
139 req_builder = req_builder.query(&[("createdAtGt", ¶m_value.to_string())]);
140 }
141 if let Some(ref param_value) = p_created_at_lt {
142 req_builder = req_builder.query(&[("createdAtLt", ¶m_value.to_string())]);
143 }
144 if let Some(ref param_value) = p_created_at_ge {
145 req_builder = req_builder.query(&[("createdAtGe", ¶m_value.to_string())]);
146 }
147 if let Some(ref param_value) = p_created_at_le {
148 req_builder = req_builder.query(&[("createdAtLe", ¶m_value.to_string())]);
149 }
150 if let Some(ref param_value) = p_updated_at_gt {
151 req_builder = req_builder.query(&[("updatedAtGt", ¶m_value.to_string())]);
152 }
153 if let Some(ref param_value) = p_updated_at_lt {
154 req_builder = req_builder.query(&[("updatedAtLt", ¶m_value.to_string())]);
155 }
156 if let Some(ref param_value) = p_updated_at_ge {
157 req_builder = req_builder.query(&[("updatedAtGe", ¶m_value.to_string())]);
158 }
159 if let Some(ref param_value) = p_updated_at_le {
160 req_builder = req_builder.query(&[("updatedAtLe", ¶m_value.to_string())]);
161 }
162 if let Some(ref user_agent) = configuration.user_agent {
163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164 }
165 if let Some(ref token) = configuration.bearer_access_token {
166 req_builder = req_builder.bearer_auth(token.to_owned());
167 };
168
169 let req = req_builder.build()?;
170 let resp = configuration.client.execute(req).await?;
171
172 let status = resp.status();
173 let content_type = resp
174 .headers()
175 .get("content-type")
176 .and_then(|v| v.to_str().ok())
177 .unwrap_or("application/octet-stream");
178 let content_type = super::ContentType::from(content_type);
179
180 if !status.is_client_error() && !status.is_server_error() {
181 let content = resp.text().await?;
182 match content_type {
183 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
184 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LogsPaginatedResponse`"))),
185 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::LogsPaginatedResponse`")))),
186 }
187 } else {
188 let content = resp.text().await?;
189 let entity: Option<LoggingControllerLogsQueryError> = serde_json::from_str(&content).ok();
190 Err(Error::ResponseError(ResponseContent { status, content, entity }))
191 }
192}
193