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};

/// ProjectUser : Represents an individual user in a project.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ProjectUser {
    /// The object type, which is always `organization.project.user`
    #[serde(rename = "object")]
    pub object: Object,
    /// The identifier, which can be referenced in API endpoints
    #[serde(rename = "id")]
    pub id: String,
    #[serde(
        rename = "name",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub name: Option<Option<String>>,
    #[serde(
        rename = "email",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub email: Option<Option<String>>,
    /// `owner` or `member`
    #[serde(rename = "role")]
    pub role: String,
    /// The Unix timestamp (in seconds) of when the project was added.
    #[serde(rename = "added_at")]
    pub added_at: i32,
}

impl ProjectUser {
    /// Represents an individual user in a project.
    pub fn new(object: Object, id: String, role: String, added_at: i32) -> ProjectUser {
        ProjectUser {
            object,
            id,
            name: None,
            email: None,
            role,
            added_at,
        }
    }
}
/// The object type, which is always `organization.project.user`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.project.user")]
    OrganizationProjectUser,
}

impl Default for Object {
    fn default() -> Object {
        Self::OrganizationProjectUser
    }
}

impl std::fmt::Display for ProjectUser {
    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),
        }
    }
}