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

/// Request für `PATCH /deliveries/{id}/notes/{note_id}`. Wie beim Create muss mindestens eines von `text` / `image_attachment` inhaltlich gefüllt sein — geprüft im Use Case.
///
/// Properties:
/// * [imageAttachment] - Object-Storage-Key oder URL eines vorab hochgeladenen Bildes.
/// * [text] 
@BuiltValue()
abstract class UpdateDeliveryNoteRequest implements Built<UpdateDeliveryNoteRequest, UpdateDeliveryNoteRequestBuilder> {
  /// Object-Storage-Key oder URL eines vorab hochgeladenen Bildes.
  @BuiltValueField(wireName: r'imageAttachment')
  String? get imageAttachment;

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

  UpdateDeliveryNoteRequest._();

  factory UpdateDeliveryNoteRequest([void updates(UpdateDeliveryNoteRequestBuilder b)]) = _$UpdateDeliveryNoteRequest;

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

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

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

  @override
  final String wireName = r'UpdateDeliveryNoteRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    UpdateDeliveryNoteRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.imageAttachment != null) {
      yield r'imageAttachment';
      yield serializers.serialize(
        object.imageAttachment,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.text != null) {
      yield r'text';
      yield serializers.serialize(
        object.text,
        specifiedType: const FullType.nullable(String),
      );
    }
  }

  @override
  Object serialize(
    Serializers serializers,
    UpdateDeliveryNoteRequest 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 UpdateDeliveryNoteRequestBuilder 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'imageAttachment':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.imageAttachment = 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
  UpdateDeliveryNoteRequest deserialize(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = UpdateDeliveryNoteRequestBuilder();
    final serializedList = (serialized as Iterable<Object?>).toList();
    final unhandled = <Object?>[];
    _deserializeProperties(
      serializers,
      serialized,
      specifiedType: specifiedType,
      serializedList: serializedList,
      unhandled: unhandled,
      result: result,
    );
    return result.build();
  }
}

