UsersClient

Struct UsersClient 

Source
pub struct UsersClient { /* private fields */ }
Expand description

Client for users operations

Implementations§

Source§

impl UsersClient

Source

pub fn new(client: Client, app_id: String, base_url: String) -> Self

Create a new client instance

Source

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

Source

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?
examples/create_user.rs (lines 43-56)
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}
Source

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}

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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?
examples/delete_user.rs (line 36)
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}
Source

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

Unlink a user linked account

Unlinks a user linked account.

Sends a POST request to /v1/users/{user_id}/accounts/unlink

Source

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

Source

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?
examples/search_users.rs (line 45)
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

Source§

fn clone(&self) -> UsersClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UsersClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more