1use std::collections::BTreeMap as Map;
2use serde::Deserialize;
3use serde_json::Value;
4
5pub(crate) const BASE_URL: &'static str = "https://api.dogegarden.net/v1";
6
7#[async_trait::async_trait]
8pub trait Endpoint {
10 type Scheme;
12 async fn send() -> Result<Self::Scheme, crate::ErrorType>;
14}
15
16crate::endpoint!(
17 #[doc = "This defines the binding for the /statistics endpoint in the API."]
18 Statistics,
19 StatisticsScheme,
20 "/statistics"
21);
22
23#[derive(Deserialize, PartialEq, Clone, Debug)]
24#[serde(rename_all = "camelCase")]
25pub struct StatisticsScheme {
27 total_rooms: u64,
28 total_scheduled_rooms: u64,
29 total_registered: u64,
30 total_online: u64,
31 total_bots_online: u64,
32 total_bots_sending_telemetry: u64,
33}
34
35crate::endpoint!(
36 #[doc = "This defines the binding for the /popularRooms endpoint in the API."]
37 PopularRooms,
38 PopularRoomsScheme,
39 "/popularRooms"
40);
41
42#[derive(Deserialize, PartialEq, Clone, Debug)]
43#[serde(rename_all = "camelCase")]
44pub struct PopularRoomsScheme {
46 rooms: Vec<PopularRoom>,
47 #[serde(flatten)]
48 undocumented: Map<String, Value>,
50}
51
52#[derive(Deserialize, PartialEq, Clone, Debug)]
53#[serde(rename_all = "camelCase")]
54pub struct PopularRoom {
56 id: String,
57 name: String,
58 description: String,
59 num_people_inside: u64,
60 is_private: bool,
61 chat_mode: String,
63 chat_throttle: u64,
65 auto_speaker: bool,
67 creator_id: String,
68 people_preview_list: Vec<PopularRoomUser>,
69 voice_server_id: String,
70 #[serde(rename = "inserted_at")]
72 inserted_at: String,
73}
74
75#[derive(Deserialize, PartialEq, Clone, Debug)]
76#[serde(rename_all = "camelCase")]
77pub struct PopularRoomUser {
79 id: String,
80 display_name: String,
81 num_followers: u64,
82 avatar_url: String,
83}
84
85crate::endpoint!(
86 #[doc = "This defines the binding for the /bots endpoint in the API."]
87 Bots,
88 Vec<Bot>,
89 "/bots"
90);
91
92#[derive(Deserialize, PartialEq, Clone, Debug)]
93#[serde(rename_all = "camelCase")]
94pub struct Bot {
96 #[serde(rename = "_id")]
97 id: String,
98 #[serde(rename = "socket_id")]
99 socket_id: String,
100 bot: BotInner,
101 room: Map<String, Value>,
104}
105
106#[derive(Deserialize, PartialEq, Clone, Debug)]
107#[serde(rename_all = "camelCase")]
108pub struct BotInner {
110 uuid: String,
111 username: String,
112 avatar: String,
113}
114
115#[derive(Deserialize, PartialEq, Clone, Debug)]
116#[serde(rename_all = "camelCase")]
117pub struct BotRoom {
119 uuid: Value,
121 name: String,
122 listening: u64,
123 users: Vec<Value>,
125}
126
127crate::endpoint!(
128 #[doc = "This defines the binding for the /scheduledRooms endpoint in the API."]
129 ScheduledRooms,
130 ScheduledRoomsScheme,
131 "/scheduledRooms"
132);
133
134#[derive(Deserialize, PartialEq, Clone, Debug)]
135#[serde(rename_all = "camelCase")]
136pub struct ScheduledRoomsScheme {
138 scheduled_rooms: Vec<ScheduledRoom>,
139}
140
141#[derive(Deserialize, PartialEq, Clone, Debug)]
142#[serde(rename_all = "camelCase")]
143pub struct ScheduledRoom {
145 id: String,
146 name: String,
147 num_attending: u64,
148 scheduled_for: String,
149 description: String,
150 room_id: Value,
152 creator: User,
153 creator_id: String,
154}
155
156
157#[derive(Deserialize, PartialEq, Clone, Debug)]
158#[serde(rename_all = "camelCase")]
159pub struct User {
162 avatar_url: Option<String>,
163 banner_url: Option<String>,
164 bio: String,
165 bot_owner_id: Value,
167 display_name: String,
168 follows_you: Value,
170 i_blocked_them: Value,
172 id: String,
173 last_online: String,
174 num_followers: u64,
175 num_following: u64,
176 online: bool,
177 room_permissions: Value,
179 username: String,
180 whisper_privacy_setting: String,
182 you_are_following: Value,
184}