Skip to content

Commit da6c30a

Browse files
author
nukosuke
authored
Merge pull request #268 from pierce-m/redact-attachment
Add support for ticket comment attachment redaction
2 parents 3fc4967 + 9719686 commit da6c30a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"attachment": {
3+
"content_type": "application/binary",
4+
"content_url": "https://company.zendesk.com/attachments/myfile.dat",
5+
"file_name": "myfile.dat",
6+
"id": 498483,
7+
"size": 2532,
8+
"thumbnails": [],
9+
"url": "https://company.zendesk.com/api/v2/attachments/498483.json"
10+
}
11+
}

zendesk/attachment.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,11 @@ func (z *Client) GetAttachment(ctx context.Context, id int64) (Attachment, error
196196

197197
return result.Attachment, nil
198198
}
199+
200+
// RedactCommentAttachment deletes an attachment with attachmentID on comment with commentID for ticket with ticketID
201+
// https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-attachments/#redact-comment-attachment
202+
func (z *Client) RedactCommentAttachment(ctx context.Context, ticketID, commentID, attachmentID int64) error {
203+
path := fmt.Sprintf("/api/v2/tickets/%d/comments/%d/attachments/%d/redact", ticketID, commentID, attachmentID)
204+
_, err := z.put(ctx, path, nil)
205+
return err
206+
}

zendesk/attachment_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,15 @@ func TestGetAttachment(t *testing.T) {
118118
t.Fatalf("Returned attachment does not have the expected ID %d. Attachment id is %d", expectedID, attachment.ID)
119119
}
120120
}
121+
122+
func TestRedactCommentAttachment(t *testing.T) {
123+
mockAPI := newMockAPI(http.MethodPut, "redact_ticket_comment_attachment.json")
124+
client := newTestClient(mockAPI)
125+
defer mockAPI.Close()
126+
127+
err := client.RedactCommentAttachment(ctx, 123, 456, 789)
128+
129+
if err != nil {
130+
t.Fatalf("Failed to redact ticket comment attachment: %s", err)
131+
}
132+
}

0 commit comments

Comments
 (0)