BitkubMarketOpenOrderDao.fromJson constructor

BitkubMarketOpenOrderDao.fromJson(
  1. BitkubOpenOrderType orderType,
  2. Map<String, dynamic> json
)

Implementation

factory BitkubMarketOpenOrderDao.fromJson(
    BitkubOpenOrderType orderType, Map<String, dynamic> json) {
  if (json["error"] == 0) {
    return BitkubMarketOpenOrderDao(
      orderType: orderType,
      errorCode: json["error"],
      errorMessage: List(),
      orders: List.of(json["result"])
          .map((json) => BitkubOpenOrderItemDao.fromJson(json))
          .toList(),
    );
  } else {
    var jsonResult = json["result"];
    List<String> listError = List();
    if (json["result"] != null) {
      jsonResult["sym"] ?? listError.addAll(jsonResult["sym"]);
      jsonResult["lmt"] ?? listError.addAll(jsonResult["lmt"]);
    } else {
      listError.add("There are no symbol trade.");
    }
    return BitkubMarketOpenOrderDao(
        orderType: orderType,
        errorCode: json["error"],
        errorMessage: listError,
        orders: List());
  }
}