Skip to content

Commit

Permalink
Handle API request by Iris Role
Browse files Browse the repository at this point in the history
  • Loading branch information
andhikamaheva committed Oct 5, 2018
1 parent 99c3894 commit 4f124f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions iris.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ type IrisGateway struct {
}

// Call : base method to call Core API
func (gateway *IrisGateway) Call(method, path string, body io.Reader, v interface{}) error {
func (gateway *IrisGateway) Call(method, path string, body io.Reader, v interface{}, key string) error {
if !strings.HasPrefix(path, "/") {
path = "/" + path
}

path = gateway.Client.APIEnvType.IrisURL() + path
req, err := gateway.Client.NewRequest(method, path, body, gateway.Client.ApproverKey)
req, err := gateway.Client.NewRequest(method, path, body, key)
if err != nil {
return err
}
Expand All @@ -32,7 +32,7 @@ func (gateway *IrisGateway) CreateBeneficiaries(req *BeneficiariesReq) (map[stri
var resp map[string]interface{}
jsonReq, _ := json.Marshal(req)

err := gateway.Call("POST", "api/v1/beneficiaries", bytes.NewBuffer(jsonReq), &resp)
err := gateway.Call("POST", "api/v1/beneficiaries", bytes.NewBuffer(jsonReq), &resp, gateway.Client.ApproverKey)
if err != nil {
gateway.Client.Logger.Println("Error create beneficiaries: ", err)
return resp, err
Expand All @@ -45,7 +45,7 @@ func (gateway *IrisGateway) CreateBeneficiaries(req *BeneficiariesReq) (map[stri
func (gateway *IrisGateway) ValidateBankAccount(bankName string, account string) (map[string]interface{}, error) {
var resp map[string]interface{}

err := gateway.Call("GET", "api/v1/account_validation?bank="+bankName+"&account="+account, nil, &resp)
err := gateway.Call("GET", "api/v1/account_validation?bank="+bankName+"&account="+account, nil, &resp, gateway.Client.ApproverKey)
if err != nil {
gateway.Client.Logger.Println("Error approving: ", err)
return resp, err
Expand All @@ -60,7 +60,7 @@ func (gateway *IrisGateway) CreatePayouts(req *PayoutReq) (Payout, error) {

jsonReq, _ := json.Marshal(req)

err := gateway.Call("POST", "api/v1/payouts", bytes.NewBuffer(jsonReq), &resp)
err := gateway.Call("POST", "api/v1/payouts", bytes.NewBuffer(jsonReq), &resp, gateway.Client.CreatorKey)
if err != nil {
gateway.Client.Logger.Println("Error create payouts: ", err)
return resp, err
Expand Down

0 comments on commit 4f124f5

Please sign in to comment.