//
// 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 'create_delivery_note_request.g.dart';

/// CreateDeliveryNoteRequest
///
/// Properties:
/// * [authorCarId] - Fahrzeug, das die Notiz erzeugt hat. Muss zum angemeldeten Account gehören. `None` ist erlaubt.
/// * [creditDeliveryItemId] - Optionaler Gutschrift-Bezug: die Belegzeile, für die diese Notiz als Gutschrift-Grund angelegt wird. Ermöglicht das gezielte Löschen beim Unremove. `None` für normale Notizen.
/// * [imageAttachment] - Object-Storage-Key oder URL eines vorab hochgeladenen Bildes.
/// * [isAmountCreditNote] - `true` markiert die Notiz als Grund einer Betrags-Gutschrift (Lieferungs-Ebene). Default `false`.
/// * [text] 
@BuiltValue()
abstract class CreateDeliveryNoteRequest implements Built<CreateDeliveryNoteRequest, CreateDeliveryNoteRequestBuilder> {
  /// Fahrzeug, das die Notiz erzeugt hat. Muss zum angemeldeten Account gehören. `None` ist erlaubt.
  @BuiltValueField(wireName: r'authorCarId')
  String? get authorCarId;

  /// Optionaler Gutschrift-Bezug: die Belegzeile, für die diese Notiz als Gutschrift-Grund angelegt wird. Ermöglicht das gezielte Löschen beim Unremove. `None` für normale Notizen.
  @BuiltValueField(wireName: r'creditDeliveryItemId')
  String? get creditDeliveryItemId;

  /// Object-Storage-Key oder URL eines vorab hochgeladenen Bildes.
  @BuiltValueField(wireName: r'imageAttachment')
  String? get imageAttachment;

  /// `true` markiert die Notiz als Grund einer Betrags-Gutschrift (Lieferungs-Ebene). Default `false`.
  @BuiltValueField(wireName: r'isAmountCreditNote')
  bool? get isAmountCreditNote;

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

  CreateDeliveryNoteRequest._();

  factory CreateDeliveryNoteRequest([void updates(CreateDeliveryNoteRequestBuilder b)]) = _$CreateDeliveryNoteRequest;

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

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

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

  @override
  final String wireName = r'CreateDeliveryNoteRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    CreateDeliveryNoteRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.authorCarId != null) {
      yield r'authorCarId';
      yield serializers.serialize(
        object.authorCarId,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.creditDeliveryItemId != null) {
      yield r'creditDeliveryItemId';
      yield serializers.serialize(
        object.creditDeliveryItemId,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.imageAttachment != null) {
      yield r'imageAttachment';
      yield serializers.serialize(
        object.imageAttachment,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.isAmountCreditNote != null) {
      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,
    CreateDeliveryNoteRequest 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 CreateDeliveryNoteRequestBuilder 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'creditDeliveryItemId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.creditDeliveryItemId = 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'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
  CreateDeliveryNoteRequest deserialize(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = CreateDeliveryNoteRequestBuilder();
    final serializedList = (serialized as Iterable<Object?>).toList();
    final unhandled = <Object?>[];
    _deserializeProperties(
      serializers,
      serialized,
      specifiedType: specifiedType,
      serializedList: serializedList,
      unhandled: unhandled,
      result: result,
    );
    return result.build();
  }
}

