2024-05-25 11:25:13 +01:00
|
|
|
//
|
|
|
|
use crate as config;
|
|
|
|
|
2024-06-19 07:03:08 +01:00
|
|
|
use std::collections::BTreeMap;
|
2024-05-25 11:25:13 +01:00
|
|
|
|
2024-06-19 07:03:08 +01:00
|
|
|
/// A notification receive from a Forge, typically via a Webhook.
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, derive_more::Constructor)]
|
|
|
|
pub struct ForgeNotification {
|
2024-05-25 11:25:13 +01:00
|
|
|
forge_alias: config::ForgeAlias,
|
|
|
|
repo_alias: config::RepoAlias,
|
2024-06-19 07:03:08 +01:00
|
|
|
headers: BTreeMap<String, String>,
|
2024-05-25 11:25:13 +01:00
|
|
|
body: Body,
|
|
|
|
}
|
2024-06-19 07:03:08 +01:00
|
|
|
impl ForgeNotification {
|
2024-05-25 11:25:13 +01:00
|
|
|
pub const fn forge_alias(&self) -> &config::ForgeAlias {
|
|
|
|
&self.forge_alias
|
|
|
|
}
|
|
|
|
pub const fn repo_alias(&self) -> &config::RepoAlias {
|
|
|
|
&self.repo_alias
|
|
|
|
}
|
|
|
|
pub const fn body(&self) -> &Body {
|
|
|
|
&self.body
|
|
|
|
}
|
|
|
|
pub fn header(&self, header: &str) -> Option<String> {
|
|
|
|
self.headers.get(header).map(|value| value.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-19 07:03:08 +01:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, derive_more::Constructor)]
|
2024-05-25 11:25:13 +01:00
|
|
|
pub struct Body(String);
|
|
|
|
impl Body {
|
|
|
|
pub fn as_str(&self) -> &str {
|
|
|
|
self.0.as_str()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn as_bytes(&self) -> &[u8] {
|
|
|
|
self.0.as_bytes()
|
|
|
|
}
|
|
|
|
}
|