const FCM_BASE: &str = "https://fcm.googleapis.com/v1";
const IID_BASE: &str = "https://iid.googleapis.com";
pub(crate) struct FcmEndpoints {
base: String,
project_id: String,
}
impl FcmEndpoints {
pub(crate) fn live(project_id: &str) -> Self {
Self {
base: FCM_BASE.to_string(),
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(crate) fn send(&self) -> String {
format!("{}/projects/{}/messages:send", self.base, self.project_id)
}
}
pub(crate) struct IidEndpoints {
base: String,
}
impl IidEndpoints {
pub(crate) fn live() -> Self {
Self {
base: IID_BASE.to_string(),
}
}
#[cfg(test)]
pub(crate) fn custom(base: impl Into<String>) -> Self {
Self { base: base.into() }
}
pub(crate) fn batch_add(&self) -> String {
format!("{}/iid/v1:batchAdd", self.base)
}
pub(crate) fn batch_remove(&self) -> String {
format!("{}/iid/v1:batchRemove", self.base)
}
}