wallabag_api/types/
user.rs

1// Copyright 2018 Samuel Walladge <samuel@swalladge.net>
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7use crate::types::ID;
8
9/// A struct representing a user. (ie. you) Fields should be self-explanatory.
10#[derive(Deserialize, Serialize, Debug)]
11pub struct User {
12    pub id: ID,
13    pub username: String,
14    pub email: String,
15    pub created_at: Option<DateTime<Utc>>,
16    pub updated_at: Option<DateTime<Utc>>,
17}
18
19/// A struct representing a user to be registered. Includes the name for the client to be
20/// registered along with.
21#[derive(Deserialize, Serialize, Debug)]
22pub struct RegisterInfo {
23    pub username: String,
24    pub password: String,
25    pub email: String,
26    pub client_name: String,
27}
28
29/// A struct representing a newly created user and associated client info.
30#[derive(Deserialize, Serialize, Debug)]
31pub struct NewlyRegisteredInfo {
32    pub id: ID,
33    pub username: String,
34    pub email: String,
35    pub created_at: Option<DateTime<Utc>>,
36    pub updated_at: Option<DateTime<Utc>>,
37    pub default_client: ClientInfo,
38}
39
40/// Represents the oauth client details.
41#[derive(Deserialize, Serialize, Debug)]
42pub struct ClientInfo {
43    client_id: String,
44    client_secret: String,
45    name: String,
46}