-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore.batchdisbursement.go
44 lines (39 loc) · 1.16 KB
/
core.batchdisbursement.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 xenditfasthttp
import (
"bytes"
"encoding/json"
"github.com/valyala/fasthttp"
)
const (
pathCreateBathcDisbursement = "/batch_disbursements"
pathGetAvailableBanks = "/available_disbursements_banks"
)
// CreateBatchDisbursement is used to create batch disbursement
func (gw *CoreXendit) CreateBatchDisbursement(req BatchDisbursementRequest) (res CreateBatchDisbursementResponse, err error) {
data, err := json.Marshal(req)
if err != nil {
return
}
buf := bytes.NewBuffer(data)
headers := map[string]string{
"Authorization": BasicAuth(gw.Client.SecretKey, ""),
"Content-Type": "application/json",
}
err = gw.Call(fasthttp.MethodPost, pathCreateBathcDisbursement, headers, buf, &res)
if err != nil {
return
}
return
}
// GetAvailableBatchDisbursementBanks is used to get available banks.
func (gw *CoreXendit) GetAvailableBatchDisbursementBanks() (res []GetAvailableDisbursementBanksResponse, err error) {
headers := map[string]string{
"Authorization": BasicAuth(gw.Client.SecretKey, ""),
"Content-Type": "application/json",
}
err = gw.Call(fasthttp.MethodGet, pathGetAvailableBanks, headers, nil, &res)
if err != nil {
return
}
return
}