Skip to main content

egs_api/facade/
misc.rs

1use crate::EpicGames;
2use crate::api::error::EpicAPIError;
3use crate::api::types::cloud_save::CloudSaveResponse;
4use crate::api::types::presence::PresenceUpdate;
5use crate::api::types::service_status::ServiceStatus;
6
7impl EpicGames {
8    /// Like [`service_status`](Self::service_status), but returns a `Result` instead of swallowing errors.
9    pub async fn try_service_status(
10        &self,
11        service_id: &str,
12    ) -> Result<Vec<ServiceStatus>, EpicAPIError> {
13        self.egs.service_status(service_id).await
14    }
15
16    /// Fetch service status from Epic's lightswitch API.
17    ///
18    /// Returns the operational status of an Epic online service (e.g., a game's
19    /// backend). The response includes whether the service is UP/DOWN, any
20    /// maintenance message, and whether the current user is banned.
21    ///
22    /// Returns `None` on API errors.
23    pub async fn service_status(&self, service_id: &str) -> Option<Vec<ServiceStatus>> {
24        self.try_service_status(service_id).await.ok()
25    }
26
27    /// Update the user's presence status.
28    ///
29    /// Sends a PATCH request to update the user's online presence (e.g.,
30    /// "online", "away") and optionally set an activity with custom properties.
31    /// The `session_id` is the OAuth session token from login. Returns `Ok(())`
32    /// on success (204 No Content) or an [`EpicAPIError`] on failure.
33    pub async fn update_presence(
34        &self,
35        session_id: &str,
36        body: &PresenceUpdate,
37    ) -> Result<(), EpicAPIError> {
38        self.egs.update_presence(session_id, body).await
39    }
40
41    // ── Cloud Saves ──
42
43    /// List cloud save files for the logged-in user.
44    ///
45    /// If `app_name` is provided, lists saves for that specific game.
46    /// If `manifests` is true (only relevant when `app_name` is set), lists manifest files.
47    pub async fn cloud_save_list(
48        &self,
49        app_name: Option<&str>,
50        manifests: bool,
51    ) -> Result<CloudSaveResponse, EpicAPIError> {
52        self.egs.cloud_save_list(app_name, manifests).await
53    }
54
55    /// Query cloud save files by specific filenames.
56    ///
57    /// Returns metadata including read/write links for the specified files.
58    pub async fn cloud_save_query(
59        &self,
60        app_name: &str,
61        filenames: &[String],
62    ) -> Result<CloudSaveResponse, EpicAPIError> {
63        self.egs.cloud_save_query(app_name, filenames).await
64    }
65
66    /// Delete a cloud save file by its storage path.
67    pub async fn cloud_save_delete(&self, path: &str) -> Result<(), EpicAPIError> {
68        self.egs.cloud_save_delete(path).await
69    }
70}