feat: add kyc layer service
This commit is contained in:
@@ -5,5 +5,6 @@ import jwt2 "github.com/golang-jwt/jwt/v5"
|
||||
type UserClaims struct {
|
||||
jwt2.RegisteredClaims
|
||||
UserID uint
|
||||
KYCLevel int
|
||||
Sections []string
|
||||
}
|
||||
|
||||
+44
-2
@@ -16,6 +16,13 @@ type Zohal struct {
|
||||
cfg config.KYC
|
||||
}
|
||||
|
||||
func NewZohal(cfg config.KYC) *Zohal {
|
||||
return &Zohal{
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
// check Phone and NationalID
|
||||
func (z *Zohal) Shahkar(ctx context.Context, phone, nationalID string) (ZohalShahkarResp, error) {
|
||||
var req ZohalShahkarReq
|
||||
var resp ZohalShahkarResp
|
||||
@@ -28,7 +35,6 @@ func (z *Zohal) Shahkar(ctx context.Context, phone, nationalID string) (ZohalSha
|
||||
if !ok {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
header := make(map[string]string)
|
||||
header["Content-Type"] = "application/json"
|
||||
header["Accept"] = "application/json"
|
||||
@@ -58,6 +64,42 @@ func (z *Zohal) Shahkar(ctx context.Context, phone, nationalID string) (ZohalSha
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (z *Zohal) GetPerson(ctx context.Context, nationalID, birthDate string) (ZohalIdentityResp, error) {
|
||||
var req ZohalIdentityReq
|
||||
var resp ZohalIdentityResp
|
||||
|
||||
header := make(map[string]string)
|
||||
header["Content-Type"] = "application/json"
|
||||
header["Accept"] = "application/json"
|
||||
header["Authorization"] = fmt.Sprintf("Bearer %s", z.cfg.APIKey)
|
||||
|
||||
req.BirthDate = birthDate
|
||||
req.NationalID = nationalID
|
||||
|
||||
u, err := url.Parse(z.cfg.URL)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
u = u.JoinPath("inquiry", "shahkar")
|
||||
|
||||
client := util.NewHttpClient()
|
||||
clientResp, err := client.HttpRequest(ctx, http.MethodPost, u.String(), req, header)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
bodyBytes, err := io.ReadAll(clientResp.Body)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bodyBytes, &resp)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, err
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user