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

/// WebhookLiveTransportIncomingData : Event data payload.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebhookLiveTransportIncomingData {
    /// The incoming transport type. Always `sip`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The `live_...` ID of the pending SIP session. Forward this value unchanged when accepting or rejecting the call through the Live API.
    #[serde(rename = "session_id")]
    pub session_id: String,
    #[serde(rename = "sip_media_security", skip_serializing_if = "Option::is_none")]
    pub sip_media_security: Option<Box<models::WebhookLiveCallIncomingDataSipMediaSecurity>>,
    /// Headers from the SIP INVITE, excluding SIP authorization headers. Retained names, values, repeated entries, and order are preserved. Treat these values as untrusted call metadata.
    #[serde(rename = "sip_headers")]
    pub sip_headers: Vec<models::WebhookLiveCallIncomingDataSipHeadersInner>,
}

impl WebhookLiveTransportIncomingData {
    /// Event data payload.
    pub fn new(
        r#type: Type,
        session_id: String,
        sip_headers: Vec<models::WebhookLiveCallIncomingDataSipHeadersInner>,
    ) -> WebhookLiveTransportIncomingData {
        WebhookLiveTransportIncomingData {
            r#type,
            session_id,
            sip_media_security: None,
            sip_headers,
        }
    }
}
/// The incoming transport type. Always `sip`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "sip")]
    Sip,
}

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

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