pub(crate) mod action;
pub(crate) mod portability;
pub(crate) mod types;
pub use types::{
ConsentRecord, ConsentResponse, ConsentResult, ConsentValue, PortabilityRequest,
PortabilityResponse, PortabilityStatus,
};
use crate::error::Result;
use std::sync::Arc;
#[derive(Debug)]
pub struct ConsentHandler<A: crate::auth::Authenticator> {
inner: Arc<crate::session::Session<A>>,
}
impl<A: crate::auth::Authenticator> Clone for ConsentHandler<A> {
fn clone(&self) -> Self {
Self {
inner: Arc::clone(&self.inner),
}
}
}
impl<A: crate::auth::Authenticator> ConsentHandler<A> {
#[must_use]
pub(crate) fn new(inner: Arc<crate::session::Session<A>>) -> Self {
Self { inner }
}
pub(crate) async fn resolve_consent_url(&self, path: &str) -> Result<String> {
let clean = path.trim_start_matches('/');
if clean.is_empty() {
self.inner.resolve_url("consent").await
} else {
self.inner.resolve_url(&format!("consent/{clean}")).await
}
}
pub(crate) async fn resolve_portability_url(&self, path: &str) -> Result<String> {
let clean = path.trim_start_matches('/');
if clean.is_empty() {
self.inner.resolve_url("portability").await
} else {
self.inner
.resolve_url(&format!("portability/{clean}"))
.await
}
}
}