const IDENTITY_TOOLKIT_BASE: &str = "https://identitytoolkit.googleapis.com/v1";
pub struct IdentityToolkitEndpoints {
base: String,
project_id: String,
}
impl IdentityToolkitEndpoints {
pub fn live(project_id: &str) -> Self {
Self {
base: IDENTITY_TOOLKIT_BASE.to_string(),
project_id: project_id.to_string(),
}
}
pub fn emulator(host: &str, project_id: &str) -> Self {
Self {
base: format!("http://{host}/identitytoolkit.googleapis.com/v1"),
project_id: project_id.to_string(),
}
}
#[cfg(test)]
pub(crate) fn custom(base: impl Into<String>) -> Self {
Self {
base: base.into(),
project_id: "test-project".to_string(),
}
}
pub fn lookup(&self) -> String {
format!("{}/accounts:lookup", self.base)
}
pub fn sign_up(&self) -> String {
format!("{}/accounts:signUp", self.base)
}
pub fn update(&self) -> String {
format!("{}/accounts:update", self.base)
}
pub fn delete(&self) -> String {
format!("{}/accounts:delete", self.base)
}
pub fn batch_get(&self) -> String {
format!(
"{}/projects/{}/accounts:batchGet",
self.base, self.project_id
)
}
pub fn create_session_cookie(&self) -> String {
format!(
"{}/projects/{}:createSessionCookie",
self.base, self.project_id
)
}
}