-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi_structs.rs
215 lines (176 loc) · 4.85 KB
/
api_structs.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
pub const ENDPOINT_CREATE_CARD_DECK: &str = "/create_card_deck";
pub const ENDPOINT_DELETE_CARD_DECK: &str = "/delete_card_deck";
pub const ENDPOINT_SET_DECK_ICON: &str = "/set_deck_icon";
pub const ENDPOINT_ADD_RATING: &str = "/add_rating";
pub const ENDPOINT_CREATE_CARD: &str = "/create_card";
pub const ENDPOINT_DELETE_CARD: &str = "/delete_card";
pub const ENDPOINT_EDIT_CARD: &str = "/edit_card";
pub const ENDPOINT_LIST_CARD_DECKS: &str = "/list_card_decks";
pub const ENDPOINT_GET_DECK: &str = "/get_deck";
pub const ENDPOINT_LIST_CARDS: &str = "/list_cards";
pub const ENDPOINT_LOGIN: &str = "/login";
pub const ENDPOINT_NEW_USER: &str = "/new_user";
pub const ENDPOINT_DELETE_USER: &str = "/delete_user";
pub const ENDPOINT_CHANGE_PASSWORD: &str = "/change_password";
pub const ENDPOINT_SEARCH_DECKS: &str = "/search_decks";
pub const ENDPOINT_LIST_FAVORITES: &str = "/list_favorites";
pub const ENDPOINT_ADD_FAVORITE: &str = "/add_favorite";
pub const ENDPOINT_DELETE_FAVORITE: &str = "/delete_favorite";
pub const ENDPOINT_AI_TEST: &str = "/ai_test";
pub const ENDPOINT_CREATE_DECK_PDF: &str = "/create_card_deck_pdf";
pub const ENDPOINT_GET_RANDOM_DECKS: &str = "/get_random_decks";
pub type AccessToken = (u32, u32);
#[derive(Debug, serde::Serialize)]
pub struct Card {
pub question: String,
pub answer: String,
}
#[derive(Debug, serde::Serialize)]
pub struct CardDeck {
pub name: String,
pub deck_id: u32,
pub user_id: u32,
pub num_cards: u32,
pub icon_num: u32,
pub rating: f32,
}
#[derive(Debug, serde::Deserialize)]
pub struct CreateCard {
pub access_token: AccessToken,
pub deck_id: u32,
pub question: String,
pub answer: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct DeleteCard {
pub access_token: AccessToken,
pub deck_id: u32,
pub card_index: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct EditCard {
pub access_token: AccessToken,
pub deck_id: u32,
pub card_index: u32,
pub new_question: String,
pub new_answer: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct CreateCardDeck {
pub access_token: AccessToken,
pub deck_name: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct DeleteCardDeck {
pub access_token: AccessToken,
pub deck_id: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct AddRating {
pub access_token: AccessToken,
pub user_id: u32,
pub deck_id: u32,
pub new_rating: f32,
}
#[derive(Debug, serde::Deserialize)]
pub struct SetDeckIcon {
pub access_token: AccessToken,
pub deck_id: u32,
pub icon: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct NewUser {
pub user_name: String,
pub email: String,
pub password: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct DeleteUser {
pub email: String,
pub password: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct ChangePassword {
pub email: String,
pub old_password: String,
pub new_password: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct ListCardDecks {
pub access_token: AccessToken,
}
#[derive(Debug, serde::Serialize)]
pub struct ListCardDecksResponse {
pub decks: Vec<CardDeck>,
}
#[derive(Debug, serde::Deserialize)]
pub struct GetDeckRequest {
pub user_id: u32,
pub deck_id: u32,
}
pub type GetDeckResponse = CardDeck;
#[derive(Debug, serde::Deserialize)]
pub struct ListCards {
pub deck_id: u32,
pub user_id: u32,
}
#[derive(Debug, serde::Serialize)]
pub struct ListCardsResponse {
pub cards: Vec<Card>,
}
#[derive(Debug, serde::Deserialize)]
pub struct LoginRequest {
pub email: String,
pub password: String,
}
#[derive(Debug, serde::Serialize)]
pub struct LoginResponse {
pub access_token: AccessToken,
pub user_id: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct SearchDecksRequest {
pub prompt: String,
}
#[derive(Debug, serde::Serialize)]
pub struct SearchDecksResponse {
pub decks: Vec<CardDeck>,
}
#[derive(Debug, serde::Deserialize)]
pub struct UploadPdf {
pub access_token: AccessToken,
pub deck_name: String,
pub file_bytes_base64: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct AiPromptTest {
pub prompt: String,
}
#[derive(Debug, serde::Deserialize)]
pub struct ListFavoritesRequest {
pub access_token: AccessToken,
}
#[derive(Debug, serde::Serialize)]
pub struct ListFavoritesResponse {
pub decks: Vec<CardDeck>,
}
#[derive(Debug, serde::Deserialize)]
pub struct AddFavorite {
pub access_token: AccessToken,
pub user_id: u32,
pub deck_id: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct DeleteFavorite {
pub access_token: AccessToken,
pub user_id: u32,
pub deck_id: u32,
}
#[derive(Debug, serde::Deserialize)]
pub struct RandomDecksRequest {
pub num_decks: u32,
}
#[derive(Debug, serde::Serialize)]
pub struct RandomDecksResponse {
pub decks: Vec<CardDeck>,
}