openai-client-base 0.13.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// GroupMemberUser : Details about a user returned from an organization group membership lookup.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct GroupMemberUser {
    /// Identifier for the user.
    #[serde(rename = "id")]
    pub id: String,
    /// Display name of the user.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "email", deserialize_with = "Option::deserialize")]
    pub email: Option<String>,
    #[serde(rename = "picture", deserialize_with = "Option::deserialize")]
    pub picture: Option<String>,
    #[serde(
        rename = "is_service_account",
        deserialize_with = "Option::deserialize"
    )]
    pub is_service_account: Option<bool>,
    /// The type of user.
    #[serde(rename = "user_type")]
    pub user_type: UserType,
}

impl GroupMemberUser {
    /// Details about a user returned from an organization group membership lookup.
    pub fn new(
        id: String,
        name: String,
        email: Option<String>,
        picture: Option<String>,
        is_service_account: Option<bool>,
        user_type: UserType,
    ) -> GroupMemberUser {
        GroupMemberUser {
            id,
            name,
            email,
            picture,
            is_service_account,
            user_type,
        }
    }
}
/// The type of user.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum UserType {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "tenant_user")]
    TenantUser,
}

impl Default for UserType {
    fn default() -> UserType {
        Self::User
    }
}

impl std::fmt::Display for GroupMemberUser {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match serde_json::to_string(self) {
            Ok(s) => write!(f, "{}", s),
            Err(_) => Err(std::fmt::Error),
        }
    }
}