package org.knowm.xchange.binance.dto.account;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;

public final class AssetDribbletLogResponse
    extends ApiResponse<AssetDribbletLogResponse.AssetDribbletLogResults> {

  private final AssetDribbletLogResults results;

  public AssetDribbletLogResponse(
      @JsonProperty("results") AssetDribbletLogResults results,
      @JsonProperty("success") boolean success,
      @JsonProperty("msg") String msg) {
    super(success, msg);
    this.results = results;
  }

  @Override
  public AssetDribbletLogResults getData() {
    return results;
  }

  @Override
  public String toString() {
    return "AssetDribbletLogResult [results="
        + results
        + ", success="
        + success
        + ", msg="
        + msg
        + "]";
  }

  @Data
  @NoArgsConstructor
  public static class AssetDribbletLogResults {
    private BigDecimal total;
    private BnbExchange[] rows;

    public List<BnbExchange> getData() {
      return Arrays.asList(rows);
    }
  }

  @Data
  @NoArgsConstructor
  public static class BnbExchange {
    private String transfered_total;
    private String service_charge_total;
    private BigInteger tran_id;
    private BnbExchangeLog[] logs;
    private String operate_time;

    public List<BnbExchangeLog> getData() {
      return Arrays.asList(logs);
    }

    public LocalDateTime getOperateTime() {
      return LocalDateTime.parse(operate_time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
  }

  @Data
  @NoArgsConstructor
  public static class BnbExchangeLog {
    private BigInteger tranId;
    private String serviceChargeAmount;
    private String uid;
    private String amount;
    private String operateTime;
    private String transferedAmount;
    private String fromAsset;

    public LocalDateTime getOperateTime() {
      return LocalDateTime.parse(operateTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
  }
}

@@ -189,51 +189,8 @@
 me;%0A
-import java.time.format.DateTimeFormatter;%0A
 impo
@@ -285,16 +285,66 @@
 tructor;
+%0Aimport org.knowm.xchange.binance.BinanceAdapters;
 %0A%0Apublic
@@ -1639,32 +1639,50 @@
  %7B%0A      return 
+BinanceAdapters.to
 LocalDateTime.pa
@@ -1670,38 +1670,32 @@
 .toLocalDateTime
-.parse
 (operate_time, D
@@ -1695,60 +1695,8 @@
 time
-, DateTimeFormatter.ofPattern(%22yyyy-MM-dd HH:mm:ss%22)
 );%0A 
@@ -2052,16 +2052,34 @@
  return 
+BinanceAdapters.to
 LocalDat
@@ -2087,14 +2087,8 @@
 Time
-.parse
 (ope
@@ -2099,60 +2099,8 @@
 Time
-, DateTimeFormatter.ofPattern(%22yyyy-MM-dd HH:mm:ss%22)
 );%0A 

Refactor to use BinanceAdapters.toLocalDateTime parse method