use serde::Deserialize;
use crate::constants::ACCOUNT_ENDPOINT_URL;
use crate::models::user::AccountID;
use crate::{PSNApiResult, PSNClient};
impl PSNClient {
pub async fn get_own_account_id(&self) -> PSNApiResult<AccountID> {
#[derive(Deserialize)]
struct AccountIdResponse {
#[serde(rename = "accountId")]
account_id: String,
}
let response = self
.get_authenticated(
format!("{ACCOUNT_ENDPOINT_URL}/v1/devices/accounts/me"),
None,
Option::<()>::None,
)
.await?;
let account_id_response = response.json::<AccountIdResponse>().await?;
Ok(AccountID(account_id_response.account_id))
}
}