// 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;

/// partnerrolle for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Partnerrolle {
    /// Erwarteter Kunde des Netzbetreibers
    #[serde(rename = "Z51")]
    ErwarteterKundeNetzbetreibers,
    /// Im System vorhandener Kunde des Netzbetreibers
    #[serde(rename = "Z52")]
    SystemVorhandenerKundeNetzbetreibers,
}

/// kommunikationsart for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kommunikationsart {
    /// Telefon
    #[serde(rename = "TE")]
    Telefon,
    /// Elektronische Post
    #[serde(rename = "EM")]
    ElektronischePost,
}

/// marktrolle for PID 55634
#[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 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Rollencodetyp {
    /// GS1
    #[serde(rename = "9")]
    Gs1,
    /// DE, BDEW (Bundesverband der Energie- und Wasserwirtschaft e.V.)
    #[serde(rename = "293")]
    DeBdewBundesverbandEnergieWasserwirtschaftEV,
}

/// ideQualifier for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum IdeQualifier {
    /// Transaktion
    #[serde(rename = "24")]
    Transaktion,
}

/// pruefidentifikator for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Pruefidentifikator {
    /// GPKE / Rückmeldung / Anfrage Daten der MaLo vom MSB an NB
    #[serde(rename = "55634")]
    GpkeRueckmeldungAnfrageDatenMaloMsbNb,
}

/// pruefschrittCode for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PruefschrittCode {
    /// Änderung Daten der MaLo
    #[serde(rename = "ZX6")]
    AenderungDatenMalo,
}

/// transaktionsgrund for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsgrund {
    /// Änderung Daten der MaLo
    #[serde(rename = "ZX6")]
    AenderungDatenMalo,
}

/// transaktionsgrundDetail for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundDetail {
    /// Erzeugende Marktlokation
    #[serde(rename = "ZW3")]
    ErzeugendeMarktlokation,
    /// Verbrauchende Marktlokation
    #[serde(rename = "ZW4")]
    VerbrauchendeMarktlokation,
}

/// transaktionsgrundErgaenzung for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TransaktionsgrundErgaenzung {
    /// Kunde verlässt eine schon bestehende Marktlokation
    #[serde(rename = "E01")]
    KundeVerlaesstBestehendeMarktlokation,
    /// - Kunde bleibt an der Marktlokation, hat nur den Marktpartner gewechselt - Ma...
    #[serde(rename = "E03")]
    KundeBleibtMarktlokationMarktpartnerGewechseltMarktpartnerKunden,
}

/// transaktionsnummer for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Transaktionsnummer {
    /// GPKE / Rückmeldung / Anfrage Daten der MaLo vom MSB an NB
    #[serde(rename = "55634")]
    GpkeRueckmeldungAnfrageDatenMaloMsbNb,
}

/// datenqualitaet for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Datenqualitaet {
    /// Erwartete Daten der Marktlokation
    #[serde(rename = "Z80")]
    ErwarteteDatenMarktlokation,
    /// Im System vorhandene Daten der Marktlokation
    #[serde(rename = "Z81")]
    SystemVorhandeneDatenMarktlokation,
}

/// mengenQualifier for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum MengenQualifier {
    /// Leistung der Marktlokation
    #[serde(rename = "Z10")]
    LeistungMarktlokation,
    /// Veranschlagte Jahresmenge Gesamt/Jahresverbrauchsprognose für spezifische Arb...
    #[serde(rename = "265")]
    VeranschlagteJahresmengeGesamtJahresverbrauchsprognoseSpezifischeArbeit,
    /// Angepasste elektrische Arbeit nach Anhang D der VDN-Richtlinie "Lastprofile f...
    #[serde(rename = "Z08")]
    AngepassteElektrischeArbeitAnhangDVdnRichtlinieLastprofileUnterbrechbare,
    /// Veranschlagte Jahresmenge Gesamt
    #[serde(rename = "31")]
    VeranschlagteJahresmengeGesamt,
}

/// mengeneinheit for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Mengeneinheit {
    /// kWh/K (Kilowatt-Stunde/Kelvin)
    #[serde(rename = "Z16")]
    KwhKKilowattStundeKelvin,
    /// Kilowattstunde
    #[serde(rename = "KWH")]
    Kilowattstunde,
    /// Kilowatt
    #[serde(rename = "KWT")]
    Kilowatt,
}

/// merkmal.code for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungCode {
    /// Zugeordneter Marktpartner
    #[serde(rename = "ZB3")]
    ZugeordneterMarktpartner,
    /// Spannungsebene der Marktlokation
    #[serde(rename = "E03")]
    SpannungsebeneMarktlokation,
    /// Messtechnische Einordnung der Marktlokation
    #[serde(rename = "Z83")]
    MesstechnischeEinordnungMarktlokation,
    /// Prognose auf Basis von Werten
    #[serde(rename = "ZC0")]
    PrognoseBasisWerten,
    /// Prognose auf Basis von Profilen
    #[serde(rename = "ZA6")]
    PrognoseBasisProfilen,
    /// Art der erzeugenden Marktlokation
    #[serde(rename = "Z34")]
    ArtErzeugendenMarktlokation,
    /// Modell 1 "Bilanzierung an der Marktlokation"
    #[serde(rename = "ZE9")]
    Modell1BilanzierungMarktlokation,
    /// Modell 2 "Bilanzierung im Bilanzierungsgebiet (BG) des LPB"
    #[serde(rename = "ZF0")]
    Modell2BilanzierungBilanzierungsgebietBgLpb,
}

/// merkmal.klasse for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungKlasse {
    /// Abwicklungsmodell
    #[serde(rename = "ZA2")]
    Abwicklungsmodell,
}

/// merkmal.qualifier for PID 55634
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ZuordnungQualifier {
    /// ÜNB
    #[serde(rename = "Z90")]
    Uenb,
    /// MSB
    #[serde(rename = "Z91")]
    Msb,
    /// Höchstspannung
    #[serde(rename = "E03")]
    Hoechstspannung,
    /// Hochspannung
    #[serde(rename = "E04")]
    Hochspannung,
    /// Mittelspannung
    #[serde(rename = "E05")]
    Mittelspannung,
    /// Niederspannung
    #[serde(rename = "E06")]
    Niederspannung,
    /// Hös/HS Umspannung
    #[serde(rename = "E07")]
    HoesHsUmspannung,
    /// HS/MS Umspannung
    #[serde(rename = "E08")]
    HsMsUmspannung,
    /// MS/NS Umspannung
    #[serde(rename = "E09")]
    MsNsUmspannung,
    /// Anzuwenden wenn alle Messlokationen, die zur Erfassung der Energiewerte der M...
    #[serde(rename = "Z52")]
    AnzuwendenAlleMesslokationenErfassungEnergiewerteMarktlokationErforderlich,
    /// Anzuwenden wenn noch mindestens eine Messlokation, die zur Erfassung der Ener...
    #[serde(rename = "Z53")]
    AnzuwendenMindestensMesslokationErfassungEnergiewerteMarktlokationKmeMme,
    /// SLP/SEP
    #[serde(rename = "E02")]
    SlpSep,
    /// TLP/TEP
    #[serde(rename = "E14")]
    TlpTep,
    /// TEP mit Referenzmessung
    #[serde(rename = "Z36")]
    TepReferenzmessung,
    /// EEG-Marktlokation ohne DV-Pflicht
    #[serde(rename = "Z33")]
    EegMarktlokationOhneDvPflicht,
    /// KWKG-Marktlokation ohne DV-Pflicht
    #[serde(rename = "Z34")]
    KwkgMarktlokationOhneDvPflicht,
    /// sonstige Marktlokation
    #[serde(rename = "Z35")]
    SonstigeMarktlokation,
    /// EEG-Marktlokation mit DV-Pflicht
    #[serde(rename = "Z37")]
    EegMarktlokationDvPflicht,
    /// KWKG-Marktlokation mit DV-Pflicht
    #[serde(rename = "Z46")]
    KwkgMarktlokationDvPflicht,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GeschaeftspartnerAdresse {
    /// Required (X). (an..35)
    pub hausnummer: Option<String>,
    /// Required (X). (an..3)
    pub landescode: Option<String>,
    /// Required (X). (an..35)
    pub ort: Option<String>,
    /// Required (M [268] S [166]). (an..17)
    pub postleitzahl: Option<String>,
    /// Required (X). (an..35)
    pub strasse: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProzessdatenZeitscheibe {
    /// Required (unknown). ()
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ZaehlerDatenZeitscheibe {
    /// Required (X [914] ∧ [937] [22]). (an..10)
    pub referenz: Option<String>,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ZuordnungMerkmal {
    /// Required (X). (an..17)
    pub code: Option<ZuordnungCode>,
    /// Required (unknown). ()
    pub codepflege: Option<String>,
    /// Required (unknown). ()
    pub dimension: Option<String>,
    /// Required (unknown). ()
    pub eigenschaft: Option<String>,
    /// Required (unknown). ()
    pub eigenschaft_2: Option<String>,
    /// Required (X). (an..3)
    pub klasse: Option<ZuordnungKlasse>,
    /// Required (X). (an..3)
    pub qualifier: Option<ZuordnungQualifier>,
}

/// Map key for Geschaeftspartner instances.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum GeschaeftspartnerKey {
    #[serde(rename = "Z51_Z52")]
    Z51_z52,
    #[serde(rename = "Z51")]
    Z51,
    #[serde(rename = "Z52")]
    Z52,
    #[serde(rename = "Z53_Z54")]
    Z53_z54,
    #[serde(rename = "Z53")]
    Z53,
    #[serde(rename = "Z54")]
    Z54,
    #[serde(rename = "Z55_Z56")]
    Z55_z56,
    #[serde(rename = "Z55")]
    Z55,
    #[serde(rename = "Z56")]
    Z56,
    #[serde(rename = "Z57_Z58")]
    Z57_z58,
    #[serde(rename = "Z57")]
    Z57,
    #[serde(rename = "Z58")]
    Z58,
}

impl std::fmt::Display for GeschaeftspartnerKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Z51_z52 => write!(f, "Z51_Z52"),
            Self::Z51 => write!(f, "Z51"),
            Self::Z52 => write!(f, "Z52"),
            Self::Z53_z54 => write!(f, "Z53_Z54"),
            Self::Z53 => write!(f, "Z53"),
            Self::Z54 => write!(f, "Z54"),
            Self::Z55_z56 => write!(f, "Z55_Z56"),
            Self::Z55 => write!(f, "Z55"),
            Self::Z56 => write!(f, "Z56"),
            Self::Z57_z58 => write!(f, "Z57_Z58"),
            Self::Z57 => write!(f, "Z57"),
            Self::Z58 => write!(f, "Z58"),
        }
    }
}

/// 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"),
        }
    }
}

/// Geschaeftspartner for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Geschaeftspartner {
    pub adresse: Option<GeschaeftspartnerAdresse>,
    /// Required (X). ()
    pub geschaeftspartner_id: Option<String>,
    /// Required (X). (an..70)
    pub name1: Option<String>,
    /// Required (X). (an..70)
    pub name2: Option<String>,
    /// Required (X). (an..3)
    pub partnerrolle: Option<Partnerrolle>,
}

/// Kontakt for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[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>,
}

/// Marktlokation for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Marktlokation {
    /// Required (X). ()
    pub codeliste_code: Option<String>,
    /// Required (X). ()
    pub codepflege_code: Option<String>,
    /// Required (X). (an..256)
    pub lokation_zeitraum_id: Option<String>,
    /// Required (X [950]). (an..35)
    pub marktlokations_id: Option<String>,
}

/// Marktteilnehmer for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[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 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[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 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (unknown). ()
    pub antwort_bearbeitungsstand: Option<String>,
    /// Required (unknown). ()
    pub bearbeitungsstand: Option<String>,
    /// Required (unknown). ()
    pub codepflege_stelle: Option<String>,
    /// Required (unknown). ()
    pub ebd_nummer: Option<String>,
    /// Required (X). (an..3)
    pub ide_qualifier: Option<IdeQualifier>,
    /// Required (X). (an..70)
    pub pruefidentifikator: Option<Pruefidentifikator>,
    /// Required (X). (an..3)
    pub pruefschritt_code: Option<PruefschrittCode>,
    /// Required (X). (an..3)
    pub transaktionsgrund: Option<Transaktionsgrund>,
    /// Required (X). (an..3)
    pub transaktionsgrund_detail: Option<TransaktionsgrundDetail>,
    /// Optional. (an..3)
    pub transaktionsgrund_ergaenzung: Option<TransaktionsgrundErgaenzung>,
    /// Required (X). (an..70)
    pub transaktionsnummer: Option<Transaktionsnummer>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
    pub zeitscheibe: Option<ProzessdatenZeitscheibe>,
}

/// ZaehlerDaten for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ZaehlerDaten {
    /// Required (X [2P0..n]). (an..3)
    pub datenqualitaet: Option<Datenqualitaet>,
    pub zeitscheibe: Option<ZaehlerDatenZeitscheibe>,
}

/// ZaehlerMengen for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct ZaehlerMengen {
    /// Required (X [902]). (an..35)
    pub menge: Option<String>,
    /// Required (X [102]). (an..3)
    pub mengen_qualifier: Option<MengenQualifier>,
    /// Required (X [103]). (an..8)
    pub mengeneinheit: Option<Mengeneinheit>,
}

/// Zuordnung for PID 55634 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Zuordnung {
    pub merkmal: Option<ZuordnungMerkmal>,
    /// Required (X). (an..17)
    pub zugeordneter_mp: Option<String>,
}

/// PID 55634 transaction — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub geschaeftspartner: Option<BTreeMap<GeschaeftspartnerKey, Geschaeftspartner>>,
    pub kontakt: Option<Kontakt>,
    /// Required (X).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub marktlokation: Option<Vec<Marktlokation>>,
    pub prozessdaten: Option<Prozessdaten>,
    /// Required (X [2P0..n]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub zaehler_daten: Option<Vec<ZaehlerDaten>>,
    pub zaehler_mengen: Option<ZaehlerMengen>,
    pub zuordnung: Option<Zuordnung>,
}

/// PID 55634 message-level — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Message {
    #[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 55634 — Rückmeldung/Anfrage Daten der MaLo.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
