use crate::{DateTimeUtc, ModelVersionId};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

use super::PricingCurrency;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "ai_model_pricing")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub model_version_id: ModelVersionId,
    pub input_price_per_1k_tokens: String,
    pub output_price_per_1k_tokens: String,
    pub currency: String,
    pub effective_from: DateTimeUtc,
}

impl Model {
    pub fn currency_enum(&self) -> Result<PricingCurrency, &'static str> {
        self.currency.parse()
    }
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
