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

/// UpdatePaymentMethodRequest
///
/// Properties:
/// * [active] - Wenn gesetzt: aktiv/inaktiv. Inaktive Methoden bleiben für historische Lieferungen referenzierbar, tauchen aber im Default-Listing nicht auf.
/// * [name] - Wenn gesetzt: neuer Anzeige-Name.
@BuiltValue()
abstract class UpdatePaymentMethodRequest implements Built<UpdatePaymentMethodRequest, UpdatePaymentMethodRequestBuilder> {
  /// Wenn gesetzt: aktiv/inaktiv. Inaktive Methoden bleiben für historische Lieferungen referenzierbar, tauchen aber im Default-Listing nicht auf.
  @BuiltValueField(wireName: r'active')
  bool? get active;

  /// Wenn gesetzt: neuer Anzeige-Name.
  @BuiltValueField(wireName: r'name')
  String? get name;

  UpdatePaymentMethodRequest._();

  factory UpdatePaymentMethodRequest([void updates(UpdatePaymentMethodRequestBuilder b)]) = _$UpdatePaymentMethodRequest;

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

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

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

  @override
  final String wireName = r'UpdatePaymentMethodRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    UpdatePaymentMethodRequest 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.name != null) {
      yield r'name';
      yield serializers.serialize(
        object.name,
        specifiedType: const FullType.nullable(String),
      );
    }
  }

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

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

