Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions intercom-java/src/main/java/io/intercom/api/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,39 @@ public static User update(User user) throws InvalidException, AuthorizationExcep
return DataResource.update(UserUpdate.buildFrom(user), "users", User.class);
}

public static User delete(String id)
/**
* @deprecated Replaced by {@link #archive(String)}. Renamed for consistency with API language
*/
public static User delete(String id) {
return archive(id);
}

public static User archive(String id)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.delete(id, "users", User.class);
}

public static User delete(Map<String, String> params)
public static UserPermanentDeleteResponse permanentDelete(String id)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {

final URI uri = UriBuilder.newBuilder()
.path("user_delete_requests")
.build();
return new HttpClient(uri)
.post(UserPermanentDeleteResponse.class, new UserPermanentDeleteRequest(id));
}

/**
* @deprecated Replaced by {@link #archive(Map)}. Renamed for consistency with API language
*/
@Deprecated
public static User delete(Map<String, String> params)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return archive(params);
}

public static User archive(Map<String, String> params)
throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
return DataResource.delete(params, "users", User.class);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.intercom.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class UserPermanentDeleteRequest {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed to PermanentlyDeleteUserRequest.


@JsonProperty("intercom_user_id")
private String intercomUserId;

public UserPermanentDeleteRequest() {
}

public UserPermanentDeleteRequest(String intercomUserId) {
this.setIntercomUserId(intercomUserId);
}

public String getIntercomUserId() {
return intercomUserId;
}

public UserPermanentDeleteRequest setIntercomUserId(String intercomUserId) {
this.intercomUserId = intercomUserId;
return this;
}

@Override
public String toString() {
return "UserPermanentlyDeleteResponse{" +
"intercomUserId='" + intercomUserId + '\'' +
"} " + super.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.intercom.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@SuppressWarnings("UnusedDeclaration")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class UserPermanentDeleteResponse {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed to PermanentlyDeleteUserResponse.


@JsonProperty("id")
private String id;

public UserPermanentDeleteResponse() {
}

public String getId() {
return id;
}

public UserPermanentDeleteResponse setId(String id) {
this.id = id;
return this;
}

@Override
public String toString() {
return "UserPermanentDeleteResponse{" +
"id='" + id + '\'' +
"} " + super.toString();
}
}
7 changes: 7 additions & 0 deletions intercom-java/src/test/java/io/intercom/api/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,11 @@ public void testBulkValidation() {
assertTrue(e.getFirstError() != null);
}
}

@Test
public void TestPermanentDelete() throws Exception{
String json = load("permanent_delete_response.json");
final UserPermanentDeleteResponse userPermanentDeleteResponse= mapper.readValue(json, UserPermanentDeleteResponse.class);
assertEquals("123456", userPermanentDeleteResponse.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": 123456
}