-
Notifications
You must be signed in to change notification settings - Fork 20
/
wallet_transaction.go
74 lines (58 loc) · 1.88 KB
/
wallet_transaction.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package lago
import (
"context"
"time"
"github.com/google/uuid"
)
type WalletStatus string
const (
WalletStatusPending WalletStatus = "pending"
WalletStatusSettled WalletStatus = "settled"
)
type TransactionType string
const (
Outbound TransactionType = "outbound"
Inbound TransactionType = "inbound"
)
type WalletTransactionRequest struct {
client *Client
}
type WalletTransactionParams struct {
WalletTransactionInput *WalletTransactionInput
}
type WalletTransactionInput struct {
WalletId string `json:"wallet_id,omitempty"`
PaidCredits string `json:"paid_credits,omitempty"`
GrantedCredits string `json:"granted_credits,omitempty"`
}
type WalletTransactionResult struct {
WalletTransactions []WalletTransaction `json:"wallet_transactions,omitempty"`
}
type WalletTransaction struct {
LagoID uuid.UUID `json:"lago_id,omitempty"`
LagoWalletID uuid.UUID `json:"lago_wallet_id,omitempty"`
Status WalletStatus `json:"status,omitempty"`
TransactionType TransactionType `json:"transaction_type,omitempty"`
Amount string `json:"amount,omitempty"`
CreditAmount string ` json:"credit_amount,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
SettledAt time.Time `json:"settled_at,omitempty"`
}
func (c *Client) WalletTransaction() *WalletTransactionRequest {
return &WalletTransactionRequest{
client: c,
}
}
func (bmr *WalletTransactionRequest) Create(ctx context.Context, walletTransactionInput *WalletTransactionInput) (*WalletTransaction, *Error) {
clientRequest := &ClientRequest{
Path: "wallet_transactions",
Result: &WalletTransactionResult{},
Body: walletTransactionInput,
}
result, err := bmr.client.Post(ctx, clientRequest)
if err != nil {
return nil, err
}
walletTransactionResult := result.(*WalletTransaction)
return walletTransactionResult, nil
}