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

/// TaskGroupItem : Collection of workflow tasks grouped together in the thread.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TaskGroupItem {
    /// Identifier of the thread item.
    #[serde(rename = "id")]
    pub id: String,
    /// Type discriminator that is always `chatkit.thread_item`.
    #[serde(rename = "object")]
    pub object: Object,
    /// Unix timestamp (in seconds) for when the item was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// Identifier of the parent thread.
    #[serde(rename = "thread_id")]
    pub thread_id: String,
    /// Type discriminator that is always `chatkit.task_group`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Tasks included in the group.
    #[serde(rename = "tasks")]
    pub tasks: Vec<models::TaskGroupTask>,
}

impl TaskGroupItem {
    /// Collection of workflow tasks grouped together in the thread.
    pub fn new(
        id: String,
        object: Object,
        created_at: i32,
        thread_id: String,
        r#type: Type,
        tasks: Vec<models::TaskGroupTask>,
    ) -> TaskGroupItem {
        TaskGroupItem {
            id,
            object,
            created_at,
            thread_id,
            r#type,
            tasks,
        }
    }
}
/// Type discriminator that is always `chatkit.thread_item`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "chatkit.thread_item")]
    ChatkitThreadItem,
}

impl Default for Object {
    fn default() -> Object {
        Self::ChatkitThreadItem
    }
}
/// Type discriminator that is always `chatkit.task_group`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "chatkit.task_group")]
    ChatkitTaskGroup,
}

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

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