pub struct PSNClient { /* private fields */ }Expand description
Main API client.
Implementations§
Source§impl PSNClient
impl PSNClient
Sourcepub async fn authenticate(&mut self) -> PSNApiResult<()>
pub async fn authenticate(&mut self) -> PSNApiResult<()>
Examples found in repository?
examples/get_all_titles.rs (line 9)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let trophy_titles = psn_client.get_all_trophies_titles(&account_id).await?;
14
15 for trophy_title in trophy_titles {
16 println!(
17 "ID: {} - Name: {} - Platform: {} - progress: {}",
18 trophy_title.np_communication_id,
19 trophy_title.trophy_title_name,
20 trophy_title.trophy_title_platform,
21 trophy_title.progress
22 );
23 }
24
25 Ok(())
26}More examples
examples/get_title_trophies.rs (line 9)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let title_trophies = psn_client
14 .get_trophies_earned_for_title(
15 &account_id,
16 "NPWR01537_00", /* Borderlands 2 PS3,PSVITA */
17 "all",
18 false,
19 )
20 .await?;
21
22 for trophy in title_trophies.trophies {
23 println!(
24 "{}: {} - {} - {}",
25 trophy.id, trophy.trophy_type, trophy.rarity, trophy.earned
26 );
27 }
28
29 Ok(())
30}Source§impl PSNClient
impl PSNClient
Sourcepub async fn get_all_trophies_titles(
&self,
account_id: &AccountID,
) -> PSNApiResult<Vec<TrophyTitle>>
pub async fn get_all_trophies_titles( &self, account_id: &AccountID, ) -> PSNApiResult<Vec<TrophyTitle>>
Get all trophy titles associated with account identified by account_id parameter.
Examples found in repository?
examples/get_all_titles.rs (line 13)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let trophy_titles = psn_client.get_all_trophies_titles(&account_id).await?;
14
15 for trophy_title in trophy_titles {
16 println!(
17 "ID: {} - Name: {} - Platform: {} - progress: {}",
18 trophy_title.np_communication_id,
19 trophy_title.trophy_title_name,
20 trophy_title.trophy_title_platform,
21 trophy_title.progress
22 );
23 }
24
25 Ok(())
26}Sourcepub async fn get_trophies_earned_for_title(
&self,
account_id: &AccountID,
title_id: &str,
trophy_group_id: &str,
ps5: bool,
) -> PSNApiResult<TitleTrophies>
pub async fn get_trophies_earned_for_title( &self, account_id: &AccountID, title_id: &str, trophy_group_id: &str, ps5: bool, ) -> PSNApiResult<TitleTrophies>
Get all trophies earned for a specific title associated with account identified by account_id parameter.
Examples found in repository?
examples/get_title_trophies.rs (lines 14-19)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let title_trophies = psn_client
14 .get_trophies_earned_for_title(
15 &account_id,
16 "NPWR01537_00", /* Borderlands 2 PS3,PSVITA */
17 "all",
18 false,
19 )
20 .await?;
21
22 for trophy in title_trophies.trophies {
23 println!(
24 "{}: {} - {} - {}",
25 trophy.id, trophy.trophy_type, trophy.rarity, trophy.earned
26 );
27 }
28
29 Ok(())
30}Source§impl PSNClient
impl PSNClient
Sourcepub async fn get_own_account_id(&self) -> PSNApiResult<AccountID>
pub async fn get_own_account_id(&self) -> PSNApiResult<AccountID>
Get the account ID of the authenticated user.
Examples found in repository?
examples/get_all_titles.rs (line 11)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let trophy_titles = psn_client.get_all_trophies_titles(&account_id).await?;
14
15 for trophy_title in trophy_titles {
16 println!(
17 "ID: {} - Name: {} - Platform: {} - progress: {}",
18 trophy_title.np_communication_id,
19 trophy_title.trophy_title_name,
20 trophy_title.trophy_title_platform,
21 trophy_title.progress
22 );
23 }
24
25 Ok(())
26}More examples
examples/get_title_trophies.rs (line 11)
6async fn main() -> PSNApiResult<()> {
7 let mut psn_client = utils::build_client()?;
8
9 psn_client.authenticate().await?;
10
11 let account_id = psn_client.get_own_account_id().await?;
12
13 let title_trophies = psn_client
14 .get_trophies_earned_for_title(
15 &account_id,
16 "NPWR01537_00", /* Borderlands 2 PS3,PSVITA */
17 "all",
18 false,
19 )
20 .await?;
21
22 for trophy in title_trophies.trophies {
23 println!(
24 "{}: {} - {} - {}",
25 trophy.id, trophy.trophy_type, trophy.rarity, trophy.earned
26 );
27 }
28
29 Ok(())
30}Auto Trait Implementations§
impl Freeze for PSNClient
impl !RefUnwindSafe for PSNClient
impl Send for PSNClient
impl Sync for PSNClient
impl Unpin for PSNClient
impl UnsafeUnpin for PSNClient
impl !UnwindSafe for PSNClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more