-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment.go
45 lines (40 loc) · 1 KB
/
comment.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
package docs
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
// AddWholeComment represent add a whole _comment
func (c comment) AddWholeComment(fileType FileType, content string) (*RespComment, error) {
en, _ := json.Marshal(map[string]interface{}{
"type": fileType,
"token": c.fileToken,
"content": content,
})
req, _ := http.NewRequest(
http.MethodPost,
fmt.Sprintf("%s/open-apis/comment/add_whole", c.baseClient.domain),
bytes.NewReader(en),
)
resp := &RespComment{}
_, err := c.baseClient.CommonReq(req, resp)
return resp, err
}
func newComment(token string, originClient *Client) *comment {
return &comment{
fileToken: token,
baseClient: originClient,
}
}
// comment represent add comment for a doc
type comment struct {
fileToken string
baseClient *Client
}
type RespComment struct {
CommentID string `json:"comment_id"`
ReplyID string `json:"reply_id"`
CreateTimestamp int64 `json:"create_timestamp"`
UpdateTimestamp int64 `json:"update_timestamp"`
}