Skip to content

Commit

Permalink
add mock transaction endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
olusolaa committed May 4, 2022
1 parent f87f89f commit 4f78d06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions juice.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (cl *Client) UpdateAccount(webhook, businessAddress, domain string) (Accoun

// TopUpFloat allows an integrator to top up float balance.
//This endpoint is only available in the sandbox environment.
func (cl *Client) TopUpFloat(amount int) (TopUpFloatResp, error) {
var res TopUpFloatResp
func (cl *Client) TopUpFloat(amount int) (Resp, error) {
var res Resp
err := cl.patch("/card-integrators/top-up-float", &TopUpFloatData{amount}, &res)
return res, err
}
Expand Down Expand Up @@ -191,6 +191,13 @@ func (cl *Client) GetTransaction(trxId string) (TransactionResp, error) {
return res, err
}

//MockTransaction mocks card transaction. This endpoint is only available in the sandbox environment.
func (cl *Client) MockTransaction(data MockTransactionData, cardId string) (Resp, error) {
var res Resp
err := cl.post(fmt.Sprintf("/cards/%s/mock-transaction", cardId), data, &res)
return res, err
}

func (cl Client) Health() (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/health/live", cl.baseURL))
body, _ := ioutil.ReadAll(resp.Body)
Expand Down
7 changes: 6 additions & 1 deletion req_resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type PaymentData struct {
CardId string `json:"card_id"`
}

type MockTransactionData struct {
Amount int `json:"amount"`
Type string `json:"type"`
}

type AccountResp struct {
Data Account `json:"data"`
}
Expand Down Expand Up @@ -108,6 +113,6 @@ type BalanceResp struct {
Id string `json:"id"`
}

type TopUpFloatResp struct {
type Resp struct {
Message string `json:"message"`
}

0 comments on commit 4f78d06

Please sign in to comment.