1use {
2 crate::account::{Data, ErrorCode, Status},
3 serde::{Deserialize, Serialize},
4 tsync::tsync,
5};
6
7#[derive(Debug, Serialize)]
8pub struct LoginArgs {
9 pub username: String,
10 pub password: String,
11}
12
13#[derive(Debug, Serialize)]
14pub struct LoginParams {
15 pub user: UserParam,
16}
17
18#[derive(Debug, Serialize)]
19pub struct UserParam {
20 pub email: String,
21 pub password: String,
22}
23
24#[derive(Debug, Serialize, Deserialize)]
25pub struct LoginResult {
26 pub status: Status,
27 pub data: Data,
28}
29
30#[derive(Debug, Serialize, Deserialize)]
32#[tsync]
33pub enum AccountStatus {
34 NotFound,
35 Ready { access_token: String },
36 Incomplete { status: ErrorCode },
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42 use serde_json::json;
43 #[test]
44 fn test_login() {
45 let args = LoginArgs {
46 username: "test".to_owned(),
47 password: "test".to_owned(),
48 };
49 let json = json!({
50 "username": "test",
51 "password": "test",
52 });
53 assert_eq!(serde_json::to_value(args).unwrap(), json);
54 }
55}