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

/// anredeCode for PID 55136
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AnredeCode {
    /// Struktur von Personennamen
    #[serde(rename = "Z01")]
    StrukturPersonennamen,
    /// Struktur der Firmenbezeichnung
    #[serde(rename = "Z02")]
    StrukturFirmenbezeichnung,
}

/// partnerrolle for PID 55136
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Partnerrolle {
    /// Erwarteter Kunde des LF
    #[serde(rename = "Z47")]
    ErwarteterKundeLf,
    /// Im System vorhandener Kunde des LF
    #[serde(rename = "Z48")]
    SystemVorhandenerKundeLf,
}

/// kommunikationsart for PID 55136
#[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 55136
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kontaktfunktion {
    /// Informationskontakt
    #[serde(rename = "IC")]
    Informationskontakt,
}

/// marktrolle for PID 55136
#[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 55136
#[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,
}

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

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

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

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

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

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

/// Map key for Geschaeftspartner instances.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum GeschaeftspartnerKey {
    #[serde(rename = "Z47_Z48")]
    Z47_z48,
    #[serde(rename = "Z47")]
    Z47,
    #[serde(rename = "Z48")]
    Z48,
    #[serde(rename = "Z49_Z50")]
    Z49_z50,
    #[serde(rename = "Z49")]
    Z49,
    #[serde(rename = "Z50")]
    Z50,
}

impl std::fmt::Display for GeschaeftspartnerKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Z47_z48 => write!(f, "Z47_Z48"),
            Self::Z47 => write!(f, "Z47"),
            Self::Z48 => write!(f, "Z48"),
            Self::Z49_z50 => write!(f, "Z49_Z50"),
            Self::Z49 => write!(f, "Z49"),
            Self::Z50 => write!(f, "Z50"),
        }
    }
}

/// 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 55136 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Geschaeftspartner {
    /// Optional. (an..35)
    pub adresszusatz: Option<String>,
    /// Optional. (an..70)
    pub anrede: Option<String>,
    /// Required (X). (an..3)
    pub anrede_code: Option<AnredeCode>,
    /// Required (Soll [8]). ()
    pub codelist_code: Option<String>,
    /// Required (Soll [8]). ()
    pub codepflege_code: Option<String>,
    /// Optional. (an..35)
    pub hausnummer: Option<String>,
    /// Required (Soll [8]). ()
    pub identifikation: Option<String>,
    /// Required (X). (an..3)
    pub land: Option<String>,
    /// Required (X). (an..70)
    pub nachname: Option<String>,
    /// Optional. (an..70)
    pub namenszusatz1: Option<String>,
    /// Optional. (an..70)
    pub namenszusatz2: Option<String>,
    /// Required (X). (an..35)
    pub ort: Option<String>,
    /// Required (X [1P0..1]). (an..3)
    pub partnerrolle: Option<Partnerrolle>,
    /// Required (M [268] S [166]). (an..17)
    pub postleitzahl: Option<String>,
    /// Required (Soll [8]). ()
    pub region: Option<String>,
    /// Required (X). (an..35)
    pub strasse: Option<String>,
    /// Optional. (an..35)
    pub strasse_zusatz: Option<String>,
    /// Optional. (an..70)
    pub vorname: Option<String>,
    pub zeitscheibe: Option<GeschaeftspartnerZeitscheibe>,
    /// Required (Soll [8]). ()
    pub zusatzinfo: Option<String>,
}

/// Kontakt for PID 55136 — 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 (([939] [321]) ∨ ([940] [322])) ∧ [514]). (an..512)
    pub kommunikationsnummer: Option<String>,
    pub kontakt: Option<KontaktKontakt>,
    /// Required (X). (an..3)
    pub kontaktfunktion: Option<Kontaktfunktion>,
}

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

/// Marktteilnehmer for PID 55136 — 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>,
    pub kontakt: Option<Kontakt>,
}

/// Nachricht for PID 55136 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Nachricht {
    /// Required (X [931] [494]). (an..35)
    pub erstellungsdatum: Option<String>,
    /// Optional. ()
    pub nachrichtennummer: Option<String>,
    /// Optional. ()
    pub nachrichtentyp: Option<String>,
}

/// Prozessdaten for PID 55136 — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Prozessdaten {
    /// Required (unknown). ()
    pub ebd_codepflege: Option<String>,
    /// Required (unknown). ()
    pub ebd_nummer: Option<String>,
    /// 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..70)
    pub transaktionsnummer: Option<Transaktionsnummer>,
    /// Required (X). (an..35)
    pub vorgang_id: Option<String>,
    /// Required (unknown). ()
    pub zeitraum_id_ref: Option<String>,
}

/// PID 55136 transaction — Rückmeldung/Anfrage Daten der MaLo.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct Transaktion {
    /// Required (Soll [8]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_map_or_vec")]
    pub geschaeftspartner: Option<BTreeMap<GeschaeftspartnerKey, Geschaeftspartner>>,
    /// Required (Muss [2061]).
    #[serde(default, deserialize_with = "crate::serde_helpers::deserialize_vec_or_single")]
    pub marktlokation: Option<Vec<Marktlokation>>,
    pub prozessdaten: Option<Prozessdaten>,
}

/// PID 55136 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 55136 — Rückmeldung/Anfrage Daten der MaLo.
pub type Interchange = crate::model::Interchange<Message, Transaktion>;
