Skip to content

Commit 013a707

Browse files
danielzimmermannjohnou
authored andcommitted
Adding of features to be GDPR compliant (#257)
* added gdpr delete of users and tickets * added gdpr delete of user * added smoke tests * moved delete methods to permanently methods because both need to be called * fixed getTicketsById test * set to 0.6.3-SNAPSHOT * added method again, was removed by copy/paste error * added single imports * added single imports * removed double deletion from user and tickets * readded single imports * added Show Compliance Deletion Statuses
1 parent 860585d commit 013a707

File tree

4 files changed

+286
-23
lines changed

4 files changed

+286
-23
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ History
105105

106106
* 0.5.x - ...
107107

108-
* 0.6.x - Requires Java 8, Upgrade async-http-client to 2.2.0, Jackson to 2.9.3 (+ others updates), Add createTicketAsync method, Add method to inline an article attachment, Add created article,section,category translation, Add suspend user, Add ticket form creation functionality, From now custom field value is an array with multiple value due to Multi-select fields, Changed type of article attachment ID and article ID from int to Long, Include response body in stacktrace message.
108+
* 0.6.x - Requires Java 8, Upgrade async-http-client to 2.2.0, Jackson to 2.9.3 (+ others updates), Add createTicketAsync method, Add method to inline an article attachment, Add created article,section,category translation, Add suspend user, Add ticket form creation functionality, From now custom field value is an array with multiple value due to Multi-select fields, Changed type of article attachment ID and article ID from int to Long, Include response body in stacktrace message,
109+
Added permanently GDPR delete of Tickets and User
109110

110111
[zd]: http://zendesk.com

src/main/java/org/zendesk/client/v2/Zendesk.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.zendesk.client.v2.model.Automation;
2828
import org.zendesk.client.v2.model.Brand;
2929
import org.zendesk.client.v2.model.Comment;
30+
import org.zendesk.client.v2.model.ComplianceDeletionStatus;
3031
import org.zendesk.client.v2.model.Field;
3132
import org.zendesk.client.v2.model.Forum;
3233
import org.zendesk.client.v2.model.Group;
@@ -267,6 +268,11 @@ public List<User> getTicketCollaborators(long id) {
267268
handleList(User.class, "users")));
268269
}
269270

271+
public JobStatus permanentlyDeleteTicket(Ticket ticket) {
272+
checkHasId(ticket);
273+
return permanentlyDeleteTicket(ticket.getId());
274+
}
275+
270276
public void deleteTicket(Ticket ticket) {
271277
checkHasId(ticket);
272278
deleteTicket(ticket.getId());
@@ -276,6 +282,14 @@ public void deleteTicket(long id) {
276282
complete(submit(req("DELETE", tmpl("/tickets/{id}.json").set("id", id)), handleStatus()));
277283
}
278284

285+
public JobStatus permanentlyDeleteTicket(long id) {
286+
deleteTicket(id);
287+
return complete(submit(
288+
req("DELETE", tmpl("/deleted_tickets/{id}.json").set("id", id)),
289+
handleJobStatus(JobStatus.class))
290+
);
291+
}
292+
279293
public ListenableFuture<JobStatus<Ticket>> queueCreateTicketAsync(Ticket ticket) {
280294
return submit(req("POST", cnst("/tickets.json?async=true"),
281295
JSON, json(Collections.singletonMap("ticket", ticket))),
@@ -326,6 +340,16 @@ public void deleteTickets(long id, long... ids) {
326340
handleStatus()));
327341
}
328342

343+
public JobStatus permanentlyDeleteTickets(long id, long... ids) {
344+
deleteTickets(id, ids);
345+
346+
return complete(
347+
submit(
348+
req("DELETE", tmpl("/deleted_tickets/destroy_many.json{?ids}").set("ids", idArray(id, ids))),
349+
handleJobStatus(JobStatus.class))
350+
);
351+
}
352+
329353
public Iterable<Ticket> getTickets() {
330354
return new PagedIterable<>(cnst("/tickets.json"), handleList(Ticket.class, "tickets"));
331355
}
@@ -412,6 +436,11 @@ public Iterable<Ticket> getUserRequestedTickets(long userId) {
412436
handleList(Ticket.class, "tickets"));
413437
}
414438

439+
public Iterable<ComplianceDeletionStatus> getComplianceDeletionStatuses(long userId) {
440+
return new PagedIterable<>(tmpl("/users/{userId}/compliance_deletion_statuses.json").set("userId", userId),
441+
handleList(ComplianceDeletionStatus.class, "compliance_deletion_statuses"));
442+
}
443+
415444
public Iterable<Ticket> getUserCCDTickets(long userId) {
416445
return new PagedIterable<>(tmpl("/users/{userId}/tickets/ccd.json").set("userId", userId),
417446
handleList(Ticket.class, "tickets"));
@@ -773,6 +802,16 @@ public void deleteUser(long id) {
773802
complete(submit(req("DELETE", tmpl("/users/{id}.json").set("id", id)), handleStatus()));
774803
}
775804

805+
public User permanentlyDeleteUser(User user) {
806+
checkHasId(user);
807+
return permanentlyDeleteUser(user.getId());
808+
}
809+
810+
public User permanentlyDeleteUser(long id) {
811+
deleteUser(id);
812+
return complete(submit(req("DELETE", tmpl("/deleted_users/{id}.json").set("id", id)), handle(User.class)));
813+
}
814+
776815
public User suspendUser(long id) {
777816
User user = new User();
778817
user.setId(id);
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.zendesk.client.v2.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import java.io.Serializable;
6+
import java.util.Date;
7+
8+
/**
9+
* https://developer.zendesk.com/rest_api/docs/core/users#show-compliance-deletion-statuses
10+
*/
11+
public class ComplianceDeletionStatus implements Serializable {
12+
13+
private static final long serialVersionUID = 1L;
14+
15+
private String action;
16+
private String application;
17+
@JsonProperty("account_subdomain")
18+
private String accountSubdomain;
19+
@JsonProperty("executer_id")
20+
private long executerId;
21+
@JsonProperty("user_id")
22+
private long userId;
23+
@JsonProperty("account_id")
24+
private long accountId;
25+
@JsonProperty("created_at")
26+
private Date createdAt;
27+
28+
public static long getSerialVersionUID() {
29+
return serialVersionUID;
30+
}
31+
32+
public String getAction() {
33+
return action;
34+
}
35+
36+
public void setAction(String action) {
37+
this.action = action;
38+
}
39+
40+
public String getApplication() {
41+
return application;
42+
}
43+
44+
public void setApplication(String application) {
45+
this.application = application;
46+
}
47+
48+
public String getAccountSubdomain() {
49+
return accountSubdomain;
50+
}
51+
52+
public void setAccountSubdomain(String accountSubdomain) {
53+
this.accountSubdomain = accountSubdomain;
54+
}
55+
56+
public long getExecuterId() {
57+
return executerId;
58+
}
59+
60+
public void setExecuterId(long executerId) {
61+
this.executerId = executerId;
62+
}
63+
64+
public long getUserId() {
65+
return userId;
66+
}
67+
68+
public void setUserId(long userId) {
69+
this.userId = userId;
70+
}
71+
72+
public long getAccountId() {
73+
return accountId;
74+
}
75+
76+
public void setAccountId(long accountId) {
77+
this.accountId = accountId;
78+
}
79+
80+
public Date getCreatedAt() {
81+
return new Date(createdAt.getTime());
82+
}
83+
84+
public void setCreatedAt(Date createdAt) {
85+
this.createdAt = createdAt;
86+
}
87+
88+
@Override
89+
public String toString() {
90+
return "ComplianceDeletionStatus{" +
91+
"action='" + action + '\'' +
92+
", application='" + application + '\'' +
93+
", accountSubdomain='" + accountSubdomain + '\'' +
94+
", executerId=" + executerId +
95+
", userId=" + userId +
96+
", accountId=" + accountId +
97+
", createdAt=" + createdAt +
98+
'}';
99+
}
100+
}

0 commit comments

Comments
 (0)