claw_spawn/domain/
account.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
6pub struct Account {
7 pub id: Uuid,
8 pub external_id: String,
9 pub subscription_tier: SubscriptionTier,
10 pub max_bots: i32,
11 pub created_at: DateTime<Utc>,
12 pub updated_at: DateTime<Utc>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
16pub enum SubscriptionTier {
17 Free,
18 Basic,
19 Pro,
20}
21
22impl Account {
23 pub fn new(external_id: String, tier: SubscriptionTier) -> Self {
24 let now = Utc::now();
25 let max_bots = match tier {
26 SubscriptionTier::Free => 0,
27 SubscriptionTier::Basic => 2,
28 SubscriptionTier::Pro => 4,
29 };
30
31 Self {
32 id: Uuid::new_v4(),
33 external_id,
34 subscription_tier: tier,
35 max_bots,
36 created_at: now,
37 updated_at: now,
38 }
39 }
40}