This commit is contained in:
renzhiyuan 2026-08-13 16:26:31 +08:00
parent 9a82fa034f
commit 0c77b7d1af
1 changed files with 30 additions and 0 deletions

View File

@ -117,3 +117,33 @@ func (s *ShortUrl) GetHeader() map[string]string {
"Authorization": s.auth,
}
}
// 不自动生成batch_name
func (s *ShortUrl) BatchCreate2(in *ShortUrlBatchCreate) (*ShortUrlBatchCreateResult, error) {
path := "/openapi/short_url/batch/create"
if len(in.Urls) == 0 {
return nil, errors.New("url is empty")
}
requestJson, err := StructToMap(in)
if err != nil {
return nil, err
}
req := Request{
Method: "POST",
Url: s.host + path,
Json: requestJson,
Headers: s.GetHeader(),
}
resp, err := req.Send()
if err != nil {
return nil, fmt.Errorf("请求失败err: %v", err)
}
var resData = &ShortUrlBatchCreateResult{}
err = CheckHttpRes(&resp, resData)
if err != nil {
return nil, err
}
return resData, nil
}