diff options
| author | Shulhan <ms@kilabit.info> | 2022-11-04 13:49:28 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-11-04 19:01:07 +0700 |
| commit | 0eef440900eda71b3a257707e49e0ad53be5353f (patch) | |
| tree | 7682364bc2f6ac826afd27fe71980ede98160b73 /client_options.go | |
| parent | 1846d3fc5d6a364986c073afccc66936ab3e469d (diff) | |
| download | duitku-0eef440900eda71b3a257707e49e0ad53be5353f.tar.xz | |
all: implement API for online transfer inquiry
The RtolInquiry method get the information of the name of the account
owner of the transfer destination.
After getting this information, customers can determine whether the
purpose of such a transfer is in accordance with the intended or not.
If appropriate, the customer can proceed to the transfer process.
Ref: https://docs.duitku.com/disbursement/en/#transfer-online
Diffstat (limited to 'client_options.go')
| -rw-r--r-- | client_options.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/client_options.go b/client_options.go index 7f23c24..5ed7d2c 100644 --- a/client_options.go +++ b/client_options.go @@ -3,10 +3,42 @@ package duitku +import ( + "fmt" + "net/url" +) + // ClientOptions configuration for HTTP client. type ClientOptions struct { ServerUrl string UserID string Email string ApiKey string + + // The hostname extracted from ServerUrl. + host string +} + +// validate each field values. +func (opts *ClientOptions) validate() (err error) { + var ( + urlServer *url.URL + ) + + urlServer, err = url.Parse(opts.ServerUrl) + if err != nil { + return fmt.Errorf(`invalid or empty ServerUrl: %s`, opts.ServerUrl) + } + opts.host = urlServer.Host + + if len(opts.UserID) == 0 { + return fmt.Errorf(`invalid or empty UserID: %s`, opts.UserID) + } + if len(opts.Email) == 0 { + return fmt.Errorf(`invalid or empty Email: %s`, opts.Email) + } + if len(opts.ApiKey) == 0 { + return fmt.Errorf(`invalid or empty ApiKey: %s`, opts.ApiKey) + } + return nil } |
