fadd
This commit is contained in:
@@ -29,7 +29,7 @@ func ProcessJRZQV3HMRequest(ctx context.Context, params []byte, deps *processors
|
|||||||
nuoerDoCheckAPIKey := "blackListV121_3_1"
|
nuoerDoCheckAPIKey := "blackListV121_3_1"
|
||||||
ApiPath := "/v1/doCheck"
|
ApiPath := "/v1/doCheck"
|
||||||
|
|
||||||
resp, err := deps.NuoerService.CallAPI(ctx, nuoerDoCheckAPIKey, ApiPath, body)
|
resp, err := deps.NuoerService.CallAPI(ctx, nuoerDoCheckAPIKey, ApiPath, body, nuoer.WithEncryptionType(2))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, nuoer.ErrDatasource) {
|
if errors.Is(err, nuoer.ErrDatasource) {
|
||||||
return nil, errors.Join(processors.ErrDatasource, err)
|
return nil, errors.Join(processors.ErrDatasource, err)
|
||||||
|
|||||||
@@ -91,7 +91,25 @@ func (s *NuoerService) logError(transactionID, apiKey, seqNo string, err error,
|
|||||||
s.logger.LogError(seqNo, transactionID, apiKey, err, payload)
|
s.logger.LogError(seqNo, transactionID, apiKey, err, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body map[string]string) (*nuoerResponse, error) {
|
// CallAPIOption 诺尔智汇 CallAPI 可选参数
|
||||||
|
type CallAPIOption func(*callAPIConfig)
|
||||||
|
|
||||||
|
type callAPIConfig struct {
|
||||||
|
encryptionType int
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithEncryptionType 指定入参加密类型(如 MD5 入参为 2)
|
||||||
|
func WithEncryptionType(encryptionType int) CallAPIOption {
|
||||||
|
return func(c *callAPIConfig) {
|
||||||
|
c.encryptionType = encryptionType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body map[string]string, opts ...CallAPIOption) (*nuoerResponse, error) {
|
||||||
|
cfg := callAPIConfig{}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(&cfg)
|
||||||
|
}
|
||||||
requestURL := strings.TrimSuffix(s.config.URL, "/")
|
requestURL := strings.TrimSuffix(s.config.URL, "/")
|
||||||
if apiPath != "" {
|
if apiPath != "" {
|
||||||
if !strings.HasPrefix(apiPath, "/") {
|
if !strings.HasPrefix(apiPath, "/") {
|
||||||
@@ -116,6 +134,9 @@ func (s *NuoerService) CallAPI(ctx context.Context, apiKey, apiPath string, body
|
|||||||
"apiKey": apiKey,
|
"apiKey": apiKey,
|
||||||
"body": body,
|
"body": body,
|
||||||
}
|
}
|
||||||
|
if cfg.encryptionType != 0 {
|
||||||
|
requestPayload["encryptionType"] = cfg.encryptionType
|
||||||
|
}
|
||||||
|
|
||||||
if s.logger != nil {
|
if s.logger != nil {
|
||||||
s.logger.LogRequest("", transactionID, apiKey, requestURL)
|
s.logger.LogRequest("", transactionID, apiKey, requestURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user