import 'package:test_sa/models/base.dart';

class MedicalGasSupplierModel extends Base {
  int? id;
  String? supplier;
  String? supplierEmail;
  String? supplierContact;
  List<AttributeInfo>? attributeInfo;

  MedicalGasSupplierModel({this.id, this.supplier, this.supplierContact, this.supplierEmail, this.attributeInfo}) : super(identifier: id?.toString() ?? '', name: supplier);

  MedicalGasSupplierModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    identifier = id?.toString() ?? '';
    supplier = json['supplier'];
    name = supplier;
    supplierEmail = json['supplierEmail'];
    supplierContact = json['supplierContact'];
    if (json['attributeInfoDtos'] != null) {
      attributeInfo = [];
      json['attributeInfoDtos'].forEach((v) {
        attributeInfo!.add(AttributeInfo.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'supplier': supplier,
      'supplierEmail': supplierEmail,
      'supplierContact': supplierContact,
      'attributeInfoDtos': attributeInfo?.map((e) => e.toJson()).toList(),
    };
  }
}

class AttributeInfo {
  int? id;
  int? medicalGasAttributeId;
  num? requestedQuantity;
  num? value;
  String? itemName;
  String? oracleName;
  String? oracleCode;

  AttributeInfo({this.id, this.medicalGasAttributeId, this.requestedQuantity, this.itemName, this.value, this.oracleName, this.oracleCode});

  AttributeInfo.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    medicalGasAttributeId = json['medicalGasAttributeId'];
    requestedQuantity = json['value'] ?? json['requestedQuantity'];
    value = json['value'];
    itemName = json['itemName'];
    oracleName = json['oracleName'];
    oracleCode = json['oracleCode'];
  }

  Map<String, dynamic> toJson() {
    //{
    //       "id": 0,
    //       "medicalGasAttributeId": 0,
    //       "requestedQuantity": 0
    //     }
    return {
      'id': id,
      'medicalGasAttributeId': medicalGasAttributeId,
      'requestedQuantity': requestedQuantity,
      // 'oracleCode': oracleCode,
    };
  }
}
