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

/// RealtimeBetaServerEventErrorError : Details of the error.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeBetaServerEventErrorError {
    /// The type of error (e.g., \"invalid_request_error\", \"server_error\").
    #[serde(rename = "type")]
    pub r#type: String,
    /// Error code, if any.
    #[serde(
        rename = "code",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub code: Option<Option<String>>,
    /// A human-readable error message.
    #[serde(rename = "message")]
    pub message: String,
    /// Parameter related to the error, if any.
    #[serde(
        rename = "param",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub param: Option<Option<String>>,
    /// The event_id of the client event that caused the error, if applicable.
    #[serde(
        rename = "event_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub event_id: Option<Option<String>>,
}

impl RealtimeBetaServerEventErrorError {
    /// Details of the error.
    pub fn new(r#type: String, message: String) -> RealtimeBetaServerEventErrorError {
        RealtimeBetaServerEventErrorError {
            r#type,
            code: None,
            message,
            param: None,
            event_id: None,
        }
    }
}

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