thunderstore_api/models/v2/
authenticate.rs

1////////////////////////////////////////////////////////////////////////////////
2// This Source Code Form is subject to the terms of the Mozilla Public         /
3// License, v. 2.0. If a copy of the MPL was not distributed with this         /
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
5////////////////////////////////////////////////////////////////////////////////
6
7////////////////////////////////////////////////////////////////////////////////
8// This Source Code Form is subject to the terms of the Mozilla Public         /
9// License, v. 2.0. If a copy of the MPL was not distributed with this         /
10// file, You can obtain one at https://mozilla.org/MPL/2.0/.                   /
11////////////////////////////////////////////////////////////////////////////////
12
13#[cfg(feature = "ts-rs")]
14use ts_rs::TS;
15
16#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
17#[cfg_attr(feature = "ts-rs", derive(TS))]
18#[cfg_attr(feature = "ts-rs", ts(export))]
19pub struct RequestBody {
20    pub code: String,
21    pub redirect_uri: String,
22}
23
24impl RequestBody {
25    #[must_use]
26    pub fn new(code: String, redirect_uri: String) -> RequestBody {
27        RequestBody { code, redirect_uri }
28    }
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
32#[cfg_attr(feature = "ts-rs", derive(TS))]
33#[cfg_attr(feature = "ts-rs", ts(export))]
34pub struct ResponseBody {
35    pub email: Option<String>,
36    pub session_id: String,
37    pub username: String,
38}
39
40impl ResponseBody {
41    #[must_use]
42    pub fn new(email: Option<String>, session_id: String, username: String) -> ResponseBody {
43        ResponseBody {
44            email,
45            session_id,
46            username,
47        }
48    }
49}