/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.2
 * Contact: contact@orvanta.cloud
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FlowConversationMessage {
    /// Unique identifier for the message
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// The conversation this message belongs to
    #[serde(rename = "conversation_id")]
    pub conversation_id: uuid::Uuid,
    /// Type of the message
    #[serde(rename = "message_type")]
    pub message_type: MessageType,
    /// The message content
    #[serde(rename = "content")]
    pub content: String,
    /// Associated job ID if this message came from a flow run
    #[serde(rename = "job_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub job_id: Option<Option<uuid::Uuid>>,
    /// When the message was created
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Monotonic cursor assigned when the message is inserted
    #[serde(rename = "created_seq")]
    pub created_seq: i64,
    /// The step name that produced that message
    #[serde(rename = "step_name", skip_serializing_if = "Option::is_none")]
    pub step_name: Option<String>,
    /// Whether the message is a success
    #[serde(rename = "success", skip_serializing_if = "Option::is_none")]
    pub success: Option<bool>,
}

impl FlowConversationMessage {
    pub fn new(id: uuid::Uuid, conversation_id: uuid::Uuid, message_type: MessageType, content: String, created_at: String, created_seq: i64) -> FlowConversationMessage {
        FlowConversationMessage {
            id,
            conversation_id,
            message_type,
            content,
            job_id: None,
            created_at,
            created_seq,
            step_name: None,
            success: None,
        }
    }
}
/// Type of the message
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum MessageType {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "assistant")]
    Assistant,
    #[serde(rename = "system")]
    System,
    #[serde(rename = "tool")]
    Tool,
}

impl Default for MessageType {
    fn default() -> MessageType {
        Self::User
    }
}

