/// result : {"code":"0","description":"Successfully completed"}
/// transactions : {"transaction":[{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]}
/// closeDayResults : {"reconciliationResult":[{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]}

class HalykCloseDayDao {
  ResultBean? result;
  TransactionsBean? transactions;
  CloseDayResultsBean? closeDayResults;

  HalykCloseDayDao({ this.result, this.closeDayResults, this.transactions});

  static HalykCloseDayDao? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    HalykCloseDayDao halykCloseDayDaoBean = HalykCloseDayDao();
    halykCloseDayDaoBean.result = ResultBean.fromMap(map['result']);
    halykCloseDayDaoBean.transactions = TransactionsBean.fromMap(map['transactions']);
    halykCloseDayDaoBean.closeDayResults = CloseDayResultsBean.fromMap(map['closeDayResults']);
    return halykCloseDayDaoBean;
  }

  Map toJson() => {
    "result": result,
    "transactions": transactions,
    "closeDayResults": closeDayResults,
  };
}

/// reconciliationResult : [{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]

class CloseDayResultsBean {
  List<ReconciliationResultBean>? reconciliationResult;

  static CloseDayResultsBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    CloseDayResultsBean closeDayResultsBean = CloseDayResultsBean();
    closeDayResultsBean.reconciliationResult = List.empty()..addAll(
      (map['reconciliationResult'] as List).map((o) => ReconciliationResultBean.fromMap(o))
    );
    return closeDayResultsBean;
  }

  Map toJson() => {
    "reconciliationResult": reconciliationResult,
  };
}

/// hostResultCode : "000"
/// hostResultDescription : "Success"
/// terminalExternalId : "example_terminal_id"

class ReconciliationResultBean {
  String? hostResultCode;
  String? hostResultDescription;
  String? terminalExternalId;

  static ReconciliationResultBean fromMap(Map<String, dynamic> map) {
    ReconciliationResultBean reconciliationResultBean = ReconciliationResultBean();
    reconciliationResultBean.hostResultCode = map['hostResultCode'];
    reconciliationResultBean.hostResultDescription = map['hostResultDescription'];
    reconciliationResultBean.terminalExternalId = map['terminalExternalId'];
    return reconciliationResultBean;
  }

  Map toJson() => {
    "hostResultCode": hostResultCode,
    "hostResultDescription": hostResultDescription,
    "terminalExternalId": terminalExternalId,
  };
}

/// transaction : [{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]

class TransactionsBean {
  List<TransactionBean>? transaction;

  static TransactionsBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    TransactionsBean transactionsBean = TransactionsBean();
    transactionsBean.transaction = List.empty()..addAll(
      (map['transaction'] as List).map((o) => TransactionBean.fromMap(o))
    );
    return transactionsBean;
  }

  Map toJson() => {
    "transaction": transaction,
  };
}

/// type : "PAYMENT"
/// instrument : "CARD"
/// amount : "6000"
/// terminalId : "123321"
/// operationDay : "4"
/// transactionNumber : "69"
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}

class TransactionBean {
  String? type;
  String? instrument;
  num amount = 0;
  int? terminalId;
  int? operationDay;
  int? transactionNumber;
  InstrumentSpecificDataBean? instrumentSpecificData;

  static TransactionBean fromMap(Map<String, dynamic> map) {
    TransactionBean transactionBean = TransactionBean();
    transactionBean.type = map['type'];
    transactionBean.instrument = map['instrument'];
    transactionBean.amount = map['amount'] ?? 0;
    transactionBean.terminalId = map['terminalId'];
    transactionBean.operationDay = map['operationDay'];
    transactionBean.transactionNumber = map['transactionNumber'];
    transactionBean.instrumentSpecificData = InstrumentSpecificDataBean.fromMap(map['instrumentSpecificData']);
    return transactionBean;
  }

  Map toJson() => {
    "type": type,
    "instrument": instrument,
    "amount": amount,
    "terminalId": terminalId,
    "operationDay": operationDay,
    "transactionNumber": transactionNumber,
    "instrumentSpecificData": instrumentSpecificData,
  };
}

/// authorizationCode : "000000"
/// rrn : "1234567890"
/// cardholderName : "IVAN IVANOV"
/// maskedPan : "123456******7890"

class InstrumentSpecificDataBean {
  String? authorizationCode;
  String? rrn;
  String? cardholderName;
  String? maskedPan;

  static InstrumentSpecificDataBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
    instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
    instrumentSpecificDataBean.rrn = map['rrn'];
    instrumentSpecificDataBean.cardholderName = map['cardholderName'];
    instrumentSpecificDataBean.maskedPan = map['maskedPan'];
    return instrumentSpecificDataBean;
  }

  Map toJson() => {
    "authorizationCode": authorizationCode,
    "rrn": rrn,
    "cardholderName": cardholderName,
    "maskedPan": maskedPan,
  };
}

/// code : "0"
/// description : "Successfully completed"

class ResultBean {
  int? code;
  String? description;

  ResultBean({this.code, this.description});

  static ResultBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    ResultBean resultBean = ResultBean();
    resultBean.code = map['code'];
    resultBean.description = map['description'];
    return resultBean;
  }

  Map toJson() => {
    "code": code,
    "description": description,
  };
}