Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implements XalAuthenticator::with_device_id #5

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading