aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-11-15 15:49:27 +0700
committerShulhan <ms@kilabit.info>2022-11-15 15:49:27 +0700
commitf98eb44cd053677b921753912e1b908f4510b28d (patch)
treeee4ff42efd74f1d776b6eb8f877ba80b23d39121 /client.go
parent1001ab2cf4f02cf81d6b4ce72c09829e6b3b66be (diff)
downloadduitku-f98eb44cd053677b921753912e1b908f4510b28d.tar.xz
all: move the "/webapi/api" prefix from server URL to paths
Instead of declaring the fixed prefix "/webapi/api" in the server URL, define it in the path itself so the server URL can be cleanly mock up.
Diffstat (limited to 'client.go')
-rw-r--r--client.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/client.go b/client.go
index b11bbf0..2a076d9 100644
--- a/client.go
+++ b/client.go
@@ -15,22 +15,22 @@ import (
// List of known and implemented HTTP API paths.
const (
- PathDisbursementListBank = `/disbursement/listBank`
- PathDisbursementCheckBalance = `/disbursement/checkBalance`
+ PathListBank = `/webapi/api/disbursement/listBank`
+ PathCheckBalance = `/webapi/api/disbursement/checkBalance`
// Paths for transfer online.
- PathDisbursementInquiry = `/disbursement/inquiry`
- PathDisbursementInquirySandbox = `/disbursement/inquirysandbox` // Used for testing.
+ PathInquiry = `/webapi/api/disbursement/inquiry`
+ PathInquirySandbox = `/webapi/api/disbursement/inquirysandbox` // Used for testing.
- PathDisbursementTransfer = `/disbursement/transfer`
- PathDisbursementTransferSandbox = `/disbursement/transfersandbox` // Used for testing.
+ PathTransfer = `/webapi/api/disbursement/transfer`
+ PathTransferSandbox = `/webapi/api/disbursement/transfersandbox` // Used for testing.
// Paths for Clearing.
- PathDisbursementInquiryClearing = `/disbursement/inquiryclearing`
- PathDisbursementInquiryClearingSandbox = `/disbursement/inquiryclearingsandbox` // Used for testing.
+ PathInquiryClearing = `/webapi/api/disbursement/inquiryclearing`
+ PathInquiryClearingSandbox = `/webapi/api/disbursement/inquiryclearingsandbox` // Used for testing.
- PathDisbursementTransferClearing = `/disbursement/transferclearing`
- PathDisbursementTransferClearingSandbox = `/disbursement/transferclearingsandbox` // Used for testing.
+ PathTransferClearing = `/webapi/api/disbursement/transferclearing`
+ PathTransferClearingSandbox = `/webapi/api/disbursement/transferclearingsandbox` // Used for testing.
)
type Client struct {
@@ -71,7 +71,7 @@ func (cl *Client) CheckBalance() (bal *Balance, err error) {
resBody []byte
)
- httpRes, resBody, err = cl.PostJSON(PathDisbursementCheckBalance, nil, req)
+ httpRes, resBody, err = cl.PostJSON(PathCheckBalance, nil, req)
if err != nil {
return nil, fmt.Errorf(`%s: %w`, logp, err)
}
@@ -95,7 +95,7 @@ func (cl *Client) CheckBalance() (bal *Balance, err error) {
func (cl *Client) ClearingInquiry(req *ClearingInquiry) (res *ClearingInquiryResponse, err error) {
var (
logp = `ClearingInquiry`
- path = PathDisbursementInquiryClearing
+ path = PathInquiryClearing
httpRes *http.Response
resBody []byte
@@ -106,7 +106,7 @@ func (cl *Client) ClearingInquiry(req *ClearingInquiry) (res *ClearingInquiryRes
// Since the path is different in test environment, we check the host
// here to set it.
if cl.opts.host != hostLive {
- path = PathDisbursementInquiryClearingSandbox
+ path = PathInquiryClearingSandbox
}
httpRes, resBody, err = cl.PostJSON(path, nil, req)
@@ -138,7 +138,7 @@ func (cl *Client) ClearingTransfer(inquiryReq *ClearingInquiry, inquiryRes *Clea
) {
var (
logp = `ClearingTransfer`
- path = PathDisbursementTransferClearing
+ path = PathTransferClearing
transferReq = newClearingTransfer(inquiryReq, inquiryRes)
httpRes *http.Response
@@ -150,7 +150,7 @@ func (cl *Client) ClearingTransfer(inquiryReq *ClearingInquiry, inquiryRes *Clea
// Since the path is different in test environment, we check the host
// here to set it.
if cl.opts.host != hostLive {
- path = PathDisbursementTransferClearingSandbox
+ path = PathTransferClearingSandbox
}
httpRes, resBody, err = cl.PostJSON(path, nil, transferReq)
@@ -187,7 +187,7 @@ func (cl *Client) ListBank() (banks []Bank, err error) {
resBody []byte
)
- httpRes, resBody, err = cl.PostJSON(PathDisbursementListBank, nil, req)
+ httpRes, resBody, err = cl.PostJSON(PathListBank, nil, req)
if err != nil {
return nil, fmt.Errorf(`%s: %w`, logp, err)
}
@@ -232,7 +232,7 @@ func (cl *Client) ListBank() (banks []Bank, err error) {
func (cl *Client) RtolInquiry(req *RtolInquiry) (res *RtolInquiryResponse, err error) {
var (
logp = `RtolInquiry`
- path = PathDisbursementInquiry
+ path = PathInquiry
resHttp *http.Response
resBody []byte
@@ -241,7 +241,7 @@ func (cl *Client) RtolInquiry(req *RtolInquiry) (res *RtolInquiryResponse, err e
// Since the path is different in test environment, we check the host
// here to set it.
if cl.opts.host != hostLive {
- path = PathDisbursementInquirySandbox
+ path = PathInquirySandbox
}
req.sign(cl.opts)
@@ -275,7 +275,7 @@ func (cl *Client) RtolInquiry(req *RtolInquiry) (res *RtolInquiryResponse, err e
func (cl *Client) RtolTransfer(inquiryReq *RtolInquiry, inquiryRes *RtolInquiryResponse) (res *RtolTransferResponse, err error) {
var (
logp = `RtolTransfer`
- path = PathDisbursementTransfer
+ path = PathTransfer
req *rtolTransfer
resHttp *http.Response
@@ -285,7 +285,7 @@ func (cl *Client) RtolTransfer(inquiryReq *RtolInquiry, inquiryRes *RtolInquiryR
// Since the path is different in test environment, we check the host
// here to set it.
if cl.opts.host != hostLive {
- path = PathDisbursementTransferSandbox
+ path = PathTransferSandbox
}
req = newRtolTransfer(inquiryReq, inquiryRes)