diff --git a/aml.go b/aml.go index 8a1cc47..3cd91e0 100644 --- a/aml.go +++ b/aml.go @@ -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:""` } diff --git a/kyx.go b/kyx.go index b75ce84..0211668 100644 --- a/kyx.go +++ b/kyx.go @@ -3,7 +3,7 @@ package kyx import ( "bytes" "encoding/json" - "errors" + "fmt" "io" "net/http" "time" @@ -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 { @@ -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 } diff --git a/kyx_test.go b/kyx_test.go index 7c47b1e..52d8708 100644 --- a/kyx_test.go +++ b/kyx_test.go @@ -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) } @@ -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) +}