This commit is contained in:
parent
9a82fa034f
commit
0c77b7d1af
30
short_url.go
30
short_url.go
|
|
@ -117,3 +117,33 @@ func (s *ShortUrl) GetHeader() map[string]string {
|
||||||
"Authorization": s.auth,
|
"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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue