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
10 changes: 10 additions & 0 deletions src/main/java/com/resend/Resend.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.resend.services.batch.Batch;
import com.resend.services.broadcasts.Broadcasts;
import com.resend.services.contacts.Contacts;
import com.resend.services.contactproperties.ContactProperties;
import com.resend.services.domains.Domains;
import com.resend.services.emails.Emails;
import com.resend.services.webhooks.Webhooks;
Expand Down Expand Up @@ -67,6 +68,15 @@ public Contacts contacts() {
return new Contacts(apiKey);
}

/**
* Returns a ContactProperties object that can be used to interact with the ContactProperties service.
*
* @return A ContactProperties object.
*/
public ContactProperties contactProperties() {
return new ContactProperties(apiKey);
}

/**
* Returns an Audience object that can be used to interact with the Audiences service.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package com.resend.services.contactproperties;

import com.resend.core.exception.ResendException;
import com.resend.core.net.AbstractHttpResponse;
import com.resend.core.net.HttpMethod;
import com.resend.core.service.BaseService;
import com.resend.services.contactproperties.model.*;
import okhttp3.MediaType;

/**
* Represents the Resend ContactProperties module.
*/
public class ContactProperties extends BaseService {

/**
* Constructs an instance of the {@code ContactProperties} class.
*
* @param apiKey The apiKey used for authentication.
*/
public ContactProperties(final String apiKey) {
super(apiKey);
}

/**
* Creates a ContactProperty.
*
* @param createContactPropertyOptions The ContactProperty details.
* @return The details of the created contact property.
* @throws ResendException If an error occurs during the ContactProperty creation process.
*/
public CreateContactPropertyResponseSuccess create(CreateContactPropertyOptions createContactPropertyOptions) throws ResendException {
String payload = super.resendMapper.writeValue(createContactPropertyOptions);
AbstractHttpResponse<String> response = httpClient.perform("/contact-properties", super.apiKey, HttpMethod.POST, payload, MediaType.get("application/json"));
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 30, 2025

Choose a reason for hiding this comment

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

Rule violated: API Key Permission Check SDK Methods

Please double-check that the production Resend API keys already include the scopes needed for the new /contact-properties create/list/get/update/remove calls; otherwise these SDK methods will fail immediately once deployed, violating the API Key Permission Check SDK Methods guideline.

Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/contactproperties/ContactProperties.java at line 33:

<comment>Please double-check that the production Resend API keys already include the scopes needed for the new /contact-properties create/list/get/update/remove calls; otherwise these SDK methods will fail immediately once deployed, violating the API Key Permission Check SDK Methods guideline.</comment>

<file context>
@@ -0,0 +1,130 @@
+     */
+    public CreateContactPropertyResponseSuccess create(CreateContactPropertyOptions createContactPropertyOptions) throws ResendException {
+        String payload = super.resendMapper.writeValue(createContactPropertyOptions);
+        AbstractHttpResponse&lt;String&gt; response = httpClient.perform(&quot;/contact-properties&quot;, super.apiKey, HttpMethod.POST, payload, MediaType.get(&quot;application/json&quot;));
+
+        if (!response.isSuccessful()) {
</file context>
Fix with Cubic


if (!response.isSuccessful()) {
throw new ResendException(response.getCode(), response.getBody());
}

String responseBody = response.getBody();
return resendMapper.readValue(responseBody, CreateContactPropertyResponseSuccess.class);
}

/**
* Retrieves a list of contact properties and returns a ListContactPropertiesResponseSuccess.
*
* @return A ListContactPropertiesResponseSuccess containing the list of contact properties.
* @throws ResendException If an error occurs during the contact properties list retrieval process.
*/
public ListContactPropertiesResponseSuccess list() throws ResendException {
AbstractHttpResponse<String> response = this.httpClient.perform("/contact-properties", super.apiKey, HttpMethod.GET, null, MediaType.get("application/json"));

if (!response.isSuccessful()) {
throw new ResendException(response.getCode(), response.getBody());
}

String responseBody = response.getBody();

return resendMapper.readValue(responseBody, ListContactPropertiesResponseSuccess.class);
}

/**
* Retrieves a contact property by its unique identifier.
*
* @param id The contact property's id.
* @return The retrieved contact property details.
* @throws ResendException If an error occurs while retrieving the contact property.
*/
public ContactProperty get(String id) throws ResendException {
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("Contact property id must be provided");
}

AbstractHttpResponse<String> response = this.httpClient.perform("/contact-properties/" + id, super.apiKey, HttpMethod.GET, null, MediaType.get("application/json"));

if (!response.isSuccessful()) {
throw new ResendException(response.getCode(), response.getBody());
}

String responseBody = response.getBody();

return resendMapper.readValue(responseBody, ContactProperty.class);
}

/**
* Updates a contact property based on the provided contact property ID.
*
* @param updateContactPropertyOptions The object with the contact property id and fallback value to update.
* @return The UpdateContactPropertyResponseSuccess with the details of the updated contact property.
* @throws ResendException If an error occurs during the contact property update process.
*/
public UpdateContactPropertyResponseSuccess update(UpdateContactPropertyOptions updateContactPropertyOptions) throws ResendException {
if (updateContactPropertyOptions.getId() == null || updateContactPropertyOptions.getId().isEmpty()) {
throw new IllegalArgumentException("Contact property id must be provided");
}

String payload = super.resendMapper.writeValue(updateContactPropertyOptions);
AbstractHttpResponse<String> response = httpClient.perform("/contact-properties/" + updateContactPropertyOptions.getId(), super.apiKey, HttpMethod.PATCH, payload, MediaType.get("application/json"));

if (!response.isSuccessful()) {
throw new ResendException(response.getCode(), response.getBody());
}

String responseBody = response.getBody();

return resendMapper.readValue(responseBody, UpdateContactPropertyResponseSuccess.class);
}

/**
* Deletes a contact property based on the provided contact property ID.
*
* @param id The identifier of the contact property to delete.
* @return The RemoveContactPropertyResponseSuccess with the details of the removed contact property.
* @throws ResendException If an error occurs during the contact property deletion process.
*/
public RemoveContactPropertyResponseSuccess remove(String id) throws ResendException {
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("Contact property id must be provided");
}

AbstractHttpResponse<String> response = httpClient.perform("/contact-properties/" + id, super.apiKey, HttpMethod.DELETE, "", null);

if (!response.isSuccessful()) {
throw new ResendException(response.getCode(), response.getBody());
}

String responseBody = response.getBody();

return resendMapper.readValue(responseBody, RemoveContactPropertyResponseSuccess.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.resend.services.contactproperties.model;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Base contact property with common properties
*/
public abstract class BaseContactProperty {
@JsonProperty("id")
private String id;

@JsonProperty("object")
private String object;

/**
* Default constructor
*/
public BaseContactProperty() {
}

/**
* Constructs a base contact property.
*
* @param id The ID of the contact property.
* @param object The object type of the contact property.
*/
public BaseContactProperty(final String id, final String object) {
this.id = id;
this.object = object;
}

/**
* Gets the ID of the contact property.
*
* @return The ID of the contact property.
*/
public String getId() {
return id;
}

/**
* Gets the object type of the contact property.
*
* @return The object type of the contact property.
*/
public String getObject() {
return object;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.resend.services.contactproperties.model;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Represents a contact property item.
*/
public class ContactProperty {

@JsonProperty("id")
private String id;

@JsonProperty("key")
private String key;

@JsonProperty("object")
private String object;

@JsonProperty("created_at")
private String createdAt;

@JsonProperty("type")
private String type;

@JsonProperty("fallback_value")
private Object fallbackValue;

/**
* Default constructor
*/
public ContactProperty() {

}

/**
* Creates an instance of ContactProperty with the specified attributes.
*
* @param id The ID of the contact property.
* @param key The key of the contact property.
* @param object The object type of the contact property.
* @param createdAt The creation timestamp of the contact property.
* @param type The type of the contact property.
* @param fallbackValue The fallback value of the contact property.
*/
public ContactProperty(final String id, final String key, final String object, final String createdAt, final String type, final Object fallbackValue) {
this.id = id;
this.key = key;
this.object = object;
this.createdAt = createdAt;
this.type = type;
this.fallbackValue = fallbackValue;
}

/**
* Gets the ID of the contact property.
*
* @return The ID of the contact property.
*/
public String getId() {
return id;
}

/**
* Gets the key of the contact property.
*
* @return The key of the contact property.
*/
public String getKey() {
return key;
}

/**
* Gets the object type of the contact property.
*
* @return The object type of the contact property.
*/
public String getObject() {
return object;
}

/**
* Gets the creation timestamp of the contact property.
*
* @return The creation timestamp of the contact property.
*/
public String getCreatedAt() {
return createdAt;
}

/**
* Gets the type of the contact property.
*
* @return The type of the contact property.
*/
public String getType() {
return type;
}

/**
* Gets the fallback value of the contact property.
*
* @return The fallback value of the contact property.
*/
public Object getFallbackValue() {
return fallbackValue;
}
}
Loading