aboutsummaryrefslogtreecommitdiff
path: root/clearing_transfer.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-11-18 18:05:19 +0700
committerShulhan <ms@kilabit.info>2022-11-18 18:05:19 +0700
commit80af1ff2a264a875fbd8dbf0a0ae8926c1ef396e (patch)
tree364f2b3ca4cfe8b43bfe13ad0614c660b090787e /clearing_transfer.go
parentf98eb44cd053677b921753912e1b908f4510b28d (diff)
downloadduitku-80af1ff2a264a875fbd8dbf0a0ae8926c1ef396e.tar.xz
all: export types RtolTransfer, ClearingTransfer and method Sign
The idea is to allow testing the client from other module without using the provided APIs.
Diffstat (limited to 'clearing_transfer.go')
-rw-r--r--clearing_transfer.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/clearing_transfer.go b/clearing_transfer.go
index 9124eac..52f23bc 100644
--- a/clearing_transfer.go
+++ b/clearing_transfer.go
@@ -11,7 +11,7 @@ import (
"time"
)
-// clearingTransfer contains request parameter for Clearing Transfer.
+// ClearingTransfer contains request parameter for Clearing Transfer.
//
// Formula to generate signature:
//
@@ -20,19 +20,19 @@ import (
// disburseId + apiKey)
//
// Ref: https://docs.duitku.com/disbursement/en/#clearing-transfer-request
-type clearingTransfer struct {
+type ClearingTransfer struct {
Type string `json:"type"`
- rtolTransfer
+ RtolTransfer
}
-// newClearingTransfer create clearingTransfer from Clearing Inquiry
+// NewClearingTransfer create ClearingTransfer from Clearing Inquiry
// request and response.
//
// The following fields are set from response: AccountName, CustRefNumber,
// DisburseID, and Type.
-func newClearingTransfer(inqReq *ClearingInquiry, inqRes *ClearingInquiryResponse) (trf *clearingTransfer) {
- trf = &clearingTransfer{}
+func NewClearingTransfer(inqReq *ClearingInquiry, inqRes *ClearingInquiryResponse) (trf *ClearingTransfer) {
+ trf = &ClearingTransfer{}
trf.Amount = inqReq.Amount
trf.BankAccount = inqReq.BankAccount
@@ -47,7 +47,9 @@ func newClearingTransfer(inqReq *ClearingInquiry, inqRes *ClearingInquiryRespons
return trf
}
-func (trf *clearingTransfer) sign(opts ClientOptions) {
+// Sign the request, fill the UserID, Email, Timestamp, and generate the
+// Signature.
+func (trf *ClearingTransfer) Sign(opts ClientOptions) {
var (
now = time.Now()