ore_types/
response.rs

1use serde::{Deserialize, Serialize};
2
3/// Response for a successful login, containing the JWT.
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct AuthResponse {
6    pub token: String,
7}
8
9/// Response after successfully sending a chat message.
10#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
11pub struct ChatSendMessageResponse {
12    pub status: String,
13    pub message: String,
14}
15
16#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
17pub struct User {
18    pub authority: String,
19    pub username: String,
20}
21
22// Notifications
23
24#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
25pub struct ChatNotification {
26    pub authority: String,
27    pub username: String,
28    pub text: String,
29    pub id: u64,
30    pub ts: i64,
31}
32
33#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
34pub struct ResetNotification {
35    pub block_id: u64,
36}
37
38#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
39pub enum Notification {
40    Chat(ChatNotification),
41    Reset(ResetNotification),
42}
43
44impl Notification {
45    pub fn id(&self) -> String {
46        match self {
47            Notification::Chat(chat) => chat.id.to_string(),
48            Notification::Reset(reset) => reset.block_id.to_string(),
49        }
50    }
51}
52
53#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
54pub struct DailyRevenue {
55    pub day: String,
56    pub revenue: i64,
57}
58
59// Username validation
60
61#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
62pub struct UsernameValidationResponse {
63    pub valid: bool,
64    pub error: Option<String>,
65}
66
67impl UsernameValidationResponse {
68    pub fn valid() -> Self {
69        Self {
70            valid: true,
71            error: None,
72        }
73    }
74
75    pub fn invalid(error: String) -> Self {
76        Self {
77            valid: false,
78            error: Some(error),
79        }
80    }
81}