-
-
Notifications
You must be signed in to change notification settings - Fork 276
/
rest_wallet_request.go
45 lines (36 loc) · 922 Bytes
/
rest_wallet_request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ftx
import (
"context"
"encoding/json"
"fmt"
"strconv"
"time"
)
type walletRequest struct {
*restRequest
}
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)
}
resp, err := r.
Method("GET").
ReferenceURL("api/wallet/deposits").
Query(q).
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
}