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

/// LiveDecisionEvent : A Decision API event for a Live delegation or transcript trigger. For a trigger, source_event_id identifies the transcript delta that caused this evaluation.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LiveDecisionEvent {
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of this Live server event.
    #[serde(rename = "event_id")]
    pub event_id: String,
    /// The Live delegation ID, or null for a transcript trigger.
    #[serde(rename = "delegation_id", deserialize_with = "Option::deserialize")]
    pub delegation_id: Option<String>,
    /// The Live-assigned ID of this trigger firing, or null for a delegation.
    #[serde(rename = "trigger_id", deserialize_with = "Option::deserialize")]
    pub trigger_id: Option<String>,
    #[serde(rename = "source_event_type", deserialize_with = "Option::deserialize")]
    pub source_event_type: Option<Box<models::LiveDecisionEventSourceEventType>>,
    /// The event_id of the transcript delta that fired this trigger, or null for a delegation.
    #[serde(rename = "source_event_id", deserialize_with = "Option::deserialize")]
    pub source_event_id: Option<String>,
    #[serde(rename = "event")]
    pub event: Box<models::LiveDecisionCompleted>,
}

impl LiveDecisionEvent {
    /// A Decision API event for a Live delegation or transcript trigger. For a trigger, source_event_id identifies the transcript delta that caused this evaluation.
    pub fn new(
        r#type: Type,
        event_id: String,
        delegation_id: Option<String>,
        trigger_id: Option<String>,
        source_event_type: Option<models::LiveDecisionEventSourceEventType>,
        source_event_id: Option<String>,
        event: models::LiveDecisionCompleted,
    ) -> LiveDecisionEvent {
        LiveDecisionEvent {
            r#type,
            event_id,
            delegation_id,
            trigger_id,
            source_event_type: source_event_type.map(Box::new),
            source_event_id,
            event: Box::new(event),
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "decision.event")]
    DecisionEvent,
}

impl Default for Type {
    fn default() -> Type {
        Self::DecisionEvent
    }
}

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