sure_client_rs/client/sync.rs
1use crate::error::ApiResult;
2use crate::models::sync::SyncResponse;
3use reqwest::Method;
4
5use super::SureClient;
6
7impl SureClient {
8 /// Trigger a family sync
9 ///
10 /// Triggers a sync operation that will apply all active rules, sync all accounts,
11 /// and auto-match transfers.
12 ///
13 /// # Returns
14 /// Sync response with status information.
15 ///
16 /// # Errors
17 /// Returns `ApiError::Unauthorized` if the API key is invalid.
18 /// Returns `ApiError::Forbidden` if the API key has insufficient scope.
19 /// Returns `ApiError::InternalServerError` if the sync fails to start.
20 /// Returns `ApiError::Network` if the request fails due to network issues.
21 ///
22 /// # Example
23 /// ```no_run
24 /// use sure_client_rs::{SureClient, BearerToken};
25 ///
26 /// # async fn example(client: SureClient) -> Result<(), Box<dyn std::error::Error>> {
27 /// let response = client.trigger_sync().await?;
28 /// println!("Sync queued: {}", response.message);
29 /// # Ok(())
30 /// # }
31 /// ```
32 ///
33 pub async fn trigger_sync(&self) -> ApiResult<SyncResponse> {
34 self.execute_request(Method::POST, "/api/v1/sync", None, None)
35 .await
36 }
37}