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

/// CreatePaymentMethodRequest
///
/// Properties:
/// * [code] - Eindeutiger Programm-Identifier (z. B. `\"paypal\"`, `\"klarna\"`).
/// * [name] - Anzeige-Name in der UI.
@BuiltValue()
abstract class CreatePaymentMethodRequest implements Built<CreatePaymentMethodRequest, CreatePaymentMethodRequestBuilder> {
  /// Eindeutiger Programm-Identifier (z. B. `\"paypal\"`, `\"klarna\"`).
  @BuiltValueField(wireName: r'code')
  String get code;

  /// Anzeige-Name in der UI.
  @BuiltValueField(wireName: r'name')
  String get name;

  CreatePaymentMethodRequest._();

  factory CreatePaymentMethodRequest([void updates(CreatePaymentMethodRequestBuilder b)]) = _$CreatePaymentMethodRequest;

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

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

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

  @override
  final String wireName = r'CreatePaymentMethodRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    CreatePaymentMethodRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'code';
    yield serializers.serialize(
      object.code,
      specifiedType: const FullType(String),
    );
    yield r'name';
    yield serializers.serialize(
      object.name,
      specifiedType: const FullType(String),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    CreatePaymentMethodRequest 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 CreatePaymentMethodRequestBuilder 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'code':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.code = valueDes;
          break;
        case r'name':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.name = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

