forked from MEDIGO/go-zendesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathticket_comment.go
52 lines (45 loc) · 1.65 KB
/
ticket_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
46
47
48
49
50
51
52
package zendesk
import (
"fmt"
"time"
)
// TicketComment represents a comment on a Ticket.
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/ticket_comments
type TicketComment struct {
ID *int64 `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Body *string `json:"body,omitempty"`
HTMLBody *string `json:"html_body,omitempty"`
Public *bool `json:"public,omitempty"`
AuthorID *int64 `json:"author_id,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Uploads []string `json:"uploads,omitempty"`
Via *Via `json:"via,comitempty"`
}
type RedactedString struct {
Text *string `json:"text"`
}
func (c *client) ListTicketCommentsDesc(id int64) ([]TicketComment, error) {
out := new(APIPayload)
err := c.get(fmt.Sprintf("/api/v2/tickets/%d/comments.json?sort_order=desc", id), out)
return out.Comments, err
}
func (c *client) ListTicketComments(id int64) ([]TicketComment, error) {
out := new(APIPayload)
err := c.get(fmt.Sprintf("/api/v2/tickets/%d/comments.json", id), out)
return out.Comments, err
}
// Redact Comment String removes a string in the comment text
//
// Zendesk Core API docs: https://developer.zendesk.com/rest_api/docs/core/ticket_comments#redact-string-in-comment
func (c *client) RedactCommentString(id, ticketID int64, text string) (*TicketComment, error) {
in := &RedactedString{Text: &text}
out := new(APIPayload)
err := c.put(
fmt.Sprintf("/api/v2/tickets/%d/comments/%d/redact.json", ticketID, id),
in,
out)
return out.Comment, err
}