From 3dcfe084e00d9a37a3e1f626ac6195a0ae8403c5 Mon Sep 17 00:00:00 2001 From: Andhika Maheva Wicaksono Date: Tue, 9 Oct 2018 09:27:24 +0700 Subject: [PATCH] 1. Finished approve payouts 2. Finished reject payouts --- iris.go | 30 ++++++++++++++++++++++++++++++ request.go | 12 ++++++++++++ 2 files changed, 42 insertions(+) diff --git a/iris.go b/iris.go index bbd5ded..d096bf3 100644 --- a/iris.go +++ b/iris.go @@ -68,3 +68,33 @@ func (gateway *IrisGateway) CreatePayouts(req *PayoutReq) (Payout, error) { return resp, nil } + +// ApprovePayouts : Approve Payout(s) with single or multiple payouts +func (gateway *IrisGateway) ApprovePayouts(req *ApprovePayoutReq) (map[string]interface{}, error) { + var resp map[string]interface{} + + jsonReq, _ := json.Marshal(req) + + err := gateway.Call("POST", "api/v1/payouts/approve", bytes.NewBuffer(jsonReq), &resp, gateway.Client.ApproverKey) + if err != nil { + gateway.Client.Logger.Println("Error approve payouts: ", err) + return resp, err + } + + return resp, nil +} + +// RejectPayouts : Reject Payout(s) with single or multiple payouts +func (gateway *IrisGateway) RejectPayouts(req *RejectPayoutReq) (map[string]interface{}, error) { + var resp map[string]interface{} + + jsonReq, _ := json.Marshal(req) + + err := gateway.Call("POST", "api/v1/payouts/reject", bytes.NewBuffer(jsonReq), &resp, gateway.Client.ApproverKey) + if err != nil { + gateway.Client.Logger.Println("Error reject payouts: ", err) + return resp, err + } + + return resp, nil +} diff --git a/request.go b/request.go index 85573ec..abae476 100644 --- a/request.go +++ b/request.go @@ -250,3 +250,15 @@ type PayoutDetails struct { Notes string `json:"notes"` BankAccountID string `json:"bank_account_id,omitempty"` } + +// ApprovePayoutReq : Represent Approve Payout Requests +type ApprovePayoutReq struct { + ReferenceNos []string `json:"reference_nos"` + OTP string `json:"otp"` +} + +// RejectPayoutReq : Represent Reject Payout Requests +type RejectPayoutReq struct { + ReferenceNos []string `json:"reference_nos"` + RejectReason string `json:"reject_reason"` +}