import 'package:mitra_corporate/model/order_model.dart';

class CreateSuratJalanModel {
  Order? order;
  List<OrderModel>? orderDetail;
  String? token;

  CreateSuratJalanModel({this.order, this.orderDetail, this.token});

  CreateSuratJalanModel.fromJson(Map<String, dynamic> json) {
    order = json['order'] != null ? Order.fromJson(json['order']) : null;
    if (json['order_detail'] != null) {
      orderDetail = <OrderModel>[];
      json['order_detail'].forEach((v) {
        orderDetail!.add(OrderModel.fromJson(v));
      });
    }
    token = json['token'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (order != null) {
      data['order'] = order!.toJson();
    }
    if (orderDetail != null) {
      data['order_detail'] = orderDetail!.map((v) => v.toJson()).toList();
    }
    data['token'] = token;
    return data;
  }
}

class Order {
  String? staffId;
  String? noRef;
  String? date;
  String? regionalId;
  String? regionalName;
  String? destinationId;
  String? destinationName;
  String? temperature;
  String? typeId;
  String? typeName;
  String? noResi;
  String? note;
  String? branchCode;
  String? companyId;

  Order(
      {this.staffId,
      this.noRef,
      this.date,
      this.destinationId,
      this.temperature,
      this.typeId,
      this.noResi,
      this.typeName,
      this.note,
      this.regionalId,
      this.regionalName,
      this.destinationName,
      this.branchCode,
      this.companyId});

  Order.fromJson(Map<String, dynamic> json) {
    staffId = json['staff_id'];
    noRef = json['no_ref'];
    date = json['date'];
    destinationId = json['destination_id'];
    regionalId = json['regional_id'];
    regionalName = json['regional_name'];
    destinationName = json['destination_name'];
    temperature = json['temperature'];
    typeId = json['type_id'];
    noResi = json['no_resi'];
    note = json['note'];
    branchCode = json['branch_code'];
    companyId = json['company_id'];
    typeName = json['type_name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['staff_id'] = staffId;
    data['no_ref'] = noRef;
    data['date'] = date;
    data['destination_id'] = destinationId;
    data['regional_id'] = regionalId;
    data['regional_name'] = regionalName;
    data['destination_name'] = destinationName;
    data['temperature'] = temperature;
    data['type_id'] = typeId;
    data['no_resi'] = noResi;
    data['note'] = note;
    data['branch_code'] = branchCode;
    data['company_id'] = companyId;
    data['type_name'] = typeName;
    return data;
  }
}
