51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package httpcall
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"finclip-app-manager/domain/entity/proto"
|
|
"finclip-app-manager/infrastructure/config"
|
|
)
|
|
|
|
type GetApiListRsp struct {
|
|
Errcode string `json:"errcode"`
|
|
Error string `json:"error"`
|
|
Data []proto.ApiInfoRspData `json:"data"`
|
|
}
|
|
|
|
//
|
|
//type ApiInfoRspData struct {
|
|
// ApiName string `json:"apiName"`
|
|
// Url string `json:"url"`
|
|
//}
|
|
|
|
func (c *Client) GetApiList(ctx context.Context, organId string) ([]proto.ApiInfoRspData, error) {
|
|
if config.GetConfig().PublishEnv != config.ENV_FDEP {
|
|
return nil, nil
|
|
}
|
|
if config.GetConfig().SdkManagerHost == "" || config.GetConfig().SdkManagerApiInfo == "" {
|
|
return nil, nil
|
|
}
|
|
url := config.GetConfig().SdkManagerHost + config.GetConfig().SdkManagerApiInfo
|
|
rsp, err := c.Request(ctx).SetHeaders(c.getNewDefaultReqHeader()).SetQueryParam("organId", organId).Get(url)
|
|
if err != nil {
|
|
log.Errorf("SdkManagerClient GetApiList err:" + err.Error())
|
|
return nil, err
|
|
}
|
|
|
|
if rsp.StatusCode() != 200 {
|
|
log.Errorf("SdkManagerClient GetApiList status err:" + rsp.String())
|
|
return nil, errors.New("status err")
|
|
}
|
|
|
|
var smsRsp GetApiListRsp
|
|
err = json.Unmarshal(rsp.Body(), &smsRsp)
|
|
if err != nil {
|
|
log.Errorf("json.Unmarshal error:" + err.Error())
|
|
return nil, err
|
|
}
|
|
log.Debugf("SdkManagerClient GetApiList rsp:%+v", rsp.String())
|
|
return smsRsp.Data, nil
|
|
}
|