use std::marker::PhantomData;
use std::time::Duration;
use super::claims::AddressClaim;
use super::scopes::{HasAddress, HasEmail, HasPhone, HasProfile, ScopeSet};
#[derive(Debug, Clone)]
pub struct IssueRequest<S: ScopeSet> {
pub sub: String,
pub ttl: Duration,
pub auth_time: Option<i64>,
pub acr: Option<String>,
pub amr: Option<Vec<String>>,
pub azp: Option<String>,
pub(crate) email: Option<String>,
pub(crate) email_verified: Option<bool>,
pub(crate) name: Option<String>,
pub(crate) given_name: Option<String>,
pub(crate) family_name: Option<String>,
pub(crate) middle_name: Option<String>,
pub(crate) nickname: Option<String>,
pub(crate) preferred_username: Option<String>,
pub(crate) profile: Option<String>,
pub(crate) picture: Option<String>,
pub(crate) website: Option<String>,
pub(crate) gender: Option<String>,
pub(crate) birthdate: Option<String>,
pub(crate) zoneinfo: Option<String>,
pub(crate) locale: Option<String>,
pub(crate) updated_at: Option<i64>,
pub(crate) phone_number: Option<String>,
pub(crate) phone_number_verified: Option<bool>,
pub(crate) address: Option<AddressClaim>,
pub(crate) _scope: PhantomData<S>,
}
impl<S: ScopeSet> IssueRequest<S> {
pub fn new(sub: impl Into<String>, ttl: Duration) -> Self {
Self {
sub: sub.into(),
ttl,
auth_time: None,
acr: None,
amr: None,
azp: None,
email: None,
email_verified: None,
name: None,
given_name: None,
family_name: None,
middle_name: None,
nickname: None,
preferred_username: None,
profile: None,
picture: None,
website: None,
gender: None,
birthdate: None,
zoneinfo: None,
locale: None,
updated_at: None,
phone_number: None,
phone_number_verified: None,
address: None,
_scope: PhantomData,
}
}
#[must_use]
pub fn with_auth_time(mut self, auth_time: i64) -> Self {
self.auth_time = Some(auth_time);
self
}
#[must_use]
pub fn with_acr(mut self, acr: impl Into<String>) -> Self {
self.acr = Some(acr.into());
self
}
#[must_use]
pub fn with_amr(mut self, amr: Vec<String>) -> Self {
self.amr = Some(amr);
self
}
#[must_use]
pub fn with_azp(mut self, azp: impl Into<String>) -> Self {
self.azp = Some(azp.into());
self
}
}
impl<S: HasEmail> IssueRequest<S> {
#[must_use]
pub fn with_email(mut self, email: impl Into<String>) -> Self {
self.email = Some(email.into());
self
}
#[must_use]
pub fn with_email_verified(mut self, verified: bool) -> Self {
self.email_verified = Some(verified);
self
}
}
impl<S: HasProfile> IssueRequest<S> {
#[must_use]
pub fn with_name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
#[must_use]
pub fn with_given_name(mut self, given_name: impl Into<String>) -> Self {
self.given_name = Some(given_name.into());
self
}
#[must_use]
pub fn with_family_name(mut self, family_name: impl Into<String>) -> Self {
self.family_name = Some(family_name.into());
self
}
#[must_use]
pub fn with_middle_name(mut self, middle_name: impl Into<String>) -> Self {
self.middle_name = Some(middle_name.into());
self
}
#[must_use]
pub fn with_nickname(mut self, nickname: impl Into<String>) -> Self {
self.nickname = Some(nickname.into());
self
}
#[must_use]
pub fn with_preferred_username(mut self, preferred_username: impl Into<String>) -> Self {
self.preferred_username = Some(preferred_username.into());
self
}
#[must_use]
pub fn with_profile(mut self, profile: impl Into<String>) -> Self {
self.profile = Some(profile.into());
self
}
#[must_use]
pub fn with_picture(mut self, picture: impl Into<String>) -> Self {
self.picture = Some(picture.into());
self
}
#[must_use]
pub fn with_website(mut self, website: impl Into<String>) -> Self {
self.website = Some(website.into());
self
}
#[must_use]
pub fn with_gender(mut self, gender: impl Into<String>) -> Self {
self.gender = Some(gender.into());
self
}
#[must_use]
pub fn with_birthdate(mut self, birthdate: impl Into<String>) -> Self {
self.birthdate = Some(birthdate.into());
self
}
#[must_use]
pub fn with_zoneinfo(mut self, zoneinfo: impl Into<String>) -> Self {
self.zoneinfo = Some(zoneinfo.into());
self
}
#[must_use]
pub fn with_locale(mut self, locale: impl Into<String>) -> Self {
self.locale = Some(locale.into());
self
}
#[must_use]
pub fn with_updated_at(mut self, updated_at: i64) -> Self {
self.updated_at = Some(updated_at);
self
}
}
impl<S: HasPhone> IssueRequest<S> {
#[must_use]
pub fn with_phone_number(mut self, phone_number: impl Into<String>) -> Self {
self.phone_number = Some(phone_number.into());
self
}
#[must_use]
pub fn with_phone_number_verified(mut self, verified: bool) -> Self {
self.phone_number_verified = Some(verified);
self
}
}
impl<S: HasAddress> IssueRequest<S> {
#[must_use]
pub fn with_address(mut self, address: AddressClaim) -> Self {
self.address = Some(address);
self
}
}