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

// ignore_for_file: unused_element
import 'package:built_collection/built_collection.dart';
import 'package:holzleitner_api/src/model/tour_summary.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'tour_summary_list.g.dart';

/// Antwort-Hülle für `GET /me/tours/today`. Eigenes Struct, weil utoipa für `Vec<T>` als Top-Level-Response keinen sauberen Schemanamen vergibt — und ein Wrapper macht die Erweiterbarkeit (z. B. Paginierung in Zukunft) zur Nicht-Breaking-Change.
///
/// Properties:
/// * [tours] 
@BuiltValue()
abstract class TourSummaryList implements Built<TourSummaryList, TourSummaryListBuilder> {
  @BuiltValueField(wireName: r'tours')
  BuiltList<TourSummary> get tours;

  TourSummaryList._();

  factory TourSummaryList([void updates(TourSummaryListBuilder b)]) = _$TourSummaryList;

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

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

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

  @override
  final String wireName = r'TourSummaryList';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    TourSummaryList object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'tours';
    yield serializers.serialize(
      object.tours,
      specifiedType: const FullType(BuiltList, [FullType(TourSummary)]),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    TourSummaryList 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 TourSummaryListBuilder 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'tours':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(TourSummary)]),
          ) as BuiltList<TourSummary>;
          result.tours.replace(valueDes);
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

