Skip to main content

auth0_integration/models/
create_user_request.rs

1use serde::Serialize;
2
3#[derive(Serialize)]
4pub struct CreateUserRequest<'a> {
5    pub connection: &'a str,
6    pub email: &'a str,
7    pub name: &'a str,
8}
9
10impl<'a> CreateUserRequest<'a> {
11    /// Creates a new `CreateUserRequest` for Auth0's `POST /api/v2/users` endpoint.
12    ///
13    /// # Parameters
14    ///
15    /// | Parameter    | Type    | Description                                                                                   |
16    /// |--------------|---------|-----------------------------------------------------------------------------------------------|
17    /// | `connection` | `&str`  | The Auth0 connection to create the user in (e.g. `"Username-Password-Authentication"`)        |
18    /// | `email`      | `&str`  | The user's email address                                                                      |
19    /// | `name`       | `&str`  | The user's full display name                                                                  |
20    ///
21    /// # Example
22    ///
23    /// ```rust
24    /// use auth0_integration::models::CreateUserRequest;
25    ///
26    /// let req = CreateUserRequest::new(
27    ///     "Username-Password-Authentication",
28    ///     "jane@example.com",
29    ///     "Jane Doe",
30    /// );
31    /// ```
32    pub fn new(connection: &'a str, email: &'a str, name: &'a str) -> Self {
33        Self { connection, email, name }
34    }
35}