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

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

part 'sync_contact_channel.g.dart';

/// SyncContactChannel
///
/// Properties:
/// * [kind] 
/// * [position] - 1-basiert: spiegelt ERP-Spaltenposition (Telefon → 1, Telefon2 → 2, …).
/// * [value] 
@BuiltValue()
abstract class SyncContactChannel implements Built<SyncContactChannel, SyncContactChannelBuilder> {
  @BuiltValueField(wireName: r'kind')
  ContactKind get kind;
  // enum kindEnum {  phone,  mobile,  email,  web,  };

  /// 1-basiert: spiegelt ERP-Spaltenposition (Telefon → 1, Telefon2 → 2, …).
  @BuiltValueField(wireName: r'position')
  int get position;

  @BuiltValueField(wireName: r'value')
  String get value;

  SyncContactChannel._();

  factory SyncContactChannel([void updates(SyncContactChannelBuilder b)]) = _$SyncContactChannel;

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

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

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

  @override
  final String wireName = r'SyncContactChannel';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    SyncContactChannel object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'kind';
    yield serializers.serialize(
      object.kind,
      specifiedType: const FullType(ContactKind),
    );
    yield r'position';
    yield serializers.serialize(
      object.position,
      specifiedType: const FullType(int),
    );
    yield r'value';
    yield serializers.serialize(
      object.value,
      specifiedType: const FullType(String),
    );
  }

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

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

