1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17#[derive(Clone, Debug)]
19pub struct AddCallParams {
20 pub new_call_adding_request: models::NewCallAddingRequest
21}
22
23#[derive(Clone, Debug)]
25pub struct GetCallParams {
26 pub id: String
28}
29
30#[derive(Clone, Debug)]
32pub struct GetCallTranscriptsParams {
33 pub public_api_base_request_v2_calls_filter: models::PublicApiBaseRequestV2CallsFilter
34}
35
36#[derive(Clone, Debug)]
38pub struct ListCallsParams {
39 pub from_date_time: String,
41 pub to_date_time: String,
43 pub cursor: Option<String>,
45 pub workspace_id: Option<String>
47}
48
49#[derive(Clone, Debug)]
51pub struct ListCallsExtensiveParams {
52 pub public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector: models::PublicApiBaseRequestWithDataV2CallsRequestFilterWithOwnersContentSelector
53}
54
55#[derive(Clone, Debug)]
57pub struct ListCrmCallsManualAssociationParams {
58 pub from_date_time: Option<String>,
60 pub cursor: Option<String>
62}
63
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum AddCallError {
69 Status400(models::ErrorResponse),
70 Status401(models::ErrorResponse),
71 Status409(models::ErrorResponse),
72 Status429(models::ErrorResponse),
73 Status500(models::ErrorResponse),
74 UnknownValue(serde_json::Value),
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetCallError {
81 Status400(models::ErrorResponse),
82 Status401(models::ErrorResponse),
83 Status404(models::ErrorResponse),
84 Status429(models::ErrorResponse),
85 Status500(models::ErrorResponse),
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetCallTranscriptsError {
93 Status400(models::ErrorResponse),
94 Status401(models::ErrorResponse),
95 Status404(models::ErrorResponse),
96 Status429(models::ErrorResponse),
97 Status500(models::ErrorResponse),
98 UnknownValue(serde_json::Value),
99}
100
101#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum ListCallsError {
105 Status400(models::ErrorResponse),
106 Status401(models::ErrorResponse),
107 Status404(models::ErrorResponse),
108 Status429(models::ErrorResponse),
109 Status500(models::ErrorResponse),
110 UnknownValue(serde_json::Value),
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum ListCallsExtensiveError {
117 Status400(models::ErrorResponse),
118 Status401(models::ErrorResponse),
119 Status404(models::ErrorResponse),
120 Status429(models::ErrorResponse),
121 Status500(models::ErrorResponse),
122 UnknownValue(serde_json::Value),
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum ListCrmCallsManualAssociationError {
129 Status400(models::ErrorResponse),
130 Status401(models::ErrorResponse),
131 Status500(models::ErrorResponse),
132 UnknownValue(serde_json::Value),
133}
134
135
136pub async fn add_call(configuration: &configuration::Configuration, params: AddCallParams) -> Result<models::NewCallAddingResponse, Error<AddCallError>> {
138 let local_var_configuration = configuration;
139
140 let new_call_adding_request = params.new_call_adding_request;
142
143
144 let local_var_client = &local_var_configuration.client;
145
146 let local_var_uri_str = format!("{}/v2/calls", local_var_configuration.base_path);
147 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
148
149 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
150 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
151 }
152 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
153 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
154 };
155 local_var_req_builder = local_var_req_builder.json(&new_call_adding_request);
156
157 let local_var_req = local_var_req_builder.build()?;
158 let local_var_resp = local_var_client.execute(local_var_req).await?;
159
160 let local_var_status = local_var_resp.status();
161 let local_var_content = local_var_resp.text().await?;
162
163 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
164 serde_json::from_str(&local_var_content).map_err(Error::from)
165 } else {
166 let local_var_entity: Option<AddCallError> = serde_json::from_str(&local_var_content).ok();
167 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
168 Err(Error::ResponseError(local_var_error))
169 }
170}
171
172pub async fn get_call(configuration: &configuration::Configuration, params: GetCallParams) -> Result<models::SpecificCall, Error<GetCallError>> {
174 let local_var_configuration = configuration;
175
176 let id = params.id;
178
179
180 let local_var_client = &local_var_configuration.client;
181
182 let local_var_uri_str = format!("{}/v2/calls/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
183 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
184
185 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
186 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
187 }
188 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
189 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
190 };
191
192 let local_var_req = local_var_req_builder.build()?;
193 let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195 let local_var_status = local_var_resp.status();
196 let local_var_content = local_var_resp.text().await?;
197
198 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199 serde_json::from_str(&local_var_content).map_err(Error::from)
200 } else {
201 let local_var_entity: Option<GetCallError> = serde_json::from_str(&local_var_content).ok();
202 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203 Err(Error::ResponseError(local_var_error))
204 }
205}
206
207pub async fn get_call_transcripts(configuration: &configuration::Configuration, params: GetCallTranscriptsParams) -> Result<models::CallTranscripts, Error<GetCallTranscriptsError>> {
209 let local_var_configuration = configuration;
210
211 let public_api_base_request_v2_calls_filter = params.public_api_base_request_v2_calls_filter;
213
214
215 let local_var_client = &local_var_configuration.client;
216
217 let local_var_uri_str = format!("{}/v2/calls/transcript", local_var_configuration.base_path);
218 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
219
220 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
221 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
222 }
223 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
224 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
225 };
226 local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_calls_filter);
227
228 let local_var_req = local_var_req_builder.build()?;
229 let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231 let local_var_status = local_var_resp.status();
232 let local_var_content = local_var_resp.text().await?;
233
234 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235 serde_json::from_str(&local_var_content).map_err(Error::from)
236 } else {
237 let local_var_entity: Option<GetCallTranscriptsError> = serde_json::from_str(&local_var_content).ok();
238 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239 Err(Error::ResponseError(local_var_error))
240 }
241}
242
243pub async fn list_calls(configuration: &configuration::Configuration, params: ListCallsParams) -> Result<models::CallsResponse, Error<ListCallsError>> {
245 let local_var_configuration = configuration;
246
247 let from_date_time = params.from_date_time;
249 let to_date_time = params.to_date_time;
250 let cursor = params.cursor;
251 let workspace_id = params.workspace_id;
252
253
254 let local_var_client = &local_var_configuration.client;
255
256 let local_var_uri_str = format!("{}/v2/calls", local_var_configuration.base_path);
257 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
258
259 if let Some(ref local_var_str) = cursor {
260 local_var_req_builder = local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
261 }
262 local_var_req_builder = local_var_req_builder.query(&[("fromDateTime", &from_date_time.to_string())]);
263 local_var_req_builder = local_var_req_builder.query(&[("toDateTime", &to_date_time.to_string())]);
264 if let Some(ref local_var_str) = workspace_id {
265 local_var_req_builder = local_var_req_builder.query(&[("workspaceId", &local_var_str.to_string())]);
266 }
267 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
268 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
269 }
270 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
271 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
272 };
273
274 let local_var_req = local_var_req_builder.build()?;
275 let local_var_resp = local_var_client.execute(local_var_req).await?;
276
277 let local_var_status = local_var_resp.status();
278 let local_var_content = local_var_resp.text().await?;
279
280 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
281 serde_json::from_str(&local_var_content).map_err(Error::from)
282 } else {
283 let local_var_entity: Option<ListCallsError> = serde_json::from_str(&local_var_content).ok();
284 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
285 Err(Error::ResponseError(local_var_error))
286 }
287}
288
289pub async fn list_calls_extensive(configuration: &configuration::Configuration, params: ListCallsExtensiveParams) -> Result<models::Calls, Error<ListCallsExtensiveError>> {
291 let local_var_configuration = configuration;
292
293 let public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector = params.public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector;
295
296
297 let local_var_client = &local_var_configuration.client;
298
299 let local_var_uri_str = format!("{}/v2/calls/extensive", local_var_configuration.base_path);
300 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
301
302 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
303 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
304 }
305 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
306 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
307 };
308 local_var_req_builder = local_var_req_builder.json(&public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector);
309
310 let local_var_req = local_var_req_builder.build()?;
311 let local_var_resp = local_var_client.execute(local_var_req).await?;
312
313 let local_var_status = local_var_resp.status();
314 let local_var_content = local_var_resp.text().await?;
315
316 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
317 serde_json::from_str(&local_var_content).map_err(Error::from)
318 } else {
319 let local_var_entity: Option<ListCallsExtensiveError> = serde_json::from_str(&local_var_content).ok();
320 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
321 Err(Error::ResponseError(local_var_error))
322 }
323}
324
325pub async fn list_crm_calls_manual_association(configuration: &configuration::Configuration, params: ListCrmCallsManualAssociationParams) -> Result<models::ManualAssociationResponse, Error<ListCrmCallsManualAssociationError>> {
327 let local_var_configuration = configuration;
328
329 let from_date_time = params.from_date_time;
331 let cursor = params.cursor;
332
333
334 let local_var_client = &local_var_configuration.client;
335
336 let local_var_uri_str = format!("{}/v2/calls/manual-crm-associations", local_var_configuration.base_path);
337 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
338
339 if let Some(ref local_var_str) = from_date_time {
340 local_var_req_builder = local_var_req_builder.query(&[("fromDateTime", &local_var_str.to_string())]);
341 }
342 if let Some(ref local_var_str) = cursor {
343 local_var_req_builder = local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
344 }
345 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
346 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
347 }
348 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
349 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
350 };
351
352 let local_var_req = local_var_req_builder.build()?;
353 let local_var_resp = local_var_client.execute(local_var_req).await?;
354
355 let local_var_status = local_var_resp.status();
356 let local_var_content = local_var_resp.text().await?;
357
358 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
359 serde_json::from_str(&local_var_content).map_err(Error::from)
360 } else {
361 let local_var_entity: Option<ListCrmCallsManualAssociationError> = serde_json::from_str(&local_var_content).ok();
362 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
363 Err(Error::ResponseError(local_var_error))
364 }
365}
366