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

/// UpdateCarRequest
///
/// Properties:
/// * [active] - Wenn gesetzt: aktiv/inaktiv. Inaktive Fahrzeuge tauchen in `GET /me/cars?activeOnly=true` (default) nicht auf.
/// * [plate] - Wenn gesetzt: neues Kennzeichen.
@BuiltValue()
abstract class UpdateCarRequest implements Built<UpdateCarRequest, UpdateCarRequestBuilder> {
  /// Wenn gesetzt: aktiv/inaktiv. Inaktive Fahrzeuge tauchen in `GET /me/cars?activeOnly=true` (default) nicht auf.
  @BuiltValueField(wireName: r'active')
  bool? get active;

  /// Wenn gesetzt: neues Kennzeichen.
  @BuiltValueField(wireName: r'plate')
  String? get plate;

  UpdateCarRequest._();

  factory UpdateCarRequest([void updates(UpdateCarRequestBuilder b)]) = _$UpdateCarRequest;

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

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

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

  @override
  final String wireName = r'UpdateCarRequest';

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

  @override
  Object serialize(
    Serializers serializers,
    UpdateCarRequest 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 UpdateCarRequestBuilder 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'active':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(bool),
          ) as bool?;
          if (valueDes == null) continue;
          result.active = valueDes;
          break;
        case r'plate':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.plate = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

