import 'dart:convert'; class OrderRequestModel { final String? outletId; final String? customerId; final String? tableNumber; final String? tableId; final String? orderType; final String? notes; final List? orderItems; final String? customerName; OrderRequestModel({ this.outletId, this.customerId, this.tableNumber, this.tableId, this.orderType, this.notes, this.orderItems, this.customerName, }); factory OrderRequestModel.fromJson(String str) => OrderRequestModel.fromMap(json.decode(str)); String toJson() => json.encode(toMap()); factory OrderRequestModel.fromMap(Map json) => OrderRequestModel( outletId: json["outlet_id"], customerId: json["customer_id"], tableNumber: json["table_number"], tableId: json["table_id"], orderType: json["order_type"], notes: json["notes"], orderItems: json["order_items"] == null ? [] : List.from( json["order_items"].map((x) => OrderItemRequest.fromMap(x))), customerName: json["customer_name"], ); Map toMap() => { "outlet_id": outletId, "customer_id": customerId, "table_number": tableNumber, "table_id": tableId, "order_type": orderType, "notes": notes, "order_items": orderItems == null ? [] : List.from(orderItems!.map((x) => x.toMap())), "customer_name": customerName, }; } class OrderItemRequest { final String? productId; final String? productVariantId; final int? quantity; final int? unitPrice; final String? notes; OrderItemRequest({ this.productId, this.productVariantId, this.quantity, this.unitPrice, this.notes, }); factory OrderItemRequest.fromJson(String str) => OrderItemRequest.fromMap(json.decode(str)); factory OrderItemRequest.fromMap(Map json) => OrderItemRequest( productId: json["product_id"], productVariantId: json["product_variant_id"], quantity: json["quantity"], unitPrice: json["unit_price"]?.toDouble(), notes: json["notes"], ); Map toMap() => { "product_id": productId, "product_variant_id": productVariantId, "quantity": quantity, "unit_price": unitPrice, "notes": notes, }; }