use chrono::{DateTime, Utc};
use std::fmt::Debug;
use std::ops::Add;
#[derive(Debug)]
pub struct User {
pub(crate) username: String,
pub(crate) password: String,
}
impl User {
#[must_use]
pub fn new<'a>(username: &'a str, password: &'a str) -> Self {
Self {
username: username.into(),
password: password.into(),
}
}
}
#[derive(Debug, Clone)]
pub struct TrustedDevice {
#[allow(missing_docs)]
pub device_group_key: String,
#[allow(missing_docs)]
pub device_key: String,
#[allow(missing_docs)]
pub device_password: String,
}
impl TrustedDevice {
#[must_use]
pub fn new<'a>(
device_password: &'a str,
device_group_key: &'a str,
device_key: &'a str,
) -> Self {
Self {
device_password: device_password.into(),
device_group_key: device_group_key.into(),
device_key: device_key.into(),
}
}
}
#[derive(Debug)]
pub struct UntrustedDevice {
pub device_group_key: String,
pub device_key: String,
}
impl UntrustedDevice {
#[must_use]
pub(crate) fn new<'a>(device_group_key: &'a str, device_key: &'a str) -> Self {
Self {
device_group_key: device_group_key.into(),
device_key: device_key.into(),
}
}
}
#[derive(Debug)]
pub struct Tokens {
pub(crate) id_token: String,
pub(crate) access_token: String,
pub(crate) refresh_token: String,
pub(crate) expires_at: DateTime<Utc>,
}
impl Tokens {
#[must_use]
pub fn new(
id_token: String,
access_token: String,
refresh_token: String,
expires_in: i32,
) -> Self {
Self {
id_token,
access_token,
refresh_token,
expires_at: Utc::now().add(chrono::Duration::seconds(i64::from(expires_in))),
}
}
}