egs_api/facade/
account.rs1use crate::EpicGames;
2use crate::api::error::EpicAPIError;
3use crate::api::types::account::{AccountData, AccountInfo, ExternalAuth};
4use crate::api::types::asset_info::GameToken;
5use crate::api::types::entitlement::Entitlement;
6use crate::api::types::epic_asset::EpicAsset;
7use crate::api::types::friends::Friend;
8use crate::api::types::library::Library;
9
10impl EpicGames {
11 pub async fn try_account_details(&mut self) -> Result<AccountData, EpicAPIError> {
13 self.egs.account_details().await
14 }
15
16 pub async fn account_details(&mut self) -> Option<AccountData> {
20 self.try_account_details().await.ok()
21 }
22
23 pub async fn try_account_ids_details(
25 &mut self,
26 ids: Vec<String>,
27 ) -> Result<Vec<AccountInfo>, EpicAPIError> {
28 self.egs.account_ids_details(ids).await
29 }
30
31 pub async fn account_ids_details(&mut self, ids: Vec<String>) -> Option<Vec<AccountInfo>> {
35 self.try_account_ids_details(ids).await.ok()
36 }
37
38 pub async fn try_account_friends(
40 &mut self,
41 include_pending: bool,
42 ) -> Result<Vec<Friend>, EpicAPIError> {
43 self.egs.account_friends(include_pending).await
44 }
45
46 pub async fn account_friends(&mut self, include_pending: bool) -> Option<Vec<Friend>> {
50 self.try_account_friends(include_pending).await.ok()
51 }
52
53 pub async fn try_external_auths(
55 &self,
56 account_id: &str,
57 ) -> Result<Vec<ExternalAuth>, EpicAPIError> {
58 self.egs.external_auths(account_id).await
59 }
60
61 pub async fn external_auths(&self, account_id: &str) -> Option<Vec<ExternalAuth>> {
68 self.try_external_auths(account_id).await.ok()
69 }
70
71 pub async fn try_sso_domains(&self) -> Result<Vec<String>, EpicAPIError> {
73 self.egs.sso_domains().await
74 }
75
76 pub async fn sso_domains(&self) -> Option<Vec<String>> {
83 self.try_sso_domains().await.ok()
84 }
85
86 pub async fn try_game_token(&mut self) -> Result<GameToken, EpicAPIError> {
88 self.egs.game_token().await
89 }
90
91 pub async fn game_token(&mut self) -> Option<GameToken> {
95 self.try_game_token().await.ok()
96 }
97
98 pub async fn try_ownership_token(&mut self, asset: &EpicAsset) -> Result<String, EpicAPIError> {
100 self.egs.ownership_token(asset).await.map(|a| a.token)
101 }
102
103 pub async fn ownership_token(&mut self, asset: &EpicAsset) -> Option<String> {
107 self.try_ownership_token(asset).await.ok()
108 }
109
110 pub async fn try_user_entitlements(&mut self) -> Result<Vec<Entitlement>, EpicAPIError> {
112 self.egs.user_entitlements().await
113 }
114
115 pub async fn user_entitlements(&mut self) -> Vec<Entitlement> {
119 self.try_user_entitlements()
120 .await
121 .unwrap_or_else(|_| Vec::new())
122 }
123
124 pub async fn try_library_items(
126 &mut self,
127 include_metadata: bool,
128 ) -> Result<Library, EpicAPIError> {
129 self.egs.library_items(include_metadata).await
130 }
131
132 pub async fn library_items(&mut self, include_metadata: bool) -> Option<Library> {
136 self.try_library_items(include_metadata).await.ok()
137 }
138}