diff --git a/fixture/PUT/redact_ticket_comment_string.json b/fixture/PUT/redact_ticket_comment_string.json new file mode 100644 index 00000000..0599d3c7 --- /dev/null +++ b/fixture/PUT/redact_ticket_comment_string.json @@ -0,0 +1,8 @@ +{ + "comment": { + "author_id": 1, + "id": 35436, + "plain_body": "My social security number is ▇▇▇▇!", + "type": "Comment" + } +} diff --git a/zendesk/ticket_comment.go b/zendesk/ticket_comment.go index 8790633a..84c5cf55 100644 --- a/zendesk/ticket_comment.go +++ b/zendesk/ticket_comment.go @@ -175,3 +175,22 @@ func (z *Client) RedactTicketComment( _, err := z.put(ctx, path, body) return err } + +// RedactTicketCommentStringRequest contains the body of the RedactTicketCommentString PUT request +type RedactTicketCommentStringRequest struct { + Text string `json:"text"` +} + +// RedactTicketCommentString permanently removes words, or strings from a ticket comment +// +// ref: https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#redact-string-in-comment +func (z *Client) RedactTicketCommentString( + ctx context.Context, + ticketID int64, + ticketCommentID int64, + body RedactTicketCommentStringRequest, +) error { + path := fmt.Sprintf("/api/v2/tickets/%d/comments/%d/redact", ticketID, ticketCommentID) + _, err := z.put(ctx, path, body) + return err +} diff --git a/zendesk/ticket_comment_test.go b/zendesk/ticket_comment_test.go index 3659408b..ef3bb40d 100644 --- a/zendesk/ticket_comment_test.go +++ b/zendesk/ticket_comment_test.go @@ -127,3 +127,17 @@ func TestRedactTicketComment(t *testing.T) { t.Fatalf("Failed to redact ticket comment: %s", err) } } + +func TestRedactTicketCommentString(t *testing.T) { + mockAPI := newMockAPI(http.MethodPut, "redact_ticket_comment_string.json") + client := newTestClient(mockAPI) + defer mockAPI.Close() + + err := client.RedactTicketCommentString(ctx, 456, 123, RedactTicketCommentStringRequest{ + Text: "My social security number is 847564!", + }) + + if err != nil { + t.Fatalf("Failed to redact ticket comment: %s", err) + } +}