Skip to content

Commit

Permalink
Merge pull request #4 from monopayments/test/aml
Browse files Browse the repository at this point in the history
feat: Update AML search functionality
  • Loading branch information
eminoz authored May 29, 2024
2 parents d996a2c + bcafa82 commit 61ae71d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions aml.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ type AmlCheckResponse struct {
WhiteListMessage string `json:"white_list_message"`
RiskLevelID int64 `json:"risk_level_id"`
IsSafeList bool `json:"is_safe_list"`
Error string `json:"error" example:""`
}
21 changes: 10 additions & 11 deletions kyx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package kyx
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"time"
Expand Down Expand Up @@ -60,12 +60,19 @@ func (t *API) put(path string, payload interface{}, response interface{}) error
return t.do(req, response)
}

func (t *API) get(path string, payload interface{}, response interface{}) error {
func (t *API) get(path string, payload interface{}, response interface{}, headers ...map[string]string) error {
url := t.EndPoint + path
fmt.Println(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
if len(headers) > 0 {
for k, v := range headers[0] {
req.Header.Set(k, v)
}
}
return t.do(req, response)
}
func (t *API) delete(path string, payload interface{}, response interface{}) error {
Expand Down Expand Up @@ -139,15 +146,7 @@ func (t *API) Contactless(payload ContactlessRequestDTO) (ArkSignerResponseMessa
func (t *API) AmlSearchByName(payload AmlCheckRequest) (AmlCheckResponse, error) {
var response AmlCheckResponse
apiPath := "/aml/user-aml"
if payload.Name == "" {
return response, errors.New("name is required")
}
apiPath = "?name=" + payload.Name

if payload.ReferenceID != "" {
apiPath = "&reference_id=" + payload.ReferenceID
}

err := t.get(apiPath, nil, &response)
err := t.post(apiPath, payload, &response)
return response, err
}
27 changes: 26 additions & 1 deletion kyx_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package kyx

import (
"fmt"
"testing"
)

var testClint *API

func InitNewAPI() {
token := ""
token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJPcmdhbml6YXRpb25JRCI6ImUyYjllMzQzLTg3ZjktNDk3ZS05ZTkzLWRjNzc0MDk1YTI3OCIsIkFjY291bnRJRCI6ImEyMjg3ODVkLWIxYWUtNDUwZi1hMTU2LWU0ZjMwY2VlODczMiIsImlzcyI6Im1vbm8ta3l4IiwiZXhwIjoxNzE5NTg5NzM3fQ.689pUie7M8IQmeYIzII0ShODpmKpvow_qDuXg_7qT_w"
testClint = NewAPI(token)
}

Expand Down Expand Up @@ -90,3 +91,27 @@ func TestKyc(t *testing.T) {
t.Log("kyc info", infoRes)

}

func TestAmlSearch(t *testing.T) {
req := AmlCheckRequest{
Name: "STEVEN ALIRABAKI",
ReferenceID: "D0001371250",
}

res, err := testClint.AmlSearchByName(req) //this function runs a aml check process

if err != nil {
t.Fatalf("Errori: %v", err)
return
}

if res.Error != "" {
t.Fatalf("Errorr: %v", res.Error)
return
}

fmt.Println("aml search ress", res)
t.Log("aml safelist ", res.IsSafeList)
t.Log("aml is white list", res.IsWhiteList)
t.Log("aml risk level", res.RiskLevelID)
}

0 comments on commit 61ae71d

Please sign in to comment.