From e1e6ad0e95aaddc200b5a387521d334996b87281 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Tue, 9 Jul 2024 13:01:20 +0800 Subject: [PATCH] chore: add from trait for subscription plan --- libs/shared-entity/src/dto/billing_dto.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libs/shared-entity/src/dto/billing_dto.rs b/libs/shared-entity/src/dto/billing_dto.rs index 35b26ab9..74c3309f 100644 --- a/libs/shared-entity/src/dto/billing_dto.rs +++ b/libs/shared-entity/src/dto/billing_dto.rs @@ -30,6 +30,19 @@ pub enum SubscriptionPlan { AiLocal = 4, } +impl From for SubscriptionPlan { + fn from(value: i16) -> Self { + match value { + 0 => SubscriptionPlan::Free, + 1 => SubscriptionPlan::Pro, + 2 => SubscriptionPlan::Team, + 3 => SubscriptionPlan::AiMax, + 4 => SubscriptionPlan::AiLocal, + _ => SubscriptionPlan::Unknown, + } + } +} + impl AsRef for SubscriptionPlan { fn as_ref(&self) -> &str { match self {