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

/// SyncDeliveryItem
///
/// Properties:
/// * [articleDefaultWarehouseCode] - Default-Lager-Code für den Artikel (Anlage neuer Artikel).
/// * [articleName] 
/// * [articleNumber] 
/// * [articleScannable] 
/// * [belegzeilenNr] 
/// * [komponentenArtikelNr] - Komponenten-Artikelnummer bei aufgelösten Stücklisten, sonst leer. Trägt die **eigene** Nummer der Komponente (eindeutig je Belegzeile).
/// * [parentArtikelNr] - Artikelnummer des **Oberartikels**, zu dem diese Komponente gehört. `None` bei Oberartikeln/regulären Zeilen. Erlaubt der App, Komponenten unter ihrem Oberartikel einzurücken.
/// * [requiredQuantity] 
/// * [unitPrice] - Stückpreis (brutto, EUR). Default `0.0`. Liefert der ERP-Sync mit; die App rechnet daraus den Warenwert.
/// * [warehouseCode] 
/// * [warehouseName] 
@BuiltValue()
abstract class SyncDeliveryItem implements Built<SyncDeliveryItem, SyncDeliveryItemBuilder> {
  /// Default-Lager-Code für den Artikel (Anlage neuer Artikel).
  @BuiltValueField(wireName: r'articleDefaultWarehouseCode')
  String? get articleDefaultWarehouseCode;

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

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

  @BuiltValueField(wireName: r'articleScannable')
  bool get articleScannable;

  @BuiltValueField(wireName: r'belegzeilenNr')
  int get belegzeilenNr;

  /// Komponenten-Artikelnummer bei aufgelösten Stücklisten, sonst leer. Trägt die **eigene** Nummer der Komponente (eindeutig je Belegzeile).
  @BuiltValueField(wireName: r'komponentenArtikelNr')
  String? get komponentenArtikelNr;

  /// Artikelnummer des **Oberartikels**, zu dem diese Komponente gehört. `None` bei Oberartikeln/regulären Zeilen. Erlaubt der App, Komponenten unter ihrem Oberartikel einzurücken.
  @BuiltValueField(wireName: r'parentArtikelNr')
  String? get parentArtikelNr;

  @BuiltValueField(wireName: r'requiredQuantity')
  int get requiredQuantity;

  /// Stückpreis (brutto, EUR). Default `0.0`. Liefert der ERP-Sync mit; die App rechnet daraus den Warenwert.
  @BuiltValueField(wireName: r'unitPrice')
  double? get unitPrice;

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

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

  SyncDeliveryItem._();

  factory SyncDeliveryItem([void updates(SyncDeliveryItemBuilder b)]) = _$SyncDeliveryItem;

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

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

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

  @override
  final String wireName = r'SyncDeliveryItem';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    SyncDeliveryItem object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.articleDefaultWarehouseCode != null) {
      yield r'articleDefaultWarehouseCode';
      yield serializers.serialize(
        object.articleDefaultWarehouseCode,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'articleName';
    yield serializers.serialize(
      object.articleName,
      specifiedType: const FullType(String),
    );
    yield r'articleNumber';
    yield serializers.serialize(
      object.articleNumber,
      specifiedType: const FullType(String),
    );
    yield r'articleScannable';
    yield serializers.serialize(
      object.articleScannable,
      specifiedType: const FullType(bool),
    );
    yield r'belegzeilenNr';
    yield serializers.serialize(
      object.belegzeilenNr,
      specifiedType: const FullType(int),
    );
    if (object.komponentenArtikelNr != null) {
      yield r'komponentenArtikelNr';
      yield serializers.serialize(
        object.komponentenArtikelNr,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.parentArtikelNr != null) {
      yield r'parentArtikelNr';
      yield serializers.serialize(
        object.parentArtikelNr,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'requiredQuantity';
    yield serializers.serialize(
      object.requiredQuantity,
      specifiedType: const FullType(int),
    );
    if (object.unitPrice != null) {
      yield r'unitPrice';
      yield serializers.serialize(
        object.unitPrice,
        specifiedType: const FullType(double),
      );
    }
    yield r'warehouseCode';
    yield serializers.serialize(
      object.warehouseCode,
      specifiedType: const FullType(String),
    );
    yield r'warehouseName';
    yield serializers.serialize(
      object.warehouseName,
      specifiedType: const FullType(String),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    SyncDeliveryItem 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 SyncDeliveryItemBuilder 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'articleDefaultWarehouseCode':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.articleDefaultWarehouseCode = valueDes;
          break;
        case r'articleName':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.articleName = valueDes;
          break;
        case r'articleNumber':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.articleNumber = valueDes;
          break;
        case r'articleScannable':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(bool),
          ) as bool;
          result.articleScannable = valueDes;
          break;
        case r'belegzeilenNr':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(int),
          ) as int;
          result.belegzeilenNr = valueDes;
          break;
        case r'komponentenArtikelNr':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.komponentenArtikelNr = valueDes;
          break;
        case r'parentArtikelNr':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.parentArtikelNr = valueDes;
          break;
        case r'requiredQuantity':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(int),
          ) as int;
          result.requiredQuantity = valueDes;
          break;
        case r'unitPrice':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(double),
          ) as double;
          result.unitPrice = valueDes;
          break;
        case r'warehouseCode':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.warehouseCode = valueDes;
          break;
        case r'warehouseName':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.warehouseName = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

