bitwarden_api_api/apis/
sync_api.rs1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{AuthRequired, ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait SyncApi: Send + Sync {
29 async fn get<'a>(
31 &self,
32 exclude_domains: Option<bool>,
33 ) -> Result<models::SyncResponseModel, Error<GetError>>;
34}
35
36pub struct SyncApiClient {
37 configuration: Arc<configuration::Configuration>,
38}
39
40impl SyncApiClient {
41 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
42 Self { configuration }
43 }
44}
45
46#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
47#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
48impl SyncApi for SyncApiClient {
49 async fn get<'a>(
50 &self,
51 exclude_domains: Option<bool>,
52 ) -> Result<models::SyncResponseModel, Error<GetError>> {
53 let local_var_configuration = &self.configuration;
54
55 let local_var_client = &local_var_configuration.client;
56
57 let local_var_uri_str = format!("{}/sync", local_var_configuration.base_path);
58 let mut local_var_req_builder =
59 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
60
61 if let Some(ref param_value) = exclude_domains {
62 local_var_req_builder =
63 local_var_req_builder.query(&[("excludeDomains", ¶m_value.to_string())]);
64 }
65 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
66
67 bitwarden_api_base::process_with_json_response(local_var_req_builder).await
68 }
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum GetError {
75 UnknownValue(serde_json::Value),
76}