Class: Privy::Services::Users

Inherits:
Resources::Users show all
Defined in:
lib/privy/public_api/services/users.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resources::Users

#delete, #get, #get_by_custom_auth_id, #get_by_discord_username, #get_by_email_address, #get_by_farcaster_id, #get_by_github_username, #get_by_phone_number, #get_by_smart_wallet_address, #get_by_telegram_user_id, #get_by_telegram_username, #get_by_twitter_subject, #get_by_twitter_username, #get_by_wallet_address, #list, #pregenerate_wallets, #search, #set_custom_metadata, #unlink_linked_account

Constructor Details

#initialize(client:, privy_client:) ⇒ Users

Returns a new instance of Users.



8
9
10
11
# File 'lib/privy/public_api/services/users.rb', line 8

def initialize(client:, privy_client:)
  super(client: client)
  @privy_client = privy_client
end

Instance Attribute Details

#privy_clientObject (readonly)

Returns the value of attribute privy_client.



6
7
8
# File 'lib/privy/public_api/services/users.rb', line 6

def privy_client
  @privy_client
end

Instance Method Details

#create(user_create_params:, request_options: nil) ⇒ Privy::Models::User

Create a new user with linked accounts. Optionally pre-generate embedded wallets for the user.

Examples:

Create a user from an email address

client.users.create(user_create_params: {
  linked_accounts: [{address: "tom.bombadill@privy.io", type: :email}]
})

Create a user with custom metadata and a pregenerated Ethereum wallet

client.users.create(user_create_params: {
  linked_accounts: [{address: "tom.bombadill@privy.io", type: :email}],
  custom_metadata: {plan: "pro"},
  wallets: [{chain_type: :ethereum}]
})

Parameters:

  • user_create_params (Hash)

    Body parameters for user creation.

  • request_options (Privy::RequestOptions, Hash, nil) (defaults to: nil)

    Transport-level config (timeouts, retries).

Options Hash (user_create_params:):

  • :linked_accounts (Array<Hash>)

    Linked accounts to associate with the user (required).

  • :custom_metadata (Hash{Symbol=>String, Float, Boolean}, nil)

    Custom metadata associated with the user.

  • :wallets (Array<Hash>, nil)

    Wallets to pregenerate for the user.

Returns:



35
36
37
# File 'lib/privy/public_api/services/users.rb', line 35

def create(user_create_params:, request_options: nil)
  super(user_create_params.merge(request_options: request_options))
end