-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_wallettransactions.go
53 lines (48 loc) · 1.75 KB
/
client_wallettransactions.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
45
46
47
48
49
50
51
52
53
package monta
import (
"context"
"fmt"
"net/url"
"strconv"
"time"
)
// ListWalletTransactionsRequest is the request input to the [Client.ListWalletTransactions] method.
type ListWalletTransactionsRequest struct {
PageFilters
// FromDate allows to filter to retrieve transactions where [WalletTransaction.CreatedAt] >= FromDate.
FromDate *time.Time
// ToDate allows to filter to retrieve transactions where [WalletTransaction.CreatedAt] <= ToDate.
ToDate *time.Time
TeamID *int64
}
// ListWalletTransactionsResponse is the response output from the [Client.ListWalletTransactions] method.
type ListWalletTransactionsResponse struct {
// WalletTransactions in the current page.
WalletTransactions []*WalletTransaction `json:"data"`
// PageMeta with metadata about the current page.
PageMeta PageMeta `json:"meta"`
}
// ListWalletTransactions to retrieve your wallet transactions.
func (c *clientImpl) ListWalletTransactions(
ctx context.Context,
request *ListWalletTransactionsRequest,
) (*ListWalletTransactionsResponse, error) {
path := "/v1/wallet-transactions"
query := url.Values{}
request.PageFilters.Apply(query)
if request.FromDate != nil {
query.Set("fromDate", request.FromDate.UTC().Format(time.RFC3339))
}
if request.ToDate != nil {
query.Set("toDate", request.ToDate.UTC().Format(time.RFC3339))
}
if request.TeamID != nil {
query.Set("teamId", strconv.Itoa(int(*request.TeamID)))
}
return doGet[ListWalletTransactionsResponse](ctx, c, path, query)
}
// GetWalletTransaction to retrieve a single wallet transaction.
func (c *clientImpl) GetWalletTransaction(ctx context.Context, transactionID int64) (*WalletTransaction, error) {
path := fmt.Sprintf("/v1/wallet-transactions/%d", transactionID)
return doGet[WalletTransaction](ctx, c, path, nil)
}