use std::collections::HashMap;
use serde::Serialize;
#[non_exhaustive]
#[derive(Default, Clone, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Config {
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub realm: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub app_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scope_separator: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub scopes: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_query_string_params: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub use_basic_authentication_with_access_code_grant: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub use_pkce_with_authorization_code_grant: Option<bool>,
}
impl Config {
#[must_use] pub fn new() -> Self {
Self { ..Default::default() }
}
#[must_use] pub fn client_id(mut self, client_id: &str) -> Self {
self.client_id = Some(String::from(client_id));
self
}
#[must_use] pub fn client_secret(mut self, client_secret: &str) -> Self {
self.client_secret = Some(String::from(client_secret));
self
}
#[must_use] pub fn realm(mut self, realm: &str) -> Self {
self.realm = Some(String::from(realm));
self
}
#[must_use] pub fn app_name(mut self, app_name: &str) -> Self {
self.app_name = Some(String::from(app_name));
self
}
#[must_use] pub fn scope_separator(mut self, scope_separator: &str) -> Self {
self.scope_separator = Some(String::from(scope_separator));
self
}
#[must_use] pub fn scopes(mut self, scopes: Vec<String>) -> Self {
self.scopes = Some(scopes);
self
}
#[must_use] pub fn additional_query_string_params(mut self, additional_query_string_params: HashMap<String, String>) -> Self {
self.additional_query_string_params = Some(additional_query_string_params);
self
}
#[must_use] pub fn use_basic_authentication_with_access_code_grant(
mut self,
use_basic_authentication_with_access_code_grant: bool,
) -> Self {
self.use_basic_authentication_with_access_code_grant = Some(use_basic_authentication_with_access_code_grant);
self
}
#[must_use] pub fn use_pkce_with_authorization_code_grant(mut self, use_pkce_with_authorization_code_grant: bool) -> Self {
self.use_pkce_with_authorization_code_grant = Some(use_pkce_with_authorization_code_grant);
self
}
}