//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//

// ignore_for_file: unused_element
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'delivery_note.g.dart';

/// Notiz an einer Lieferung — frei eingegeben durch den Fahrer.  Mindestens eines von `text` oder `image_attachment` muss gesetzt sein. Die Constraint sitzt sowohl im DB-Schema (CHECK) als auch in der Application-Schicht.
///
/// Properties:
/// * [authorCarId] - Fahrzeug, falls bekannt — nullable bis das Backend Cars verwaltet.
/// * [authorPersonalnummer] - Personalnummer des Akteurs (aus dem JWT). Pflicht.
/// * [createdAt] 
/// * [creditDeliveryItemId] - Wenn die Notiz als Gutschrift-Grund zu einer Belegzeile angelegt wurde: deren `DeliveryItem`-Id. Erlaubt dem Client, die Notiz beim Zurücknehmen der Gutschrift (Unremove) gezielt wieder zu löschen. `None` bei normalen Text-/Foto-Notizen.
/// * [deliveryId] 
/// * [id] 
/// * [imageAttachment] - Referenz auf einen Bild-Anhang (z. B. Object-Storage-Key/URL).
/// * [imageAttachmentDeleted] - `true`, wenn die lokale Bilddatei nach erfolgreichem Report-Upload gelöscht wurde (das Bild steckt nun im Lieferbericht in DOCUframe). Read-only; die App zeigt dann statt der Vorschau einen Hinweis. Bei Text-Notizen / vorhandenem Bild: `false`.
/// * [isAmountCreditNote] - `true`, wenn die Notiz den Grund einer **Betrags-Gutschrift** (Geld-Nachlass, Lieferungs-Ebene) dokumentiert. Erlaubt dem Client, sie beim Entfernen der Gutschrift gezielt zu löschen.
/// * [text] 
@BuiltValue()
abstract class DeliveryNote implements Built<DeliveryNote, DeliveryNoteBuilder> {
  /// Fahrzeug, falls bekannt — nullable bis das Backend Cars verwaltet.
  @BuiltValueField(wireName: r'authorCarId')
  String? get authorCarId;

  /// Personalnummer des Akteurs (aus dem JWT). Pflicht.
  @BuiltValueField(wireName: r'authorPersonalnummer')
  int get authorPersonalnummer;

  @BuiltValueField(wireName: r'createdAt')
  DateTime get createdAt;

  /// Wenn die Notiz als Gutschrift-Grund zu einer Belegzeile angelegt wurde: deren `DeliveryItem`-Id. Erlaubt dem Client, die Notiz beim Zurücknehmen der Gutschrift (Unremove) gezielt wieder zu löschen. `None` bei normalen Text-/Foto-Notizen.
  @BuiltValueField(wireName: r'creditDeliveryItemId')
  String? get creditDeliveryItemId;

  @BuiltValueField(wireName: r'deliveryId')
  String get deliveryId;

  @BuiltValueField(wireName: r'id')
  String get id;

  /// Referenz auf einen Bild-Anhang (z. B. Object-Storage-Key/URL).
  @BuiltValueField(wireName: r'imageAttachment')
  String? get imageAttachment;

  /// `true`, wenn die lokale Bilddatei nach erfolgreichem Report-Upload gelöscht wurde (das Bild steckt nun im Lieferbericht in DOCUframe). Read-only; die App zeigt dann statt der Vorschau einen Hinweis. Bei Text-Notizen / vorhandenem Bild: `false`.
  @BuiltValueField(wireName: r'imageAttachmentDeleted')
  bool? get imageAttachmentDeleted;

  /// `true`, wenn die Notiz den Grund einer **Betrags-Gutschrift** (Geld-Nachlass, Lieferungs-Ebene) dokumentiert. Erlaubt dem Client, sie beim Entfernen der Gutschrift gezielt zu löschen.
  @BuiltValueField(wireName: r'isAmountCreditNote')
  bool get isAmountCreditNote;

  @BuiltValueField(wireName: r'text')
  String? get text;

  DeliveryNote._();

  factory DeliveryNote([void updates(DeliveryNoteBuilder b)]) = _$DeliveryNote;

  @BuiltValueHook(initializeBuilder: true)
  static void _defaults(DeliveryNoteBuilder b) => b;

  @BuiltValueSerializer(custom: true)
  static Serializer<DeliveryNote> get serializer => _$DeliveryNoteSerializer();
}

class _$DeliveryNoteSerializer implements PrimitiveSerializer<DeliveryNote> {
  @override
  final Iterable<Type> types = const [DeliveryNote, _$DeliveryNote];

  @override
  final String wireName = r'DeliveryNote';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    DeliveryNote object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.authorCarId != null) {
      yield r'authorCarId';
      yield serializers.serialize(
        object.authorCarId,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'authorPersonalnummer';
    yield serializers.serialize(
      object.authorPersonalnummer,
      specifiedType: const FullType(int),
    );
    yield r'createdAt';
    yield serializers.serialize(
      object.createdAt,
      specifiedType: const FullType(DateTime),
    );
    if (object.creditDeliveryItemId != null) {
      yield r'creditDeliveryItemId';
      yield serializers.serialize(
        object.creditDeliveryItemId,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'deliveryId';
    yield serializers.serialize(
      object.deliveryId,
      specifiedType: const FullType(String),
    );
    yield r'id';
    yield serializers.serialize(
      object.id,
      specifiedType: const FullType(String),
    );
    if (object.imageAttachment != null) {
      yield r'imageAttachment';
      yield serializers.serialize(
        object.imageAttachment,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.imageAttachmentDeleted != null) {
      yield r'imageAttachmentDeleted';
      yield serializers.serialize(
        object.imageAttachmentDeleted,
        specifiedType: const FullType(bool),
      );
    }
    yield r'isAmountCreditNote';
    yield serializers.serialize(
      object.isAmountCreditNote,
      specifiedType: const FullType(bool),
    );
    if (object.text != null) {
      yield r'text';
      yield serializers.serialize(
        object.text,
        specifiedType: const FullType.nullable(String),
      );
    }
  }

  @override
  Object serialize(
    Serializers serializers,
    DeliveryNote object, {
    FullType specifiedType = FullType.unspecified,
  }) {
    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
  }

  void _deserializeProperties(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
    required List<Object?> serializedList,
    required DeliveryNoteBuilder result,
    required List<Object?> unhandled,
  }) {
    for (var i = 0; i < serializedList.length; i += 2) {
      final key = serializedList[i] as String;
      final value = serializedList[i + 1];
      switch (key) {
        case r'authorCarId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.authorCarId = valueDes;
          break;
        case r'authorPersonalnummer':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(int),
          ) as int;
          result.authorPersonalnummer = valueDes;
          break;
        case r'createdAt':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(DateTime),
          ) as DateTime;
          result.createdAt = valueDes;
          break;
        case r'creditDeliveryItemId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.creditDeliveryItemId = valueDes;
          break;
        case r'deliveryId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.deliveryId = valueDes;
          break;
        case r'id':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.id = valueDes;
          break;
        case r'imageAttachment':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.imageAttachment = valueDes;
          break;
        case r'imageAttachmentDeleted':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(bool),
          ) as bool;
          result.imageAttachmentDeleted = valueDes;
          break;
        case r'isAmountCreditNote':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(bool),
          ) as bool;
          result.isAmountCreditNote = valueDes;
          break;
        case r'text':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.text = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

  @override
  DeliveryNote deserialize(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = DeliveryNoteBuilder();
    final serializedList = (serialized as Iterable<Object?>).toList();
    final unhandled = <Object?>[];
    _deserializeProperties(
      serializers,
      serialized,
      specifiedType: specifiedType,
      serializedList: serializedList,
      unhandled: unhandled,
      result: result,
    );
    return result.build();
  }
}

