use super::Scope;
#[derive(Debug, Default)]
pub struct Builder {
pub(crate) scopes: Option<Vec<Scope>>,
pub(crate) name: String,
pub(crate) note: String,
}
impl Builder {
pub fn new(name: String) -> Self {
let note = format!("A token created for {}.", &name);
Self {
name,
note,
..Default::default()
}
}
pub fn note(mut self, note: String) -> Self {
self.note = note;
self
}
pub fn scope(mut self, scope: Scope) -> Self {
if let None = self.scopes {
self.scopes = Some(vec![]);
}
if let Some(ref mut scopes) = &mut self.scopes {
scopes.push(scope);
}
self
}
pub fn build(self) -> crate::Authenticator {
crate::Authenticator { config: self }
}
}