Skip to content

Commit

Permalink
Merge pull request #129 from MrWildanMD/master
Browse files Browse the repository at this point in the history
Add account to client API
  • Loading branch information
adityarx authored Jun 19, 2023
2 parents ccb95a7 + b8fe182 commit fadf519
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/xendit/xendit-go"
"github.com/xendit/xendit-go/account"
"github.com/xendit/xendit-go/balance"
"github.com/xendit/xendit-go/card"
"github.com/xendit/xendit-go/cardlesscredit"
Expand Down Expand Up @@ -39,6 +40,7 @@ type API struct {
Customer *customer.Client
Transaction *transaction.Client
Report *report.Client
Account *account.Client
}

func (a *API) init() {
Expand All @@ -56,6 +58,7 @@ func (a *API) init() {
a.Customer = &customer.Client{Opt: &a.opt, APIRequester: a.apiRequester}
a.Transaction = &transaction.Client{Opt: &a.opt, APIRequester: a.apiRequester}
a.Report = &report.Client{Opt: &a.opt, APIRequester: a.apiRequester}
a.Account = &account.Client{Opt: &a.opt, APIRequester: a.apiRequester}
}

// New creates a new Xendit API client
Expand All @@ -74,7 +77,8 @@ func New(secretKey string) *API {

// WithAPIRequester set custom APIRequester for Xendit Client
// Can be chained with constructor like below:
// client.New(yourSecretKey).WithAPIRequester(yourCustomRequester)
//
// client.New(yourSecretKey).WithAPIRequester(yourCustomRequester)
func (a *API) WithAPIRequester(apiRequester xendit.APIRequester) *API {
a.apiRequester = apiRequester
a.init()
Expand All @@ -83,7 +87,8 @@ func (a *API) WithAPIRequester(apiRequester xendit.APIRequester) *API {

// WithCustomURL set custom xendit URL for Xendit Client
// Can be chained with constructor like below:
// client.New(yourSecretKey).WithCustomURL(yourCustomURL)
//
// client.New(yourSecretKey).WithCustomURL(yourCustomURL)
func (a *API) WithCustomURL(xenditURL string) *API {
a.opt.XenditURL = xenditURL
a.init()
Expand All @@ -92,7 +97,8 @@ func (a *API) WithCustomURL(xenditURL string) *API {

// WithCustomHTTPClient set custom HTTP Client for default API Requester
// Can be chained with constructor like below:
// client.New(yourSecretKey).WithCustomHTTPClient(yourCustomHTTPClient)
//
// client.New(yourSecretKey).WithCustomHTTPClient(yourCustomHTTPClient)
func (a *API) WithCustomHTTPClient(client *http.Client) *API {
a.apiRequester = &xendit.APIRequesterImplementation{
HTTPClient: client,
Expand Down

0 comments on commit fadf519

Please sign in to comment.