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

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

/// rollencodetyp for PID 23009
#[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,
    /// DE, DVGW Service & Consult GmbH
    #[serde(rename = "332")]
    DeDvgwServiceConsultGmbh,
}

/// ablesedatumFormat for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AblesedatumFormat {
    /// CCYYMMDD
    #[serde(rename = "102")]
    Ccyymmdd,
    /// CCYYMMDDHHMMZZZ
    #[serde(rename = "303")]
    Ccyymmddhhmmzzz,
}

/// antwortStatusAnlass for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AntwortStatusAnlass {
    /// Kommunikationsstörung
    #[serde(rename = "Z75")]
    Kommunikationsstoerung,
    /// Gerätewechsel
    #[serde(rename = "Z78")]
    StromGasMesswerteUnvollstaendigWegenGeraetewechsels,
    /// Messeinrichtung gestört/defekt
    #[serde(rename = "Z81")]
    StromGasMesswerteSindNichtVerwendbarVerfuegbarMesseinrichtungDefekt,
    /// keine Störung feststellbar
    #[serde(rename = "ZB8")]
    KeineStoerungFeststellbar,
    /// Störungsbehebung nicht möglich
    #[serde(rename = "ZC1")]
    StoerungsbehebungNichtMoeglich,
}

/// antwortStatusCode for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AntwortStatusCode {
    /// störungsfrei
    #[serde(rename = "Z09")]
    Stoerungsfrei,
    /// gestört
    #[serde(rename = "Z10")]
    Gestoert,
}

/// beginnDatumFormat for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BeginnDatumFormat {
    /// CCYYMMDD
    #[serde(rename = "102")]
    Ccyymmdd,
    /// CCYYMMDDHHMMZZZ
    #[serde(rename = "303")]
    Ccyymmddhhmmzzz,
}

/// berichtszeitraumFormat for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BerichtszeitraumFormat {
    /// CCYYMMDD
    #[serde(rename = "102")]
    Ccyymmdd,
    /// CCYYMMDDHHMMZZZ
    #[serde(rename = "303")]
    Ccyymmddhhmmzzz,
}

/// endeDatumFormat for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum EndeDatumFormat {
    /// CCYYMMDD
    #[serde(rename = "102")]
    Ccyymmdd,
    /// CCYYMMDDHHMMZZZ
    #[serde(rename = "303")]
    Ccyymmddhhmmzzz,
}

/// geraeteStatusAnlass for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GeraeteStatusAnlass {
    /// Kommunikationsstörung
    #[serde(rename = "Z75")]
    Kommunikationsstoerung,
    /// Gerätewechsel
    #[serde(rename = "Z78")]
    StromGasMesswerteUnvollstaendigWegenGeraetewechsels,
    /// Messeinrichtung gestört/defekt
    #[serde(rename = "Z81")]
    StromGasMesswerteSindNichtVerwendbarVerfuegbarMesseinrichtungDefekt,
    /// keine Störung feststellbar
    #[serde(rename = "ZB8")]
    KeineStoerungFeststellbar,
    /// Störungsbehebung nicht möglich
    #[serde(rename = "ZC1")]
    StoerungsbehebungNichtMoeglich,
}

/// geraeteStatusCode for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GeraeteStatusCode {
    /// störungsfrei
    #[serde(rename = "Z09")]
    Stoerungsfrei,
    /// gestört
    #[serde(rename = "Z10")]
    Gestoert,
}

/// referenzNummer for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ReferenzNummer {
    /// WiM / Informationsmeldung (Störungsbehebung) vom MSB an NB (Gas)/MSB (Strom)
    #[serde(rename = "23009")]
    WimInformationsmeldungStoerungsbehebungMsbNbGasMsbStrom,
}

/// referenzQualifier for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ReferenzQualifier {
    /// Prüfidentifikator
    #[serde(rename = "Z13")]
    Pruefidentifikator,
    /// Transaktions-Referenznummer
    #[serde(rename = "TN")]
    TransaktionsReferenznummer,
}

/// dokumententyp for PID 23009
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Dokumententyp {
    /// Prüfbericht
    #[serde(rename = "293")]
    Pruefbericht2,
}

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

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

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

/// Messlokation for PID 23009 — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Messlokation {
    /// Required (X [951] [509]). (an..35)
    pub meldepunkt_id: Option<String>,
    /// Required (unknown). ()
    pub messlokation_ref_id: Option<String>,
    /// Required (unknown). ()
    pub messlokation_ref_qualifier: Option<String>,
}

/// Nachricht for PID 23009 — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Optional. (an..70)
    pub dokumentennummer: Option<String>,
    /// Optional. (an..35)
    pub erstellungsdatum: Option<String>,
}

/// Position for PID 23009 — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Position {
    /// Required (X). (an..3)
    pub ablesedatum_format: Option<AblesedatumFormat>,
    /// Required (X). (an..3)
    pub antwort_status_anlass: Option<AntwortStatusAnlass>,
    /// Required (X). (an..3)
    pub antwort_status_code: Option<AntwortStatusCode>,
    /// Required (X ([931] [13] ∧ [495]) ⊻ ([495] ∧ [515])). (an..35)
    pub bearbeitungs_datum: Option<String>,
    /// Required (X ([931] [13] ∧ [495]) ⊻ ([495] ∧ [515])). (an..35)
    pub beginn_datum: Option<String>,
    /// Required (X). (an..3)
    pub beginn_datum_format: Option<BeginnDatumFormat>,
    /// Required (unknown). ()
    pub begruendung_funktion_code: Option<String>,
    /// Required (unknown). ()
    pub begruendung_referenz_code: Option<String>,
    /// Required (X). (an..512)
    pub begruendung_text1: Option<String>,
    /// Optional. (an..512)
    pub begruendung_text2: Option<String>,
    /// Optional. (an..512)
    pub begruendung_text3: Option<String>,
    /// Optional. (an..512)
    pub begruendung_text4: Option<String>,
    /// Optional. (an..512)
    pub begruendung_text5: Option<String>,
    /// Required (X). (an..3)
    pub berichtszeitraum_format: Option<BerichtszeitraumFormat>,
    /// Required (X ([931] [13] ∧ [495]) ⊻ ([495] ∧ [515])). (an..35)
    pub ende_datum: Option<String>,
    /// Required (X). (an..3)
    pub ende_datum_format: Option<EndeDatumFormat>,
    /// Required (unknown). ()
    pub fehler_funktion_code: Option<String>,
    /// Required (unknown). ()
    pub fehler_referenz_code: Option<String>,
    /// Required (X). (an..512)
    pub fehler_text1: Option<String>,
    /// Optional. (an..512)
    pub fehler_text2: Option<String>,
    /// Optional. (an..512)
    pub fehler_text3: Option<String>,
    /// Optional. (an..512)
    pub fehler_text4: Option<String>,
    /// Optional. (an..512)
    pub fehler_text5: Option<String>,
    /// Required (X ([931] [13] ∧ [495]) ⊻ ([495] ∧ [515])). (an..35)
    pub geplante_fertigstellung: Option<String>,
    /// Required (X). (an..3)
    pub geraete_status_anlass: Option<GeraeteStatusAnlass>,
    /// Required (X). (an..3)
    pub geraete_status_code: Option<GeraeteStatusCode>,
    /// Required (X [908] [511]). (an..6)
    pub positionsnummer: Option<String>,
}

/// Referenz for PID 23009 — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Referenz {
    /// Required (X). (an..70)
    pub referenz_nummer: Option<ReferenzNummer>,
    /// Required (X). (an..3)
    pub referenz_qualifier: Option<ReferenzQualifier>,
}

/// Vorgang for PID 23009 — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Vorgang {
    /// Required (X). (an..3)
    pub dokumententyp: Option<Dokumententyp>,
    /// Required (X). (an..70)
    pub vorgangsnummer: Option<String>,
}

/// PID 23009 transaction — Informations-meldung.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    pub messlokation: Option<Messlokation>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub position: Option<Vec<Position>>,
    pub referenz: Option<Referenz>,
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub vorgang: Option<Vec<Vorgang>>,
}

/// PID 23009 message-level — Informations-meldung.
#[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 23009 — Informations-meldung.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
