pub use carrier_core::envelope::{SignaturId, Zeitstempel};
use super::{Auftrag, Meldung, Teq};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Release {
pub major: u8,
pub minor: u8,
}
impl Release {
pub const SPRI_4_4: Self = Self { major: 4, minor: 4 };
}
impl Default for Release {
fn default() -> Self {
Self::SPRI_4_4
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Control {
pub zeitstempel: Zeitstempel,
pub release: Release,
pub signatur: SignaturId,
}
impl Control {
#[must_use]
pub fn new(zeitstempel: impl Into<Zeitstempel>, signatur: SignaturId) -> Self {
Self { zeitstempel: zeitstempel.into(), release: Release::SPRI_4_4, signatur }
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
pub enum Payload {
AuftragRequest {
control: Control,
auftrag: Auftrag,
},
AuftragResponse {
control: Control,
quittung: Teq,
},
MeldungRequest {
control: Control,
meldung: Meldung,
},
MeldungResponse {
control: Control,
quittung: Teq,
},
}
impl Payload {
#[must_use]
pub fn kind(&self) -> &'static str {
match self {
Self::AuftragRequest { auftrag, .. } => match auftrag.aenderungskennzeichen {
crate::Aenderungskennzeichen::Standard => auftrag.geschaeftsfall.code().as_str(),
crate::Aenderungskennzeichen::Storno => "Storno",
crate::Aenderungskennzeichen::Terminverschiebung => "Terminverschiebung",
},
Self::MeldungRequest { meldung, .. } => meldung.typ().as_str(),
Self::AuftragResponse { .. } | Self::MeldungResponse { .. } => "TEQ",
}
}
#[must_use]
pub const fn control(&self) -> &Control {
match self {
Self::AuftragRequest { control, .. }
| Self::AuftragResponse { control, .. }
| Self::MeldungRequest { control, .. }
| Self::MeldungResponse { control, .. } => control,
}
}
#[must_use]
pub const fn soap_action(&self) -> &'static str {
match self {
Self::AuftragRequest { .. } | Self::AuftragResponse { .. } => {
"http://spri.telekom.de/oss/v4/spri/annehmenAuftrag"
}
Self::MeldungRequest { .. } | Self::MeldungResponse { .. } => {
"http://spri.telekom.de/oss/v4/spri/annehmenMeldung"
}
}
}
}