-
Notifications
You must be signed in to change notification settings - Fork 58
/
disbursement.go
89 lines (71 loc) · 2.53 KB
/
disbursement.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package disbursement
import (
"context"
"github.com/xendit/xendit-go"
)
// Create creates new disbursement
func Create(data *CreateParams) (*xendit.Disbursement, *xendit.Error) {
return CreateWithContext(context.Background(), data)
}
// CreateWithContext creates new disbursement with context
func CreateWithContext(ctx context.Context, data *CreateParams) (*xendit.Disbursement, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.CreateWithContext(ctx, data)
}
// GetByID gets a disbursement
func GetByID(data *GetByIDParams) (*xendit.Disbursement, *xendit.Error) {
return GetByIDWithContext(context.Background(), data)
}
// GetByIDWithContext gets a disbursement with context
func GetByIDWithContext(ctx context.Context, data *GetByIDParams) (*xendit.Disbursement, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetByIDWithContext(ctx, data)
}
// GetByExternalID gets a disbursement
func GetByExternalID(data *GetByExternalIDParams) ([]xendit.Disbursement, *xendit.Error) {
return GetByExternalIDWithContext(context.Background(), data)
}
// GetByExternalIDWithContext gets a disbursement with context
func GetByExternalIDWithContext(ctx context.Context, data *GetByExternalIDParams) ([]xendit.Disbursement, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetByExternalIDWithContext(ctx, data)
}
// GetAvailableBanks gets available disbursement banks
func GetAvailableBanks() ([]xendit.DisbursementBank, *xendit.Error) {
return GetAvailableBanksWithContext(context.Background())
}
// GetAvailableBanksWithContext gets available disbursement banks with context
func GetAvailableBanksWithContext(ctx context.Context) ([]xendit.DisbursementBank, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetAvailableBanksWithContext(ctx)
}
// CreateBatch creates new batch disbursement
func CreateBatch(data *CreateBatchParams) (*xendit.BatchDisbursement, *xendit.Error) {
return CreateBatchWithContext(context.Background(), data)
}
// CreateBatchWithContext creates new batch disbursement with context
func CreateBatchWithContext(ctx context.Context, data *CreateBatchParams) (*xendit.BatchDisbursement, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.CreateBatchWithContext(ctx, data)
}
func getClient() (*Client, *xendit.Error) {
return &Client{
Opt: &xendit.Opt,
APIRequester: xendit.GetAPIRequester(),
}, nil
}