Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow unknown properties from the API #24

Merged
merged 1 commit into from
Jan 15, 2024
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
2 changes: 2 additions & 0 deletions src/main/java/com/resend/core/mapper/ResendMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
Expand All @@ -17,6 +18,7 @@ public class ResendMapper implements IMapper {
public ResendMapper() {
this.mapper = new ObjectMapper();
this.mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class RemoveContactResponseSuccess extends BaseContact {
@JsonProperty("deleted")
private boolean deleted;

@JsonProperty("contact")
private String contact;

/**
* Default constructor
*/
Expand All @@ -23,8 +26,9 @@ public RemoveContactResponseSuccess() {
* @param id The ID of the removed contact.
* @param object The object of the removed contact.
* @param deleted The state of the removed contact.
* @param contact The contact of the removed contact.
*/
public RemoveContactResponseSuccess(final String id, final String object, final boolean deleted) {
public RemoveContactResponseSuccess(final String id, final String object, final boolean deleted, final String contact) {
super(id, object);
this.deleted = deleted;
}
Expand All @@ -37,4 +41,13 @@ public RemoveContactResponseSuccess(final String id, final String object, final
public boolean getRemoved() {
return deleted;
}

/**
* Gets the contact of the removed item.
*
* @return The contact of the removed item.
*/
public String getContact() {
return contact;
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/resend/services/util/ContactsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static CreateContactResponseSuccess createContactResponseSuccess() {
}

public static RemoveContactResponseSuccess removeContactResponseSuccess() {
return new RemoveContactResponseSuccess("123", "contact", true);
return new RemoveContactResponseSuccess("123", "contact", true, "contact");
}

public static ListContactsResponseSuccess createContactsListResponse() {
Expand Down