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

// ignore_for_file: unused_element
import 'package:holzleitner_api/src/model/delivery_credit.dart';
import 'package:holzleitner_api/src/model/delivery_note.dart';
import 'package:holzleitner_api/src/model/delivery_with_items.dart';
import 'package:holzleitner_api/src/model/article.dart';
import 'package:holzleitner_api/src/model/contact_channel.dart';
import 'package:holzleitner_api/src/model/customer.dart';
import 'package:holzleitner_api/src/model/contact_source.dart';
import 'package:holzleitner_api/src/model/tour.dart';
import 'package:holzleitner_api/src/model/warehouse.dart';
import 'package:built_collection/built_collection.dart';
import 'package:holzleitner_api/src/model/customer_contact.dart';
import 'package:holzleitner_api/src/model/service.dart';
import 'package:holzleitner_api/src/model/delivery_service_value.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'tour_details.g.dart';

/// TourDetails
///
/// Properties:
/// * [articles] 
/// * [contactChannels] - Die zu `contact_sources` gehörenden Einzel-Kanäle (Telefon, Mobil, E-Mail, Web). Join per `source_id`.
/// * [contactSources] - Alle vom ERP gespiegelten Kontaktquellen aller Lieferungen dieser Tour. Die App joint clientseitig per `delivery_id` und gruppiert nach `role` (Lieferadresse / Rechnungsadresse / Ansprechpartner / Kundenstamm / Belegadresse).
/// * [credits] - Aktuelle Betrags-Gutschriften (jüngster Stand pro Lieferung), nur für Lieferungen, deren letztes Ereignis `set` war. Join per `delivery_id`.
/// * [customerContacts] 
/// * [customers] 
/// * [deliveries] 
/// * [deliveryServices] - Pro-Lieferung gesetzte Service-Werte. Join per `delivery_id` + `service_id`.
/// * [notes] - Alle Notizen aller Lieferungen dieser Tour, in einer Liste. Die App joint clientseitig per `delivery_id`. Reihenfolge: pro Lieferung aufsteigend nach `created_at`.
/// * [services] - Aktive Service-Definitionen (Stammdaten) — die App rendert daraus Phase 4. Bewusst hier mitgeliefert, damit die Detailseite alles aus dem Tour-Aggregat hat.
/// * [tour] 
/// * [warehouses] 
@BuiltValue()
abstract class TourDetails implements Built<TourDetails, TourDetailsBuilder> {
  @BuiltValueField(wireName: r'articles')
  BuiltList<Article> get articles;

  /// Die zu `contact_sources` gehörenden Einzel-Kanäle (Telefon, Mobil, E-Mail, Web). Join per `source_id`.
  @BuiltValueField(wireName: r'contactChannels')
  BuiltList<ContactChannel> get contactChannels;

  /// Alle vom ERP gespiegelten Kontaktquellen aller Lieferungen dieser Tour. Die App joint clientseitig per `delivery_id` und gruppiert nach `role` (Lieferadresse / Rechnungsadresse / Ansprechpartner / Kundenstamm / Belegadresse).
  @BuiltValueField(wireName: r'contactSources')
  BuiltList<ContactSource> get contactSources;

  /// Aktuelle Betrags-Gutschriften (jüngster Stand pro Lieferung), nur für Lieferungen, deren letztes Ereignis `set` war. Join per `delivery_id`.
  @BuiltValueField(wireName: r'credits')
  BuiltList<DeliveryCredit> get credits;

  @BuiltValueField(wireName: r'customerContacts')
  BuiltList<CustomerContact> get customerContacts;

  @BuiltValueField(wireName: r'customers')
  BuiltList<Customer> get customers;

  @BuiltValueField(wireName: r'deliveries')
  BuiltList<DeliveryWithItems> get deliveries;

  /// Pro-Lieferung gesetzte Service-Werte. Join per `delivery_id` + `service_id`.
  @BuiltValueField(wireName: r'deliveryServices')
  BuiltList<DeliveryServiceValue> get deliveryServices;

  /// Alle Notizen aller Lieferungen dieser Tour, in einer Liste. Die App joint clientseitig per `delivery_id`. Reihenfolge: pro Lieferung aufsteigend nach `created_at`.
  @BuiltValueField(wireName: r'notes')
  BuiltList<DeliveryNote> get notes;

  /// Aktive Service-Definitionen (Stammdaten) — die App rendert daraus Phase 4. Bewusst hier mitgeliefert, damit die Detailseite alles aus dem Tour-Aggregat hat.
  @BuiltValueField(wireName: r'services')
  BuiltList<Service> get services;

  @BuiltValueField(wireName: r'tour')
  Tour get tour;

  @BuiltValueField(wireName: r'warehouses')
  BuiltList<Warehouse> get warehouses;

  TourDetails._();

  factory TourDetails([void updates(TourDetailsBuilder b)]) = _$TourDetails;

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

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

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

  @override
  final String wireName = r'TourDetails';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    TourDetails object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'articles';
    yield serializers.serialize(
      object.articles,
      specifiedType: const FullType(BuiltList, [FullType(Article)]),
    );
    yield r'contactChannels';
    yield serializers.serialize(
      object.contactChannels,
      specifiedType: const FullType(BuiltList, [FullType(ContactChannel)]),
    );
    yield r'contactSources';
    yield serializers.serialize(
      object.contactSources,
      specifiedType: const FullType(BuiltList, [FullType(ContactSource)]),
    );
    yield r'credits';
    yield serializers.serialize(
      object.credits,
      specifiedType: const FullType(BuiltList, [FullType(DeliveryCredit)]),
    );
    yield r'customerContacts';
    yield serializers.serialize(
      object.customerContacts,
      specifiedType: const FullType(BuiltList, [FullType(CustomerContact)]),
    );
    yield r'customers';
    yield serializers.serialize(
      object.customers,
      specifiedType: const FullType(BuiltList, [FullType(Customer)]),
    );
    yield r'deliveries';
    yield serializers.serialize(
      object.deliveries,
      specifiedType: const FullType(BuiltList, [FullType(DeliveryWithItems)]),
    );
    yield r'deliveryServices';
    yield serializers.serialize(
      object.deliveryServices,
      specifiedType: const FullType(BuiltList, [FullType(DeliveryServiceValue)]),
    );
    yield r'notes';
    yield serializers.serialize(
      object.notes,
      specifiedType: const FullType(BuiltList, [FullType(DeliveryNote)]),
    );
    yield r'services';
    yield serializers.serialize(
      object.services,
      specifiedType: const FullType(BuiltList, [FullType(Service)]),
    );
    yield r'tour';
    yield serializers.serialize(
      object.tour,
      specifiedType: const FullType(Tour),
    );
    yield r'warehouses';
    yield serializers.serialize(
      object.warehouses,
      specifiedType: const FullType(BuiltList, [FullType(Warehouse)]),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    TourDetails 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 TourDetailsBuilder 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'articles':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(Article)]),
          ) as BuiltList<Article>;
          result.articles.replace(valueDes);
          break;
        case r'contactChannels':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(ContactChannel)]),
          ) as BuiltList<ContactChannel>;
          result.contactChannels.replace(valueDes);
          break;
        case r'contactSources':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(ContactSource)]),
          ) as BuiltList<ContactSource>;
          result.contactSources.replace(valueDes);
          break;
        case r'credits':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(DeliveryCredit)]),
          ) as BuiltList<DeliveryCredit>;
          result.credits.replace(valueDes);
          break;
        case r'customerContacts':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(CustomerContact)]),
          ) as BuiltList<CustomerContact>;
          result.customerContacts.replace(valueDes);
          break;
        case r'customers':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(Customer)]),
          ) as BuiltList<Customer>;
          result.customers.replace(valueDes);
          break;
        case r'deliveries':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(DeliveryWithItems)]),
          ) as BuiltList<DeliveryWithItems>;
          result.deliveries.replace(valueDes);
          break;
        case r'deliveryServices':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(DeliveryServiceValue)]),
          ) as BuiltList<DeliveryServiceValue>;
          result.deliveryServices.replace(valueDes);
          break;
        case r'notes':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(DeliveryNote)]),
          ) as BuiltList<DeliveryNote>;
          result.notes.replace(valueDes);
          break;
        case r'services':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(Service)]),
          ) as BuiltList<Service>;
          result.services.replace(valueDes);
          break;
        case r'tour':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(Tour),
          ) as Tour;
          result.tour.replace(valueDes);
          break;
        case r'warehouses':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(Warehouse)]),
          ) as BuiltList<Warehouse>;
          result.warehouses.replace(valueDes);
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

