1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use uuid::Uuid;
6use validator::Validate;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
10pub struct RegisterRequest {
11 #[validate(email)]
12 pub email: String,
13 #[validate(length(min = 6))]
14 pub password: String,
15 #[validate(length(min = 1))]
16 pub username: String,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
21pub struct LoginRequest {
22 pub email: String,
23 #[validate(length(min = 6))]
24 pub password: String,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct LoginResponse {
30 pub token: String,
31 pub user_id: String,
32 pub username: String,
33 pub email: String,
34 pub tier: String,
35 pub expires_in_secs: u64,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
40pub struct SearchRequest {
41 pub query: String,
42 #[validate(range(min = 1, max = 100))]
43 pub limit: Option<u32>,
44 pub offset: Option<u32>,
45 pub category: Option<String>,
46 pub sort_by: Option<String>, }
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct PackageResult {
52 pub id: String,
53 pub name: String,
54 pub version: String,
55 pub author: String,
56 pub description: String,
57 pub downloads: u64,
58 pub price: Option<f64>,
59 pub license: String,
60 pub rating: f32,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct PurchaseRequest {
66 pub package_id: String,
67 pub version: String,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct PurchaseResponse {
73 pub transaction_id: String,
74 pub package_id: String,
75 pub price: f64,
76 pub status: String, pub payment_url: Option<String>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
82pub struct CreateApiKeyRequest {
83 #[validate(length(min = 1))]
84 pub name: String,
85 pub expires_in_days: Option<u32>,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90pub struct ApiKeyResponse {
91 pub id: String,
92 pub key: String, pub name: String,
94 pub created_at: DateTime<Utc>,
95 pub expires_at: Option<DateTime<Utc>>,
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100pub struct UsageRequest {
101 pub operation: String, pub cost_credits: u32,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
107pub struct UsageStatsResponse {
108 pub user_id: String,
109 pub tier: String,
110 pub period_start: DateTime<Utc>,
111 pub period_end: DateTime<Utc>,
112 pub api_calls_used: u64,
113 pub api_calls_limit: u64,
114 pub templates_used: u64,
115 pub templates_limit: u64,
116 pub total_credits_used: u64,
117 pub total_credits_available: u64,
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct InvoiceResponse {
123 pub invoice_id: String,
124 pub user_id: String,
125 pub amount: f64,
126 pub currency: String,
127 pub status: String, pub issued_at: DateTime<Utc>,
129 pub due_at: DateTime<Utc>,
130 pub items: Vec<InvoiceItem>,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135pub struct InvoiceItem {
136 pub description: String,
137 pub quantity: u32,
138 pub unit_price: f64,
139 pub total: f64,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize, Validate)]
144pub struct UpgradeRequest {
145 pub new_tier: String, }
147
148#[derive(Debug, Clone, Serialize, Deserialize)]
150pub struct HealthResponse {
151 pub status: String,
152 pub timestamp: DateTime<Utc>,
153 pub version: String,
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize)]
158pub struct PaginatedResponse<T> {
159 pub data: Vec<T>,
160 pub total: u64,
161 pub limit: u32,
162 pub offset: u32,
163}
164
165#[derive(Debug, Clone, Serialize, Deserialize)]
167pub struct ErrorResponse {
168 pub error: String,
169 pub status: u16,
170 pub timestamp: DateTime<Utc>,
171}