withdrawHistory method

Future<Either<String, List<Withdraw>>> withdrawHistory({
  1. required String coin,
  2. String? withdrawOrderId,
  3. int? status,
  4. int? offset,
  5. int? limit,
  6. int? startTime,
  7. int? endTime,
  8. int? recvWindow,
})

Fetch withdraw history.

Implementation

Future<Either<String, List<Withdraw>>> withdrawHistory({
  required String coin,
  String? withdrawOrderId,
  int? status,
  int? offset,
  int? limit,
  int? startTime,
  int? endTime,
  int? recvWindow,
}) {
  Map<String, String> params = {
    'coin': coin,
  };
  if (withdrawOrderId != null) params['withdrawOrderId'] = withdrawOrderId;
  if (status != null) params['status'] = status.toString();
  if (offset != null) params['offset'] = offset.toString();
  if (limit != null) params['limit'] = limit.toString();
  if (startTime != null) params['startTime'] = startTime.toString();
  if (endTime != null) params['endTime'] = endTime.toString();
  if (recvWindow != null) params['recvWindow'] = recvWindow.toString();
  return sendRequest(
    path: 'sapi/v1/capital/withdraw/history',
    type: RequestType.GET,
    params: params,
    keyRequired: true,
    signatureRequired: true,
    timestampRequired: true,
  ).then((r) => r.isLeft
      ? Left(r.left)
      : Right(List<Withdraw>.from(r.right.map((e) => Withdraw.fromMap(e)))));
}