propelauth 0.23.3

A Rust crate for managing authentication and authorization with support for multi-tenant / B2B products, powered by PropelAuth
Documentation
/*
 * propelauth
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 0.1.0
 *
 * Generated by: https://openapi-generator.tech
 */

use std::collections::HashMap;

use serde_json::Value;

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct UserMetadata {
    #[serde(rename = "user_id")]
    pub user_id: String,
    #[serde(rename = "email")]
    pub email: String,
    #[serde(rename = "email_confirmed")]
    pub email_confirmed: bool,
    #[serde(rename = "has_password")]
    pub has_password: bool,
    #[serde(rename = "username", skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(rename = "first_name", skip_serializing_if = "Option::is_none")]
    pub first_name: Option<String>,
    #[serde(rename = "last_name", skip_serializing_if = "Option::is_none")]
    pub last_name: Option<String>,
    #[serde(rename = "picture_url", skip_serializing_if = "Option::is_none")]
    pub picture_url: Option<String>,
    #[serde(rename = "locked")]
    pub locked: bool,
    #[serde(rename = "enabled")]
    pub enabled: bool,
    #[serde(rename = "mfa_enabled")]
    pub mfa_enabled: bool,
    #[serde(rename = "created_at")]
    pub created_at: i64,
    #[serde(rename = "last_active_at")]
    pub last_active_at: i64,
    #[serde(rename = "org_id_to_org_info", skip_serializing_if = "Option::is_none")]
    pub org_id_to_org_info: Option<HashMap<String, crate::models::UserInOrg>>,
    #[serde(rename = "legacy_user_id", skip_serializing_if = "Option::is_none")]
    pub legacy_user_id: Option<String>,
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<HashMap<String, Value>>,
    #[serde(rename = "properties", skip_serializing_if = "Option::is_none")]
    pub properties: Option<HashMap<String, Value>>,
    /// `role_in_org` is only returned when using `fetch_users_in_org`
    /// and is their role for the org specified in the query.
    #[serde(rename = "role_in_org", default)]
    pub role_in_org: Option<String>,
    /// `additional_roles_in_org` is only returned when using `fetch_users_in_org`
    /// and is their additional roles for the org specified in the query.
    #[serde(rename = "additional_roles_in_org", default)]
    pub additional_roles_in_org: Option<Vec<String>>,
}

impl UserMetadata {
    pub fn new(
        user_id: String,
        email: String,
        email_confirmed: bool,
        has_password: bool,
        locked: bool,
        enabled: bool,
        mfa_enabled: bool,
        created_at: i64,
        last_active_at: i64,
    ) -> UserMetadata {
        UserMetadata {
            user_id,
            email,
            email_confirmed,
            has_password,
            username: None,
            first_name: None,
            last_name: None,
            picture_url: None,
            locked,
            enabled,
            mfa_enabled,
            created_at,
            last_active_at,
            org_id_to_org_info: None,
            legacy_user_id: None,
            metadata: None,
            properties: None,
            role_in_org: None,
            additional_roles_in_org: None,
        }
    }
}