diff --git a/libs/shared-entity/src/dto/billing_dto.rs b/libs/shared-entity/src/dto/billing_dto.rs index b5942c14..1ce62c49 100644 --- a/libs/shared-entity/src/dto/billing_dto.rs +++ b/libs/shared-entity/src/dto/billing_dto.rs @@ -67,6 +67,21 @@ impl AsRef for SubscriptionPlan { } } +impl TryFrom<&str> for SubscriptionPlan { + type Error = String; + + fn try_from(value: &str) -> Result { + match value { + "free" => Ok(SubscriptionPlan::Free), + "pro" => Ok(SubscriptionPlan::Pro), + "team" => Ok(SubscriptionPlan::Team), + "ai_max" => Ok(SubscriptionPlan::AiMax), + "ai_local" => Ok(SubscriptionPlan::AiLocal), + _ => Err(format!("Invalid SubscriptionPlan value: {}", value)), + } + } +} + #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] pub enum SubscriptionStatus {