pub struct UsersClient { /* private fields */ }Expand description
Client for users operations
Implementations§
Source§impl UsersClient
impl UsersClient
Sourcepub fn new(client: Client, app_id: String, base_url: String) -> Self
pub fn new(client: Client, app_id: String, base_url: String) -> Self
Create a new client instance
Sourcepub async fn list<'a>(
&'a self,
cursor: Option<&'a GetUsersCursor>,
limit: Option<f64>,
) -> Result<ResponseValue<GetUsersResponse>, Error<()>>
pub async fn list<'a>( &'a self, cursor: Option<&'a GetUsersCursor>, limit: Option<f64>, ) -> Result<ResponseValue<GetUsersResponse>, Error<()>>
Gets Users
Get all users in your app.
Sends a GET request to /v1/users
Sourcepub async fn create<'a>(
&'a self,
body: &'a CreateUserBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn create<'a>( &'a self, body: &'a CreateUserBody, ) -> Result<ResponseValue<User>, Error<()>>
Create User
Create a new user with linked accounts. Optionally pre-generate embedded wallets for the user.
Sends a POST request to /v1/users
Examples found in repository?
29async fn main() -> Result<()> {
30 tracing_subscriber::fmt()
31 .with_env_filter(
32 EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
33 )
34 .init();
35
36 // Initialize client from environment variables
37 let client = PrivyClient::new_from_env()?;
38
39 tracing::info!("initialized privy client from environment");
40
41 let user = client
42 .users()
43 .create(&CreateUserBody {
44 linked_accounts: vec![
45 LinkedAccountInput::EmailInput(LinkedAccountEmailInput {
46 address: "alex@arlyon.dev".into(),
47 type_: LinkedAccountEmailInputType::Email,
48 }),
49 LinkedAccountInput::CustomJwtInput(LinkedAccountCustomJwtInput {
50 custom_user_id: "alex@arlyon.dev".try_into().unwrap(),
51 type_: LinkedAccountCustomJwtInputType::CustomAuth,
52 }),
53 ],
54 custom_metadata: None,
55 wallets: vec![],
56 })
57 .await?;
58
59 tracing::info!("got new user: {:?}", user);
60
61 Ok(())
62}Sourcepub async fn get<'a>(
&'a self,
user_id: &'a str,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get<'a>( &'a self, user_id: &'a str, ) -> Result<ResponseValue<User>, Error<()>>
Get User
Get a user by user ID.
Sends a GET request to /v1/users/{user_id}
Sourcepub async fn get_by_discord_username<'a>(
&'a self,
body: &'a LookUpUserByDiscordUsernameBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_discord_username<'a>( &'a self, body: &'a LookUpUserByDiscordUsernameBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Discord Username
Looks up a user by their Discord username.
Sends a POST request to /v1/users/discord/username
Sourcepub async fn get_by_email_address<'a>(
&'a self,
body: &'a LookUpUserByEmailBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_email_address<'a>( &'a self, body: &'a LookUpUserByEmailBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Email Address
Looks up a user by their email address.
Sends a POST request to /v1/users/email/address
Sourcepub async fn get_by_farcaster_id<'a>(
&'a self,
body: &'a LookUpUserByFarcasterIdBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_farcaster_id<'a>( &'a self, body: &'a LookUpUserByFarcasterIdBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Farcaster ID
Looks up a user by their Farcaster ID.
Sends a POST request to /v1/users/farcaster/fid
Sourcepub async fn get_by_github_username<'a>(
&'a self,
body: &'a LookUpUserByGithubUsernameBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_github_username<'a>( &'a self, body: &'a LookUpUserByGithubUsernameBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Github Username
Looks up a user by their Github username.
Sends a POST request to /v1/users/github/username
Sourcepub async fn get_by_phone_number<'a>(
&'a self,
body: &'a LookUpUserByPhoneNumberBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_phone_number<'a>( &'a self, body: &'a LookUpUserByPhoneNumberBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Phone Number
Looks up a user by their phone number.
Sends a POST request to /v1/users/phone/number
Sourcepub async fn get_by_smart_wallet_address<'a>(
&'a self,
body: &'a LookUpUserBySmartWalletAddressBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_smart_wallet_address<'a>( &'a self, body: &'a LookUpUserBySmartWalletAddressBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Smart Wallet Address
Looks up a user by their smart wallet address.
Sends a POST request to /v1/users/smart_wallet/address
Sourcepub async fn get_by_telegram_user_id<'a>(
&'a self,
body: &'a LookUpUserByTelegramUserIdBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_telegram_user_id<'a>( &'a self, body: &'a LookUpUserByTelegramUserIdBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Telegram User ID
Looks up a user by their Telegram user ID.
Sends a POST request to /v1/users/telegram/telegram_user_id
Sourcepub async fn get_by_telegram_username<'a>(
&'a self,
body: &'a LookUpUserByTelegramUsernameBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_telegram_username<'a>( &'a self, body: &'a LookUpUserByTelegramUsernameBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Telegram Username
Looks up a user by their Telegram username.
Sends a POST request to /v1/users/telegram/username
Sourcepub async fn get_by_twitter_subject<'a>(
&'a self,
body: &'a LookUpUserByTwitterSubjectBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_twitter_subject<'a>( &'a self, body: &'a LookUpUserByTwitterSubjectBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Twitter Subject
Looks up a user by their Twitter subject.
Sends a POST request to /v1/users/twitter/subject
Sourcepub async fn get_by_twitter_username<'a>(
&'a self,
body: &'a LookUpUserByTwitterUsernameBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_twitter_username<'a>( &'a self, body: &'a LookUpUserByTwitterUsernameBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Twitter Username
Looks up a user by their Twitter username.
Sends a POST request to /v1/users/twitter/username
Sourcepub async fn get_by_wallet_address<'a>(
&'a self,
body: &'a LookUpUserByWalletAddressBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_wallet_address<'a>( &'a self, body: &'a LookUpUserByWalletAddressBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by wallet address
Looks up a user by their wallet address.
Sends a POST request to /v1/users/wallet/address
Sourcepub async fn get_by_custom_auth_id<'a>(
&'a self,
body: &'a LookUpUserByCustomAuthIdBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn get_by_custom_auth_id<'a>( &'a self, body: &'a LookUpUserByCustomAuthIdBody, ) -> Result<ResponseValue<User>, Error<()>>
Lookup User by Custom Auth ID
Looks up a user by their custom auth ID.
Sends a POST request to /v1/users/custom_auth/id
Sourcepub async fn delete<'a>(
&'a self,
user_id: &'a str,
) -> Result<ResponseValue<()>, Error<ByteStream>>
pub async fn delete<'a>( &'a self, user_id: &'a str, ) -> Result<ResponseValue<()>, Error<ByteStream>>
Delete User
Delete a user by user ID.
Sends a DELETE request to /v1/users/{user_id}
Examples found in repository?
24async fn main() -> Result<()> {
25 tracing_subscriber::fmt()
26 .with_env_filter(
27 EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
28 )
29 .init();
30
31 // Initialize client from environment variables
32 let client = PrivyClient::new_from_env()?;
33
34 tracing::info!("initialized privy client from environment");
35
36 let user = client.users().delete("cmf56qacr01qpl90brxql83lx").await?;
37
38 tracing::info!("deleted user: {:?}", user);
39
40 Ok(())
41}Sourcepub async fn set_custom_metadata<'a>(
&'a self,
user_id: &'a str,
body: &'a UpdateUserCustomMetadataBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn set_custom_metadata<'a>( &'a self, user_id: &'a str, body: &'a UpdateUserCustomMetadataBody, ) -> Result<ResponseValue<User>, Error<()>>
Create Custom Metadata
Adds custom metadata to a user by user ID.
Sends a POST request to /v1/users/{user_id}/custom_metadata
Sourcepub async fn unlink_linked_account<'a>(
&'a self,
user_id: &'a str,
body: &'a UnlinkUserLinkedAccountBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn unlink_linked_account<'a>( &'a self, user_id: &'a str, body: &'a UnlinkUserLinkedAccountBody, ) -> Result<ResponseValue<User>, Error<()>>
Unlink a user linked account
Unlinks a user linked account.
Sends a POST request to /v1/users/{user_id}/accounts/unlink
Sourcepub async fn pregenerate_wallets<'a>(
&'a self,
user_id: &'a str,
body: &'a CreateUserWalletBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn pregenerate_wallets<'a>( &'a self, user_id: &'a str, body: &'a CreateUserWalletBody, ) -> Result<ResponseValue<User>, Error<()>>
Create Embedded Wallet
Creates an embedded wallet for an existing user.
Sends a POST request to /v1/users/{user_id}/wallets
Sourcepub async fn search<'a>(
&'a self,
body: &'a SearchUsersBody,
) -> Result<ResponseValue<User>, Error<()>>
pub async fn search<'a>( &'a self, body: &'a SearchUsersBody, ) -> Result<ResponseValue<User>, Error<()>>
Search Users by Search Term
Search users by search term, emails, phone numbers, or wallet addresses.
Sends a POST request to /v1/users/search
Examples found in repository?
24async fn main() -> Result<()> {
25 tracing_subscriber::fmt()
26 .with_env_filter(
27 EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")),
28 )
29 .init();
30
31 // Get search term from environment and initialize client
32 let search_term =
33 std::env::var("PRIVY_SEARCH_TERM").unwrap_or_else(|_| "alex@arlyon.dev".to_string());
34 let client = PrivyClient::new_from_env()?;
35
36 tracing::info!(
37 "initialized privy client from environment, search_term: {}",
38 search_term
39 );
40
41 // Search for users by email address or other criteria
42 let search_result = client
43 .users()
44 // TODO: search term rename is not working
45 .search(&SearchUsersBody::Variant0 { search_term })
46 .await?;
47
48 tracing::info!("search result: {:?}", search_result);
49
50 Ok(())
51}Trait Implementations§
Source§impl Clone for UsersClient
impl Clone for UsersClient
Source§fn clone(&self) -> UsersClient
fn clone(&self) -> UsersClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more