-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest_customize_result.go
46 lines (37 loc) · 1.13 KB
/
request_customize_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ernieapi
import (
"context"
"github.com/google/go-querystring/query"
"net/http"
"strings"
)
type V3CustomizeResultRequest struct {
TaskId int `json:"taskId" url:"taskId"`
}
type V3CustomizeResultResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data V3CustomizeResultData `json:"data"`
}
type V3CustomizeResultData struct {
Result string `json:"result"`
CreateTime string `json:"createTime"`
RequestID string `json:"requestId"`
Text string `json:"text"`
TaskID int `json:"taskId"`
Status int `json:"status"`
}
func (c *Client) GetV3CustomizeResult(ctx context.Context, request *V3CustomizeResultRequest) (response *V3CustomizeResultResponse, err error) {
urlSuffix := "/rest/1.0/ernie/v1/getResult"
requestParams, err := query.Values(*request)
if err != nil {
return response, ErrV3CustomizeRequest
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.fullURL(urlSuffix), strings.NewReader(requestParams.Encode()))
if err != nil {
return
}
errResponse := &ResponseError{}
err = c.sendRequest(req, &response, errResponse)
return
}