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
4 changes: 4 additions & 0 deletions src/main/java/co/lettermint/api/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.net.URLEncoder;
import java.util.Map;

public class ApiClient {

Check warning on line 10 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 10 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 10 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;
private final DomainsEndpoint domains;
private final MessagesEndpoint messages;
Expand All @@ -18,7 +18,7 @@
private final TeamEndpoint team;
private final WebhooksEndpoint webhooks;

public ApiClient(String apiToken, String baseUrl) {

Check warning on line 21 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 21 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 21 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
this.client = new LettermintClient(apiToken, baseUrl, LettermintClient.AuthMode.BEARER);
this.domains = new DomainsEndpoint(client);
this.messages = new MessagesEndpoint(client);
Expand Down Expand Up @@ -78,7 +78,7 @@
}
}

public static class DomainsEndpoint {

Check warning on line 81 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 81 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 81 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

DomainsEndpoint(LettermintClient client) {
Expand Down Expand Up @@ -118,7 +118,7 @@
}
}

public static class MessagesEndpoint {

Check warning on line 121 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 121 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 121 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

MessagesEndpoint(LettermintClient client) {
Expand All @@ -145,6 +145,10 @@
return client.post("/messages/" + segment(messageId) + "/cancel", null, RescheduleMessageResponse.class);
}

public ProcessInboundMessageResponse process(String messageId) {
return client.post("/messages/" + segment(messageId) + "/process", null, ProcessInboundMessageResponse.class);
}

public MessageEventsResponse events(String messageId) {
return events(messageId, null);
}
Expand All @@ -166,7 +170,7 @@
}
}

public static class ProjectsEndpoint {

Check warning on line 173 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 173 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 173 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

ProjectsEndpoint(LettermintClient client) {
Expand Down Expand Up @@ -214,7 +218,7 @@
}
}

public static class RoutesEndpoint {

Check warning on line 221 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 221 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 221 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

RoutesEndpoint(LettermintClient client) {
Expand All @@ -238,7 +242,7 @@
}
}

public static class StatsEndpoint {

Check warning on line 245 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 245 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 245 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

StatsEndpoint(LettermintClient client) {
Expand All @@ -254,7 +258,7 @@
}
}

public static class SuppressionsEndpoint {

Check warning on line 261 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 261 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 261 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

SuppressionsEndpoint(LettermintClient client) {
Expand All @@ -278,7 +282,7 @@
}
}

public static class TeamEndpoint {

Check warning on line 285 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 285 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 285 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

TeamEndpoint(LettermintClient client) {
Expand Down Expand Up @@ -322,7 +326,7 @@
}
}

public static class WebhooksEndpoint {

Check warning on line 329 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 17 - ubuntu-latest)

no comment

Check warning on line 329 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Test (Java 21 - ubuntu-latest)

no comment

Check warning on line 329 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment
private final LettermintClient client;

WebhooksEndpoint(LettermintClient client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public final class MessageEventType {
public static final String INBOUNDRECEIVED = "inbound_received";
public static final String INBOUNDQUEUED = "inbound_queued";
public static final String INBOUNDSPAMBLOCKED = "inbound_spam_blocked";
public static final String INBOUNDRELEASED = "inbound_released";
public static final String INBOUNDPROCESSED = "inbound_processed";
public static final String INBOUNDRETRY = "inbound_retry";

Expand Down
1 change: 1 addition & 0 deletions src/main/java/co/lettermint/models/api/MessageStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public final class MessageStatus {
public static final String SCHEDULED = "scheduled";
public static final String PENDING = "pending";
public static final String QUEUED = "queued";
public static final String QUARANTINED = "quarantined";
public static final String SUPPRESSED = "suppressed";
public static final String PROCESSED = "processed";
public static final String DELIVERED = "delivered";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.lettermint.models.api;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ProcessInboundMessageResponse {
@JsonProperty("data")
public Map<String, Object> data;
}
6 changes: 6 additions & 0 deletions src/test/java/co/lettermint/ApiClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ void schedulesMessageChangesWithTypedResponses() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.enqueue(new MockResponse().setHeader("Content-Type", "application/json").setBody("{\"message_id\":\"msg/id\",\"status\":\"scheduled\",\"scheduled_at\":\"2026-08-27T09:00:00Z\"}"));
server.enqueue(new MockResponse().setHeader("Content-Type", "application/json").setBody("{\"message_id\":\"msg/id\",\"status\":\"canceled\",\"scheduled_at\":null}"));
server.enqueue(new MockResponse().setHeader("Content-Type", "application/json").setBody("{\"data\":{\"message_id\":\"msg/id\",\"status\":\"queued\",\"webhook_target_count\":1}}"));
server.start();

ApiClient api = Lettermint.api("api-token", server.url("/v1").toString());
co.lettermint.models.api.RescheduleMessageRequest payload = new co.lettermint.models.api.RescheduleMessageRequest();
payload.scheduledAt = "2026-08-27T09:00:00Z";
assertEquals("scheduled", api.messages().reschedule("msg/id", payload).status);
assertEquals("canceled", api.messages().cancel("msg/id").status);
assertEquals("queued", api.messages().process("msg/id").data.get("status"));

RecordedRequest reschedule = server.takeRequest();
assertEquals("PATCH", reschedule.getMethod());
Expand All @@ -165,6 +167,9 @@ void schedulesMessageChangesWithTypedResponses() throws Exception {
RecordedRequest cancel = server.takeRequest();
assertEquals("POST", cancel.getMethod());
assertEquals("/v1/messages/msg%2Fid/cancel", cancel.getPath());
RecordedRequest process = server.takeRequest();
assertEquals("POST", process.getMethod());
assertEquals("/v1/messages/msg%2Fid/process", process.getPath());
}
}

Expand Down Expand Up @@ -270,6 +275,7 @@ void apiExposesDocumentedOperations() throws Exception {
methods.put("message.show", api.messages().getClass().getMethod("retrieve", String.class));
methods.put("rescheduleMessage", api.messages().getClass().getMethod("reschedule", String.class, co.lettermint.models.api.RescheduleMessageRequest.class));
methods.put("cancelScheduledMessage", api.messages().getClass().getMethod("cancel", String.class));
methods.put("processInboundMessage", api.messages().getClass().getMethod("process", String.class));
methods.put("message.events", api.messages().getClass().getMethod("events", String.class));
methods.put("message.source", api.messages().getClass().getMethod("source", String.class));
methods.put("message.html", api.messages().getClass().getMethod("html", String.class));
Expand Down
Loading