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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ConversationResource {
    /// The unique ID of the conversation.
    #[serde(rename = "id")]
    pub id: String,
    /// The object type, which is always `conversation`.
    #[serde(rename = "object")]
    pub object: Object,
    #[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
    pub metadata: Option<serde_json::Value>,
    /// The time at which the conversation was created, measured in seconds since the Unix epoch.
    #[serde(rename = "created_at")]
    pub created_at: i32,
}

impl ConversationResource {
    pub fn new(
        id: String,
        object: Object,
        metadata: Option<serde_json::Value>,
        created_at: i32,
    ) -> ConversationResource {
        ConversationResource {
            id,
            object,
            metadata,
            created_at,
        }
    }
}
/// The object type, which is always `conversation`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "conversation")]
    Conversation,
}

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

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