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    pub profile_photo_url: Option<String>,
21}
22
23// Notifications
24
25#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
26pub struct ChatNotification {
27    pub authority: String,
28    pub username: String,
29    pub text: String,
30    pub id: u64,
31    pub ts: i64,
32    pub profile_photo_url: Option<String>,
33}
34
35#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
36pub struct ResetNotification {
37    pub block_id: u64,
38}
39
40#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
41pub enum Notification {
42    Chat(ChatNotification),
43    Reset(ResetNotification),
44}
45
46impl Notification {
47    pub fn id(&self) -> String {
48        match self {
49            Notification::Chat(chat) => chat.id.to_string(),
50            Notification::Reset(reset) => reset.block_id.to_string(),
51        }
52    }
53}
54
55#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
56pub struct DailyRevenue {
57    pub day: String,
58    pub revenue: i64,
59}
60
61// Username validation
62
63#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
64pub struct UsernameValidationResponse {
65    pub valid: bool,
66    pub error: Option<String>,
67}
68
69impl UsernameValidationResponse {
70    pub fn valid() -> Self {
71        Self {
72            valid: true,
73            error: None,
74        }
75    }
76
77    pub fn invalid(error: String) -> Self {
78        Self {
79            valid: false,
80            error: Some(error),
81        }
82    }
83}