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

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

part 'delivery_credit_response.g.dart';

/// DeliveryCreditResponse
///
/// Properties:
/// * [credit] - Aktueller Stand nach dem Ereignis — `None`, wenn (zuletzt) entfernt.
@BuiltValue()
abstract class DeliveryCreditResponse implements Built<DeliveryCreditResponse, DeliveryCreditResponseBuilder> {
  /// Aktueller Stand nach dem Ereignis — `None`, wenn (zuletzt) entfernt.
  @BuiltValueField(wireName: r'credit')
  DeliveryCredit? get credit;

  DeliveryCreditResponse._();

  factory DeliveryCreditResponse([void updates(DeliveryCreditResponseBuilder b)]) = _$DeliveryCreditResponse;

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

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

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

  @override
  final String wireName = r'DeliveryCreditResponse';

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

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

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

