clerk_fapi_rs/models/
client_user.rs

1/*
2 * Clerk Frontend API
3 *
4 * The Clerk REST Frontend API, meant to be accessed from a browser or native environment.  This is a Form Based API and all the data must be sent and formatted according to the `application/x-www-form-urlencoded` content type.  ### Versions  When the API changes in a way that isn't compatible with older versions, a new version is released. Each version is identified by its release date, e.g. `2021-02-05`. For more information, please see [Clerk API Versions](https://clerk.com/docs/backend-requests/versioning/overview).  ### Using the Try It Console  The `Try It` feature of the docs only works for **Development Instances** when using the `DevBrowser` security scheme. To use it, first generate a dev instance token from the `/v1/dev_browser` endpoint.  Please see https://clerk.com/docs for more information.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: support@clerk.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ClientUser {
16    #[serde(rename = "id")]
17    pub id: String,
18    /// String representing the object's type. Objects of the same type share the same value.
19    #[serde(rename = "object")]
20    pub object: Object,
21    #[serde(rename = "username", deserialize_with = "Option::deserialize")]
22    pub username: Option<String>,
23    #[serde(rename = "first_name", deserialize_with = "Option::deserialize")]
24    pub first_name: Option<String>,
25    #[serde(rename = "last_name", deserialize_with = "Option::deserialize")]
26    pub last_name: Option<String>,
27    #[serde(rename = "image_url", skip_serializing_if = "Option::is_none")]
28    pub image_url: Option<String>,
29    #[serde(rename = "has_image")]
30    pub has_image: bool,
31    #[serde(
32        rename = "primary_email_address_id",
33        deserialize_with = "Option::deserialize"
34    )]
35    pub primary_email_address_id: Option<String>,
36    #[serde(
37        rename = "primary_phone_number_id",
38        deserialize_with = "Option::deserialize"
39    )]
40    pub primary_phone_number_id: Option<String>,
41    #[serde(
42        rename = "primary_web3_wallet_id",
43        deserialize_with = "Option::deserialize"
44    )]
45    pub primary_web3_wallet_id: Option<String>,
46    #[serde(rename = "password_enabled")]
47    pub password_enabled: bool,
48    #[serde(rename = "two_factor_enabled")]
49    pub two_factor_enabled: bool,
50    #[serde(rename = "totp_enabled")]
51    pub totp_enabled: bool,
52    #[serde(rename = "backup_code_enabled")]
53    pub backup_code_enabled: bool,
54    #[serde(rename = "email_addresses")]
55    pub email_addresses: Vec<models::ClientEmailAddress>,
56    #[serde(rename = "phone_numbers")]
57    pub phone_numbers: Vec<models::ClientPhoneNumber>,
58    #[serde(rename = "web3_wallets")]
59    pub web3_wallets: Vec<models::ClientWeb3Wallet>,
60    #[serde(rename = "passkeys")]
61    pub passkeys: Vec<models::ClientPasskey>,
62    #[serde(
63        rename = "organization_memberships",
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub organization_memberships: Option<Vec<models::ClientOrganizationMembership>>,
67    #[serde(rename = "external_accounts")]
68    pub external_accounts: Vec<models::ExternalAccountWithVerification>,
69    #[serde(rename = "saml_accounts")]
70    pub saml_accounts: Vec<models::ClientSamlAccount>,
71    /// Unix timestamp of last update.
72    #[serde(
73        rename = "password_last_updated_at",
74        default,
75        with = "::serde_with::rust::double_option",
76        skip_serializing_if = "Option::is_none"
77    )]
78    pub password_last_updated_at: Option<Option<i64>>,
79    #[serde(rename = "public_metadata")]
80    pub public_metadata: std::collections::HashMap<String, serde_json::Value>,
81    #[serde(rename = "private_metadata", skip_serializing_if = "Option::is_none")]
82    pub private_metadata: Option<std::collections::HashMap<String, serde_json::Value>>,
83    #[serde(rename = "unsafe_metadata", skip_serializing_if = "Option::is_none")]
84    pub unsafe_metadata: Option<std::collections::HashMap<String, serde_json::Value>>,
85    #[serde(rename = "external_id", deserialize_with = "Option::deserialize")]
86    pub external_id: Option<String>,
87    /// Unix timestamp of last sign-in.
88    #[serde(rename = "last_sign_in_at", deserialize_with = "Option::deserialize")]
89    pub last_sign_in_at: Option<i64>,
90    /// Flag to denote whether user is banned or not.
91    #[serde(rename = "banned")]
92    pub banned: bool,
93    /// Flag to denote whether user is currently locked, i.e. restricted from signing in or not.
94    #[serde(rename = "locked")]
95    pub locked: bool,
96    /// The number of seconds remaining until the lockout period expires for a locked user. A null value for a locked user indicates that lockout never expires.
97    #[serde(
98        rename = "lockout_expires_in_seconds",
99        deserialize_with = "Option::deserialize"
100    )]
101    pub lockout_expires_in_seconds: Option<i64>,
102    /// The number of verification attempts remaining until the user is locked. Null if account lockout is not enabled. Note: if a user is locked explicitly via the Backend API, they may still have verification attempts remaining.
103    #[serde(
104        rename = "verification_attempts_remaining",
105        deserialize_with = "Option::deserialize"
106    )]
107    pub verification_attempts_remaining: Option<i64>,
108    /// Unix timestamp of creation.
109    #[serde(rename = "created_at")]
110    pub created_at: i64,
111    /// Unix timestamp of last update.
112    #[serde(rename = "updated_at")]
113    pub updated_at: i64,
114    /// If enabled, user can delete themselves via FAPI.
115    #[serde(rename = "delete_self_enabled")]
116    pub delete_self_enabled: bool,
117    /// If enabled, user can create organizations via FAPI.
118    #[serde(rename = "create_organization_enabled")]
119    pub create_organization_enabled: bool,
120    /// The maximum number of organizations the user can create. 0 means unlimited.
121    #[serde(
122        rename = "create_organizations_limit",
123        skip_serializing_if = "Option::is_none"
124    )]
125    pub create_organizations_limit: Option<i64>,
126    /// Unix timestamp of the latest session activity, with day precision.
127    #[serde(rename = "last_active_at", deserialize_with = "Option::deserialize")]
128    pub last_active_at: Option<i64>,
129    /// Unix timestamp at which the user enabled MFA.
130    #[serde(rename = "mfa_enabled_at", deserialize_with = "Option::deserialize")]
131    pub mfa_enabled_at: Option<i64>,
132    /// Unix timestamp at which the user disabled MFA.
133    #[serde(rename = "mfa_disabled_at", deserialize_with = "Option::deserialize")]
134    pub mfa_disabled_at: Option<i64>,
135    /// Unix timestamp at which the user accepted the legal requirements.
136    #[serde(rename = "legal_accepted_at", deserialize_with = "Option::deserialize")]
137    pub legal_accepted_at: Option<i64>,
138    /// Deprecated. Use `image_url` instead.
139    #[serde(rename = "profile_image_url", skip_serializing_if = "Option::is_none")]
140    pub profile_image_url: Option<String>,
141}
142
143impl ClientUser {
144    pub fn new(
145        id: String,
146        object: Object,
147        username: Option<String>,
148        first_name: Option<String>,
149        last_name: Option<String>,
150        has_image: bool,
151        primary_email_address_id: Option<String>,
152        primary_phone_number_id: Option<String>,
153        primary_web3_wallet_id: Option<String>,
154        password_enabled: bool,
155        two_factor_enabled: bool,
156        totp_enabled: bool,
157        backup_code_enabled: bool,
158        email_addresses: Vec<models::ClientEmailAddress>,
159        phone_numbers: Vec<models::ClientPhoneNumber>,
160        web3_wallets: Vec<models::ClientWeb3Wallet>,
161        passkeys: Vec<models::ClientPasskey>,
162        external_accounts: Vec<models::ExternalAccountWithVerification>,
163        saml_accounts: Vec<models::ClientSamlAccount>,
164        public_metadata: std::collections::HashMap<String, serde_json::Value>,
165        external_id: Option<String>,
166        last_sign_in_at: Option<i64>,
167        banned: bool,
168        locked: bool,
169        lockout_expires_in_seconds: Option<i64>,
170        verification_attempts_remaining: Option<i64>,
171        created_at: i64,
172        updated_at: i64,
173        delete_self_enabled: bool,
174        create_organization_enabled: bool,
175        last_active_at: Option<i64>,
176        mfa_enabled_at: Option<i64>,
177        mfa_disabled_at: Option<i64>,
178        legal_accepted_at: Option<i64>,
179    ) -> ClientUser {
180        ClientUser {
181            id,
182            object,
183            username,
184            first_name,
185            last_name,
186            image_url: None,
187            has_image,
188            primary_email_address_id,
189            primary_phone_number_id,
190            primary_web3_wallet_id,
191            password_enabled,
192            two_factor_enabled,
193            totp_enabled,
194            backup_code_enabled,
195            email_addresses,
196            phone_numbers,
197            web3_wallets,
198            passkeys,
199            organization_memberships: None,
200            external_accounts,
201            saml_accounts,
202            password_last_updated_at: None,
203            public_metadata,
204            private_metadata: None,
205            unsafe_metadata: None,
206            external_id,
207            last_sign_in_at,
208            banned,
209            locked,
210            lockout_expires_in_seconds,
211            verification_attempts_remaining,
212            created_at,
213            updated_at,
214            delete_self_enabled,
215            create_organization_enabled,
216            create_organizations_limit: None,
217            last_active_at,
218            mfa_enabled_at,
219            mfa_disabled_at,
220            legal_accepted_at,
221            profile_image_url: None,
222        }
223    }
224}
225/// String representing the object's type. Objects of the same type share the same value.
226#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
227pub enum Object {
228    #[serde(rename = "user")]
229    User,
230}
231
232impl Default for Object {
233    fn default() -> Object {
234        Self::User
235    }
236}