// Auto-generated by automapper-generator. Do not edit.

#![allow(dead_code, unused_imports, non_camel_case_types)]

use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

/// textbezug for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Textbezug {
    /// Zusätzliche Informationen (für allgemeine Hinweise)
    #[serde(rename = "ACB")]
    ZusaetzlicheInformationenAllgemeineHinweise,
}

/// kommunikationsart for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kommunikationsart {
    /// Elektronische Post
    #[serde(rename = "EM")]
    ElektronischePost,
    /// Telefax
    #[serde(rename = "FX")]
    Telefax,
    /// Telefon
    #[serde(rename = "TE")]
    Telefon,
    /// weiteres Telefon
    #[serde(rename = "AJ")]
    WeiteresTelefon,
    /// Handy
    #[serde(rename = "AL")]
    Handy,
}

/// kontaktfunktion for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kontaktfunktion {
    /// Informationskontakt
    #[serde(rename = "IC")]
    Informationskontakt,
}

/// marktrolle for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Marktrolle {
    /// Dokumenten-/Nachrichtenaussteller bzw. -absender
    #[serde(rename = "MS")]
    DokumentenNachrichtenausstellerAbsender,
    /// Nachrichtenempfänger
    #[serde(rename = "MR")]
    Nachrichtenempfaenger,
}

/// rollencodetyp for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Rollencodetyp {
    /// GS1
    #[serde(rename = "9")]
    Gs1,
    /// DE, DVGW Service & Consult GmbH
    #[serde(rename = "332")]
    DeDvgwServiceConsultGmbh,
}

/// produktIdentifikation.id for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ProzessdatenId {
    /// GeLi Gas / Anfrage nach Stornierung
    #[serde(rename = "44022")]
    GeliGasAnfrageStornierung,
}

/// pruefidentifikator for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// GeLi Gas / Anfrage nach Stornierung
    #[serde(rename = "44022")]
    GeliGasAnfrageStornierung,
}

/// transaktionsgrund for PID 44022
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// Dient dem Rückruf von abgegebenen Meldungen
    #[serde(rename = "E05")]
    DientRueckrufAbgegebenenMeldungen,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KontaktKontakt {
    /// Required (X). (an..256)
    pub name: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProzessdatenProduktIdentifikation {
    /// Required (X). (an..70)
    pub id: Option<ProzessdatenId>,
}

/// Map key for Marktteilnehmer instances.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum MarktteilnehmerKey {
    /// Dokumenten-/Nachrichtenaussteller bzw. -absender
    #[serde(rename = "MS")]
    Ms,
    /// Nachrichtenempfänger
    #[serde(rename = "MR")]
    Mr,
}

impl std::fmt::Display for MarktteilnehmerKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Ms => write!(f, "MS"),
            Self::Mr => write!(f, "MR"),
        }
    }
}

/// Freitext for PID 44022 — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Freitext {
    /// Required (X). (an..512)
    pub text: Option<String>,
    /// Required (unknown). ()
    pub text_referenz: Option<String>,
    /// Optional. (an..512)
    pub text_zeile2: Option<String>,
    /// Optional. (an..512)
    pub text_zeile3: Option<String>,
    /// Optional. (an..512)
    pub text_zeile4: Option<String>,
    /// Optional. (an..512)
    pub text_zeile5: Option<String>,
    /// Required (X). (an..3)
    pub textbezug: Option<Textbezug>,
    /// Required (unknown). ()
    pub textfunktion: Option<String>,
}

/// Kontakt for PID 44022 — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Kontakt {
    /// Required (X [1P0..1]). (an..3)
    pub kommunikationsart: Option<Kommunikationsart>,
    /// Required (X). (an..512)
    pub kommunikationsnummer: Option<String>,
    pub kontakt: Option<KontaktKontakt>,
    /// Required (X). (an..3)
    pub kontaktfunktion: Option<Kontaktfunktion>,
}

/// Marktteilnehmer for PID 44022 — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktteilnehmer {
    /// Required (unknown). ()
    pub codeliste_code: Option<String>,
    /// Required (X). (an..3)
    pub marktrolle: Option<Marktrolle>,
    /// Required (X). (an..35)
    pub rollencodenummer: Option<String>,
    /// Required (X). (an..3)
    pub rollencodetyp: Option<Rollencodetyp>,
}

/// Nachricht for PID 44022 — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Optional. (an..35)
    pub erstellungsdatum: Option<String>,
    /// Optional. ()
    pub nachrichtennummer: Option<String>,
    /// Optional. ()
    pub nachrichtentyp: Option<String>,
}

/// Prozessdaten for PID 44022 — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    pub produkt_identifikation: Option<ProzessdatenProduktIdentifikation>,
    /// Required (X). (an..70)
    pub pruefidentifikator: Option<Pruefidentifikator>,
    /// Required (unknown). ()
    pub status_code: Option<String>,
    /// Required (X). (an..3)
    pub transaktionsgrund: Option<Transaktionsgrund>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
}

/// PID 44022 transaction — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    pub freitext: Option<Freitext>,
    pub prozessdaten: Option<Prozessdaten>,
}

/// PID 44022 message-level — Anfrage nach Stornierung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Message {
    pub kontakt: Option<Kontakt>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub marktteilnehmer: Option<BTreeMap<MarktteilnehmerKey, Marktteilnehmer>>,
    pub nachricht: Option<Nachricht>,
}

/// Complete interchange for PID 44022 — Anfrage nach Stornierung.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
