Skip to content

Commit

Permalink
feat: Update AML search functionality
Browse files Browse the repository at this point in the history
The recent code changes in `aml.go` and `kyx.go` files modify the AML search functionality. The `get` function in `kyx.go` now accepts an optional `headers` parameter, allowing for custom headers to be passed in the GET request. Additionally, the `AmlSearchByName` function in `kyx.go` has been updated to use the `post` function instead of the `get` function. These changes enhance the AML search functionality and improve the flexibility of the API.

Based on the recent user commits and repository commits, it seems that the AML search functionality has been recently added and refined. The commits indicate the addition of the AML search by name functionality, as well as the addition of new fields in the `InfoKycResponse` struct. The commits also include a test for the KYC functionality and some general updates to the repository.

Please note that the suggested commit message is based on the provided code changes and commits. It is important to review and modify the message as needed to accurately reflect the purpose of the changes and adhere to the repository's commit message conventions.
  • Loading branch information
eminoz committed May 29, 2024
1 parent d996a2c commit bcafa82
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 bcafa82

Please sign in to comment.