Skip to content

Commit

Permalink
feat: Implements XalAuthenticator::with_device_id
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Dec 15, 2024
1 parent 4bc9054 commit 7f098f2
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@ impl XalAuthenticator {
/// This method initializes an instance of the XAL Authenticator with the specified
/// `app_params`, `client_params`, and `sandbox_id`.
///
/// The `device_id` parameter can be provided to use a specific device ID, or it can be left as
/// `None` to generate a new device ID.
///
/// See constants in [`crate::models::app_params`] for [`crate::XalAppParameters`] and
/// [`crate::models::client_params`] for [`crate::XalClientParameters`].
///
Expand Down Expand Up @@ -371,6 +368,42 @@ impl XalAuthenticator {
}
}

/// Create a new instance of the XAL Authenticator with explicit Device Id.
///
/// See `new()` method.
///
/// # Examples
///
/// Instantiate explicitly with app/client parameters and device id
///
/// ```
/// use xal::{XalAuthenticator, app_params, client_params};
/// let authenticator = XalAuthenticator::with_device_id(
/// app_params::APP_GAMEPASS_BETA(),
/// client_params::CLIENT_ANDROID(),
/// "RETAIL".into(),
/// uuid::uuid!("dc1183d0-a9f8-4c3f-a2a9-83706023791e")
/// );
/// ```
///
/// # Notes
///
/// If you don't have specific needs for client parameters, use [`crate::XalAuthenticator::default`]
pub fn with_device_id(
app_params: XalAppParameters,
client_params: XalClientParameters,
sandbox_id: String,
device_id: uuid::Uuid,
) -> Self {
Self {
app_params,
client_params,
device_id,
sandbox_id,
..Default::default()
}
}

/// Get Device Id
pub fn device_id(&self) -> uuid::Uuid {
self.device_id
Expand Down

0 comments on commit 7f098f2

Please sign in to comment.