Skip to content

Conversation

@kewynakshlley
Copy link
Collaborator

@kewynakshlley kewynakshlley commented Oct 31, 2025

Summary by cubic

Split segment and topic operations into dedicated sub-services under Contacts and made Contacts handle only global contacts. Adds APIs to manage contact segment membership and topic subscriptions, and deprecates segment/topic methods and fields in Contacts.

  • New Features

    • Added ContactSegments sub-service: add, remove, and list a contact’s segments (supports pagination).
    • Added ContactTopics sub-service: list (supports pagination) and update a contact’s topic subscriptions.
    • Contacts now exposes segments() and topics() accessors and always uses /contacts for global CRUD.
  • Migration

    • Global contacts: use contacts().create/update/get/remove; segment_id and audience_id fields are ignored.
    • Segments: use contacts().segments().add/remove/list.
    • Topics: use contacts().topics().list/update.
    • Deprecated in Contacts: list(segmentId[, params]), get(GetContactOptions), remove(RemoveContactOptions), getTopics(...), getTopics(..., params), updateTopics(...). These will be removed in a future version.

Written for commit 2393de5. Summary will update automatically on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 17 files

Prompt for AI agents (all 4 issues)

Understand the root cause of the following 4 issues and fix them.


<file name="src/test/java/com/resend/services/contacts/ContactTopicsTest.java">

<violation number="1" location="src/test/java/com/resend/services/contacts/ContactTopicsTest.java:26">
By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.</violation>
</file>

<file name="src/test/java/com/resend/services/contacts/ContactSegmentsTest.java">

<violation number="1" location="src/test/java/com/resend/services/contacts/ContactSegmentsTest.java:24">
These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.</violation>
</file>

<file name="src/main/java/com/resend/services/contacts/Contacts.java">

<violation number="1" location="src/main/java/com/resend/services/contacts/Contacts.java:55">
Rule violated: **API Key Permission Check SDK Methods**

New segments() / topics() accessors expose freshly added Resend segment &amp; topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.</violation>
</file>

<file name="src/main/java/com/resend/services/contacts/ContactSegments.java">

<violation number="1" location="src/main/java/com/resend/services/contacts/ContactSegments.java:4">
Rule violated: **Initialisms and Acronyms Naming Conventions**

Rename `URLHelper` to use camel-case for the acronym (e.g., `UrlHelper`) to comply with the Initialisms and Acronyms Naming Conventions rule.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@BeforeEach
public void setUp() {
MockitoAnnotations.openMocks(this);
contactTopics = mock(ContactTopics.class);
Copy link
Contributor

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

Choose a reason for hiding this comment

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

By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.

Prompt for AI agents
Address the following comment on src/test/java/com/resend/services/contacts/ContactTopicsTest.java at line 26:

<comment>By replacing the ContactTopics under test with a Mockito mock, the subsequent assertions only validate stubbed behavior rather than the real implementation, so the tests provide no meaningful coverage. Please instantiate the real ContactTopics (or a properly configured test double) instead of mocking it here.</comment>

<file context>
@@ -0,0 +1,94 @@
+    @BeforeEach
+    public void setUp() {
+        MockitoAnnotations.openMocks(this);
+        contactTopics = mock(ContactTopics.class);
+    }
+
</file context>
Fix with Cubic

@BeforeEach
public void setUp() {
MockitoAnnotations.openMocks(this);
contactSegments = mock(ContactSegments.class);
Copy link
Contributor

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

Choose a reason for hiding this comment

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

These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.

Prompt for AI agents
Address the following comment on src/test/java/com/resend/services/contacts/ContactSegmentsTest.java at line 24:

<comment>These tests mock ContactSegments itself, so every add/remove/list call is intercepted by Mockito. The real service code (validation, HTTP call, mapping) never runs, making the suite a tautology that cannot catch regressions. Replace the mock with a real instance (with mocked dependencies) or cover behavior at a higher level.</comment>

<file context>
@@ -0,0 +1,145 @@
+    @BeforeEach
+    public void setUp() {
+        MockitoAnnotations.openMocks(this);
+        contactSegments = mock(ContactSegments.class);
+    }
+
</file context>
Fix with Cubic

*
* @return The ContactSegments service instance.
*/
public ContactSegments segments() {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 31, 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

New segments() / topics() accessors expose freshly added Resend segment & topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.

Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/contacts/Contacts.java at line 55:

<comment>New segments() / topics() accessors expose freshly added Resend segment &amp; topic endpoints. Please confirm the production API key is provisioned with the required segment/topic scopes so these calls do not start failing after release.</comment>

<file context>
@@ -24,22 +48,46 @@ public Contacts(final String apiKey) {
+     *
+     * @return The ContactSegments service instance.
+     */
+    public ContactSegments segments() {
+        if (this.contactSegments == null) {
+            this.contactSegments = new ContactSegments(this.apiKey);
</file context>
Fix with Cubic

package com.resend.services.contacts;

import com.resend.core.exception.ResendException;
import com.resend.core.helper.URLHelper;
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Rule violated: Initialisms and Acronyms Naming Conventions

Rename URLHelper to use camel-case for the acronym (e.g., UrlHelper) to comply with the Initialisms and Acronyms Naming Conventions rule.

Prompt for AI agents
Address the following comment on src/main/java/com/resend/services/contacts/ContactSegments.java at line 4:

<comment>Rename `URLHelper` to use camel-case for the acronym (e.g., `UrlHelper`) to comply with the Initialisms and Acronyms Naming Conventions rule.</comment>

<file context>
@@ -0,0 +1,137 @@
+package com.resend.services.contacts;
+
+import com.resend.core.exception.ResendException;
+import com.resend.core.helper.URLHelper;
+import com.resend.core.net.AbstractHttpResponse;
+import com.resend.core.net.HttpMethod;
</file context>
Fix with Cubic

@kewynakshlley kewynakshlley merged commit 9861fe3 into main Oct 31, 2025
4 checks passed
@kewynakshlley kewynakshlley deleted the feat/contact-segment-subservice branch October 31, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants