1use 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 DisconnectConnectionError {
22 Status401(models::ApiError),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum InstallConnectionError {
30 Status401(models::ApiError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ListAccountsError {
38 Status401(models::ApiError),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum ListConnectionIntegrationsError {
46 Status401(models::ApiError),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ListConnectionsError {
54 Status401(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum ListUserConnectionsError {
62 Status401(models::ApiError),
63 UnknownValue(serde_json::Value),
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum RefreshConnectionError {
70 Status401(models::ApiError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RemoveAccountError {
78 Status401(models::ApiError),
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum ResolveAccountError {
86 Status401(models::ApiError),
87 UnknownValue(serde_json::Value),
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum SyncAccountError {
94 Status401(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum UpdateAccountError {
102 Status401(models::ApiError),
103 UnknownValue(serde_json::Value),
104}
105
106
107pub async fn disconnect_connection(configuration: &configuration::Configuration, disconnect_connection_request: models::DisconnectConnectionRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<DisconnectConnectionError>> {
108 let p_body_disconnect_connection_request = disconnect_connection_request;
110
111 let uri_str = format!("{}/v1/connections/disconnect", configuration.base_path);
112 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
113
114 if let Some(ref user_agent) = configuration.user_agent {
115 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116 }
117 if let Some(ref token) = configuration.bearer_access_token {
118 req_builder = req_builder.bearer_auth(token.to_owned());
119 };
120 req_builder = req_builder.json(&p_body_disconnect_connection_request);
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 `std::collections::HashMap<String, 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 `std::collections::HashMap<String, serde_json::Value>`")))),
139 }
140 } else {
141 let content = resp.text().await?;
142 let entity: Option<DisconnectConnectionError> = serde_json::from_str(&content).ok();
143 Err(Error::ResponseError(ResponseContent { status, content, entity }))
144 }
145}
146
147pub async fn install_connection(configuration: &configuration::Configuration, install_connection_request: models::InstallConnectionRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<InstallConnectionError>> {
148 let p_body_install_connection_request = install_connection_request;
150
151 let uri_str = format!("{}/v1/connections/install", configuration.base_path);
152 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
153
154 if let Some(ref user_agent) = configuration.user_agent {
155 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156 }
157 if let Some(ref token) = configuration.bearer_access_token {
158 req_builder = req_builder.bearer_auth(token.to_owned());
159 };
160 req_builder = req_builder.json(&p_body_install_connection_request);
161
162 let req = req_builder.build()?;
163 let resp = configuration.client.execute(req).await?;
164
165 let status = resp.status();
166 let content_type = resp
167 .headers()
168 .get("content-type")
169 .and_then(|v| v.to_str().ok())
170 .unwrap_or("application/octet-stream");
171 let content_type = super::ContentType::from(content_type);
172
173 if !status.is_client_error() && !status.is_server_error() {
174 let content = resp.text().await?;
175 match content_type {
176 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
177 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
178 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
179 }
180 } else {
181 let content = resp.text().await?;
182 let entity: Option<InstallConnectionError> = serde_json::from_str(&content).ok();
183 Err(Error::ResponseError(ResponseContent { status, content, entity }))
184 }
185}
186
187pub async fn list_accounts(configuration: &configuration::Configuration, ) -> Result<models::AccountListResponse, Error<ListAccountsError>> {
188
189 let uri_str = format!("{}/v1/accounts", configuration.base_path);
190 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
191
192 if let Some(ref user_agent) = configuration.user_agent {
193 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
194 }
195 if let Some(ref token) = configuration.bearer_access_token {
196 req_builder = req_builder.bearer_auth(token.to_owned());
197 };
198
199 let req = req_builder.build()?;
200 let resp = configuration.client.execute(req).await?;
201
202 let status = resp.status();
203 let content_type = resp
204 .headers()
205 .get("content-type")
206 .and_then(|v| v.to_str().ok())
207 .unwrap_or("application/octet-stream");
208 let content_type = super::ContentType::from(content_type);
209
210 if !status.is_client_error() && !status.is_server_error() {
211 let content = resp.text().await?;
212 match content_type {
213 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
214 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AccountListResponse`"))),
215 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::AccountListResponse`")))),
216 }
217 } else {
218 let content = resp.text().await?;
219 let entity: Option<ListAccountsError> = serde_json::from_str(&content).ok();
220 Err(Error::ResponseError(ResponseContent { status, content, entity }))
221 }
222}
223
224pub async fn list_connection_integrations(configuration: &configuration::Configuration, ) -> Result<models::ConnectionListResponse, Error<ListConnectionIntegrationsError>> {
225
226 let uri_str = format!("{}/v1/connections/integrations", configuration.base_path);
227 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
228
229 if let Some(ref user_agent) = configuration.user_agent {
230 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231 }
232 if let Some(ref token) = configuration.bearer_access_token {
233 req_builder = req_builder.bearer_auth(token.to_owned());
234 };
235
236 let req = req_builder.build()?;
237 let resp = configuration.client.execute(req).await?;
238
239 let status = resp.status();
240 let content_type = resp
241 .headers()
242 .get("content-type")
243 .and_then(|v| v.to_str().ok())
244 .unwrap_or("application/octet-stream");
245 let content_type = super::ContentType::from(content_type);
246
247 if !status.is_client_error() && !status.is_server_error() {
248 let content = resp.text().await?;
249 match content_type {
250 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectionListResponse`"))),
252 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::ConnectionListResponse`")))),
253 }
254 } else {
255 let content = resp.text().await?;
256 let entity: Option<ListConnectionIntegrationsError> = serde_json::from_str(&content).ok();
257 Err(Error::ResponseError(ResponseContent { status, content, entity }))
258 }
259}
260
261pub async fn list_connections(configuration: &configuration::Configuration, ) -> Result<models::ConnectionListResponse, Error<ListConnectionsError>> {
262
263 let uri_str = format!("{}/v1/connections/list", configuration.base_path);
264 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
265
266 if let Some(ref user_agent) = configuration.user_agent {
267 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
268 }
269 if let Some(ref token) = configuration.bearer_access_token {
270 req_builder = req_builder.bearer_auth(token.to_owned());
271 };
272
273 let req = req_builder.build()?;
274 let resp = configuration.client.execute(req).await?;
275
276 let status = resp.status();
277 let content_type = resp
278 .headers()
279 .get("content-type")
280 .and_then(|v| v.to_str().ok())
281 .unwrap_or("application/octet-stream");
282 let content_type = super::ContentType::from(content_type);
283
284 if !status.is_client_error() && !status.is_server_error() {
285 let content = resp.text().await?;
286 match content_type {
287 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
288 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectionListResponse`"))),
289 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::ConnectionListResponse`")))),
290 }
291 } else {
292 let content = resp.text().await?;
293 let entity: Option<ListConnectionsError> = serde_json::from_str(&content).ok();
294 Err(Error::ResponseError(ResponseContent { status, content, entity }))
295 }
296}
297
298pub async fn list_user_connections(configuration: &configuration::Configuration, ) -> Result<models::ConnectionAccountListResponse, Error<ListUserConnectionsError>> {
299
300 let uri_str = format!("{}/v1/connections/user", configuration.base_path);
301 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
302
303 if let Some(ref user_agent) = configuration.user_agent {
304 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
305 }
306 if let Some(ref token) = configuration.bearer_access_token {
307 req_builder = req_builder.bearer_auth(token.to_owned());
308 };
309
310 let req = req_builder.build()?;
311 let resp = configuration.client.execute(req).await?;
312
313 let status = resp.status();
314 let content_type = resp
315 .headers()
316 .get("content-type")
317 .and_then(|v| v.to_str().ok())
318 .unwrap_or("application/octet-stream");
319 let content_type = super::ContentType::from(content_type);
320
321 if !status.is_client_error() && !status.is_server_error() {
322 let content = resp.text().await?;
323 match content_type {
324 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
325 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConnectionAccountListResponse`"))),
326 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::ConnectionAccountListResponse`")))),
327 }
328 } else {
329 let content = resp.text().await?;
330 let entity: Option<ListUserConnectionsError> = serde_json::from_str(&content).ok();
331 Err(Error::ResponseError(ResponseContent { status, content, entity }))
332 }
333}
334
335pub async fn refresh_connection(configuration: &configuration::Configuration, refresh_connection_request: models::RefreshConnectionRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<RefreshConnectionError>> {
336 let p_body_refresh_connection_request = refresh_connection_request;
338
339 let uri_str = format!("{}/v1/connections/refresh", configuration.base_path);
340 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
341
342 if let Some(ref user_agent) = configuration.user_agent {
343 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
344 }
345 if let Some(ref token) = configuration.bearer_access_token {
346 req_builder = req_builder.bearer_auth(token.to_owned());
347 };
348 req_builder = req_builder.json(&p_body_refresh_connection_request);
349
350 let req = req_builder.build()?;
351 let resp = configuration.client.execute(req).await?;
352
353 let status = resp.status();
354 let content_type = resp
355 .headers()
356 .get("content-type")
357 .and_then(|v| v.to_str().ok())
358 .unwrap_or("application/octet-stream");
359 let content_type = super::ContentType::from(content_type);
360
361 if !status.is_client_error() && !status.is_server_error() {
362 let content = resp.text().await?;
363 match content_type {
364 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
365 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
366 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
367 }
368 } else {
369 let content = resp.text().await?;
370 let entity: Option<RefreshConnectionError> = serde_json::from_str(&content).ok();
371 Err(Error::ResponseError(ResponseContent { status, content, entity }))
372 }
373}
374
375pub async fn remove_account(configuration: &configuration::Configuration, account_id: &str) -> Result<(), Error<RemoveAccountError>> {
376 let p_path_account_id = account_id;
378
379 let uri_str = format!("{}/v1/accounts/{accountId}", configuration.base_path, accountId=crate::apis::urlencode(p_path_account_id));
380 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
381
382 if let Some(ref user_agent) = configuration.user_agent {
383 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384 }
385 if let Some(ref token) = configuration.bearer_access_token {
386 req_builder = req_builder.bearer_auth(token.to_owned());
387 };
388
389 let req = req_builder.build()?;
390 let resp = configuration.client.execute(req).await?;
391
392 let status = resp.status();
393
394 if !status.is_client_error() && !status.is_server_error() {
395 Ok(())
396 } else {
397 let content = resp.text().await?;
398 let entity: Option<RemoveAccountError> = serde_json::from_str(&content).ok();
399 Err(Error::ResponseError(ResponseContent { status, content, entity }))
400 }
401}
402
403pub async fn resolve_account(configuration: &configuration::Configuration, provider: Option<&str>, email: Option<&str>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ResolveAccountError>> {
404 let p_query_provider = provider;
406 let p_query_email = email;
407
408 let uri_str = format!("{}/v1/accounts/resolve", configuration.base_path);
409 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
410
411 if let Some(ref param_value) = p_query_provider {
412 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
413 }
414 if let Some(ref param_value) = p_query_email {
415 req_builder = req_builder.query(&[("email", ¶m_value.to_string())]);
416 }
417 if let Some(ref user_agent) = configuration.user_agent {
418 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
419 }
420 if let Some(ref token) = configuration.bearer_access_token {
421 req_builder = req_builder.bearer_auth(token.to_owned());
422 };
423
424 let req = req_builder.build()?;
425 let resp = configuration.client.execute(req).await?;
426
427 let status = resp.status();
428 let content_type = resp
429 .headers()
430 .get("content-type")
431 .and_then(|v| v.to_str().ok())
432 .unwrap_or("application/octet-stream");
433 let content_type = super::ContentType::from(content_type);
434
435 if !status.is_client_error() && !status.is_server_error() {
436 let content = resp.text().await?;
437 match content_type {
438 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
439 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
440 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
441 }
442 } else {
443 let content = resp.text().await?;
444 let entity: Option<ResolveAccountError> = serde_json::from_str(&content).ok();
445 Err(Error::ResponseError(ResponseContent { status, content, entity }))
446 }
447}
448
449pub async fn sync_account(configuration: &configuration::Configuration, account_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<SyncAccountError>> {
450 let p_path_account_id = account_id;
452
453 let uri_str = format!("{}/v1/accounts/{accountId}/sync", configuration.base_path, accountId=crate::apis::urlencode(p_path_account_id));
454 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
455
456 if let Some(ref user_agent) = configuration.user_agent {
457 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
458 }
459 if let Some(ref token) = configuration.bearer_access_token {
460 req_builder = req_builder.bearer_auth(token.to_owned());
461 };
462
463 let req = req_builder.build()?;
464 let resp = configuration.client.execute(req).await?;
465
466 let status = resp.status();
467 let content_type = resp
468 .headers()
469 .get("content-type")
470 .and_then(|v| v.to_str().ok())
471 .unwrap_or("application/octet-stream");
472 let content_type = super::ContentType::from(content_type);
473
474 if !status.is_client_error() && !status.is_server_error() {
475 let content = resp.text().await?;
476 match content_type {
477 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
478 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
479 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
480 }
481 } else {
482 let content = resp.text().await?;
483 let entity: Option<SyncAccountError> = serde_json::from_str(&content).ok();
484 Err(Error::ResponseError(ResponseContent { status, content, entity }))
485 }
486}
487
488pub async fn update_account(configuration: &configuration::Configuration, account_id: &str, update_account_request: models::UpdateAccountRequest) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<UpdateAccountError>> {
489 let p_path_account_id = account_id;
491 let p_body_update_account_request = update_account_request;
492
493 let uri_str = format!("{}/v1/accounts/{accountId}", configuration.base_path, accountId=crate::apis::urlencode(p_path_account_id));
494 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
495
496 if let Some(ref user_agent) = configuration.user_agent {
497 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
498 }
499 if let Some(ref token) = configuration.bearer_access_token {
500 req_builder = req_builder.bearer_auth(token.to_owned());
501 };
502 req_builder = req_builder.json(&p_body_update_account_request);
503
504 let req = req_builder.build()?;
505 let resp = configuration.client.execute(req).await?;
506
507 let status = resp.status();
508 let content_type = resp
509 .headers()
510 .get("content-type")
511 .and_then(|v| v.to_str().ok())
512 .unwrap_or("application/octet-stream");
513 let content_type = super::ContentType::from(content_type);
514
515 if !status.is_client_error() && !status.is_server_error() {
516 let content = resp.text().await?;
517 match content_type {
518 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
520 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
521 }
522 } else {
523 let content = resp.text().await?;
524 let entity: Option<UpdateAccountError> = serde_json::from_str(&content).ok();
525 Err(Error::ResponseError(ResponseContent { status, content, entity }))
526 }
527}
528