import 'package:cheminova/models/rd_order_item_model.dart';

class PlacedOrdersProcessing {
  final String orderId;
  final List<RDOrderItem> invoiceItems;

  PlacedOrdersProcessing({
    required this.orderId,
    required this.invoiceItems,
  });

  // Factory constructor for creating an instance from JSON
  factory PlacedOrdersProcessing.fromJson(Map<String, dynamic> json) {
    return PlacedOrdersProcessing(
      orderId: json['orderId'] ?? '',  // Handle missing or null values
      invoiceItems: (json['invoiceItems'] as List)
          .map((item) => RDOrderItem.fromJson(item))
          .toList(),
    );
  }

  // Method to convert instance to JSON
  Map<String, dynamic> toJson() {
    return {
      'orderId': orderId,
      'invoiceItems': invoiceItems.map((item) => item.toJson()).toList(),
    };
  }

  // Overriding toString method
  @override
  String toString() {
    return 'PlacedOrdersProcessing(orderId: $orderId, invoiceItems: $invoiceItems)';
  }
}
