2021-03-21 12:17:41 +00:00
|
|
|
package ftx
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2021-03-23 14:26:18 +00:00
|
|
|
"strconv"
|
|
|
|
"time"
|
2021-03-21 12:17:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type walletRequest struct {
|
|
|
|
*restRequest
|
|
|
|
}
|
|
|
|
|
2021-03-23 14:26:18 +00:00
|
|
|
func (r *walletRequest) DepositHistory(ctx context.Context, since time.Time, until time.Time, limit int) (depositHistoryResponse, error) {
|
|
|
|
q := make(map[string]string)
|
|
|
|
if limit > 0 {
|
|
|
|
q["limit"] = strconv.Itoa(limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
if since != (time.Time{}) {
|
|
|
|
q["start_time"] = strconv.FormatInt(since.Unix(), 10)
|
|
|
|
}
|
|
|
|
if until != (time.Time{}) {
|
|
|
|
q["end_time"] = strconv.FormatInt(until.Unix(), 10)
|
|
|
|
}
|
|
|
|
|
2021-03-21 12:17:41 +00:00
|
|
|
resp, err := r.
|
|
|
|
Method("GET").
|
|
|
|
ReferenceURL("api/wallet/deposits").
|
2021-03-23 14:26:18 +00:00
|
|
|
Query(q).
|
2021-03-21 12:17:41 +00:00
|
|
|
DoAuthenticatedRequest(ctx)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return depositHistoryResponse{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var d depositHistoryResponse
|
|
|
|
if err := json.Unmarshal(resp.Body, &d); err != nil {
|
|
|
|
return depositHistoryResponse{}, fmt.Errorf("failed to unmarshal deposit history response body to json: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return d, nil
|
|
|
|
}
|