openai-client-base 0.12.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};

/// Invite : Represents an individual `invite` to the organization.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct Invite {
    /// The object type, which is always `organization.invite`
    #[serde(rename = "object")]
    pub object: Object,
    /// The identifier, which can be referenced in API endpoints
    #[serde(rename = "id")]
    pub id: String,
    /// The email address of the individual to whom the invite was sent
    #[serde(rename = "email")]
    pub email: String,
    /// `owner` or `reader`
    #[serde(rename = "role")]
    pub role: Role,
    /// `accepted`,`expired`, or `pending`
    #[serde(rename = "status")]
    pub status: Status,
    /// The Unix timestamp (in seconds) of when the invite was sent.
    #[serde(rename = "invited_at")]
    pub invited_at: i32,
    /// The Unix timestamp (in seconds) of when the invite expires.
    #[serde(rename = "expires_at")]
    pub expires_at: i32,
    /// The Unix timestamp (in seconds) of when the invite was accepted.
    #[serde(rename = "accepted_at", skip_serializing_if = "Option::is_none")]
    pub accepted_at: Option<i32>,
    /// The projects that were granted membership upon acceptance of the invite.
    #[serde(rename = "projects", skip_serializing_if = "Option::is_none")]
    pub projects: Option<Vec<models::InviteProjectsInner>>,
}

impl Invite {
    /// Represents an individual `invite` to the organization.
    pub fn new(
        object: Object,
        id: String,
        email: String,
        role: Role,
        status: Status,
        invited_at: i32,
        expires_at: i32,
    ) -> Invite {
        Invite {
            object,
            id,
            email,
            role,
            status,
            invited_at,
            expires_at,
            accepted_at: None,
            projects: None,
        }
    }
}
/// The object type, which is always `organization.invite`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "organization.invite")]
    OrganizationInvite,
}

impl Default for Object {
    fn default() -> Object {
        Self::OrganizationInvite
    }
}
/// `owner` or `reader`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "owner")]
    Owner,
    #[serde(rename = "reader")]
    Reader,
}

impl Default for Role {
    fn default() -> Role {
        Self::Owner
    }
}
/// `accepted`,`expired`, or `pending`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "accepted")]
    Accepted,
    #[serde(rename = "expired")]
    Expired,
    #[serde(rename = "pending")]
    Pending,
}

impl Default for Status {
    fn default() -> Status {
        Self::Accepted
    }
}

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