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

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

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 All @@ -34,6 +34,10 @@
return client.getRaw("/ping").trim();
}

public BlockedFileTypesResponse blockedFileTypes() {
return client.get("/blocked-file-types", BlockedFileTypesResponse.class);
}

public DomainsEndpoint domains() {
return domains;
}
Expand Down Expand Up @@ -74,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

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 @@ -114,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

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 Down Expand Up @@ -154,7 +158,7 @@
}
}

public static class ProjectsEndpoint {

Check warning on line 161 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 161 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 161 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment

Check warning on line 161 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 161 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 161 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

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

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

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

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 @@ -310,7 +314,7 @@
}
}

public static class WebhooksEndpoint {

Check warning on line 317 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 317 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 317 in src/main/java/co/lettermint/api/ApiClient.java

View workflow job for this annotation

GitHub Actions / Build

no comment

Check warning on line 317 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 317 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 317 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
@@ -0,0 +1,14 @@
package co.lettermint.models.api;

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

@JsonIgnoreProperties(ignoreUnknown = true)
public class BlockedFileTypesResponse {
@JsonProperty("extensions")
public List<String> extensions;

@JsonProperty("mime_types")
public List<String> mimeTypes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public final class MessageEventType {
public static final String PROCESSED = "processed";
public static final String SUPPRESSED = "suppressed";
public static final String DELIVERED = "delivered";
public static final String AUTOREPLIED = "auto_replied";
public static final String SOFTBOUNCED = "soft_bounced";
public static final String HARDBOUNCED = "hard_bounced";
public static final String SPAMCOMPLAINT = "spam_complaint";
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/co/lettermint/models/api/ProjectData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class ProjectData {
@JsonProperty("smtp_enabled")
public Boolean smtpEnabled;

@JsonProperty("redact_email_content")
public Boolean redactEmailContent;

@JsonProperty("default_route_id")
public String defaultRouteId;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/co/lettermint/models/api/StoreProjectData.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ public class StoreProjectData {

@JsonProperty("initial_routes")
public InitialRoutes initialRoutes;

@JsonProperty("short_token")
public Boolean shortToken;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class StoreSuppressionData {
public SuppressionReason reason;

@JsonProperty("scope")
public String scope;
public SuppressionScope scope;

@JsonProperty("route_id")
public String routeId;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/co/lettermint/models/api/UpdateProjectData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class UpdateProjectData {
@JsonProperty("smtp_enabled")
public Boolean smtpEnabled;

@JsonProperty("redact_email_content")
public Boolean redactEmailContent;

@JsonProperty("default_route_id")
public String defaultRouteId;
}
5 changes: 2 additions & 3 deletions src/main/java/co/lettermint/models/api/UpdateRouteData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

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

@JsonIgnoreProperties(ignoreUnknown = true)
public class UpdateRouteData {
@JsonProperty("name")
public String name;

@JsonProperty("settings")
public Map<String, Object> settings;
public UpdateRouteSettingsData settings;

@JsonProperty("inbound_settings")
public Map<String, Object> inboundSettings;
public UpdateRouteInboundSettingsData inboundSettings;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package co.lettermint.models.api;

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

@JsonIgnoreProperties(ignoreUnknown = true)
public class UpdateRouteInboundSettingsData {
@JsonProperty("inbound_domain")
public String inboundDomain;

@JsonProperty("inbound_spam_threshold")
public Double inboundSpamThreshold;

@JsonProperty("attachment_delivery")
public AttachmentDelivery attachmentDelivery;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package co.lettermint.models.api;

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

@JsonIgnoreProperties(ignoreUnknown = true)
public class UpdateRouteSettingsData {
@JsonProperty("track_opens")
public Boolean trackOpens;

@JsonProperty("track_clicks")
public Boolean trackClicks;

@JsonProperty("disable_plaintext_generation")
public Boolean disablePlaintextGeneration;

@JsonProperty("disable_hosted_unsubscribe")
public Boolean disableHostedUnsubscribe;

@JsonProperty("redact_email_content")
public Boolean redactEmailContent;
}
1 change: 1 addition & 0 deletions src/main/java/co/lettermint/models/api/VolumeTier.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public final class VolumeTier {
public static final int VALUE_10000 = 10000;
public static final int VALUE_50000 = 50000;
public static final int VALUE_125000 = 125000;
public static final int VALUE_300000 = 300000;
public static final int VALUE_500000 = 500000;
public static final int VALUE_750000 = 750000;
public static final int VALUE_1000000 = 1000000;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/co/lettermint/models/api/WebhookEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public final class WebhookEvent {
public static final String MESSAGECREATED = "message.created";
public static final String MESSAGESENT = "message.sent";
public static final String MESSAGEDELIVERED = "message.delivered";
public static final String MESSAGEAUTOREPLIED = "message.auto_replied";
public static final String MESSAGEHARDBOUNCED = "message.hard_bounced";
public static final String MESSAGESOFTBOUNCED = "message.soft_bounced";
public static final String MESSAGESPAMCOMPLAINT = "message.spam_complaint";
Expand Down
59 changes: 59 additions & 0 deletions src/test/java/co/lettermint/ApiClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ void staticApiUsesBearerTokenAndRawPing() throws Exception {
}
}

@Test
void apiBlockedFileTypesUsesBearerToken() throws Exception {
try (MockWebServer server = new MockWebServer()) {
server.enqueue(new MockResponse()
.setHeader("Content-Type", "application/json")
.setBody("{\"extensions\":[\"exe\"],\"mime_types\":[\"application/x-msdownload\"]}"));
server.start();

ApiClient api = Lettermint.api("api-token", server.url("/v1").toString());
co.lettermint.models.api.BlockedFileTypesResponse response = api.blockedFileTypes();

RecordedRequest request = server.takeRequest();
assertEquals("/v1/blocked-file-types", request.getPath());
assertEquals("Bearer api-token", request.getHeader("Authorization"));
assertNull(request.getHeader("x-lettermint-token"));
assertEquals("exe", response.extensions.get(0));
}
}

@Test
void sendsBatchEmailsWithTypedPayloads() throws Exception {
try (MockWebServer server = new MockWebServer()) {
Expand Down Expand Up @@ -119,6 +138,45 @@ void publicClientRejectsAbsoluteRequestPaths() throws Exception {
assertEquals("Request path must be relative", exception.getMessage());
}

@Test
void generatedApiModelsMatchCurrentTeamSchema() {
assertEquals("auto_replied", co.lettermint.models.api.MessageEventType.AUTOREPLIED);
assertEquals("message.auto_replied", co.lettermint.models.api.WebhookEvent.MESSAGEAUTOREPLIED);
assertEquals(300000, co.lettermint.models.api.VolumeTier.VALUE_300000);

co.lettermint.models.api.UpdateRouteSettingsData settings = new co.lettermint.models.api.UpdateRouteSettingsData();
settings.redactEmailContent = true;
settings.disablePlaintextGeneration = false;

co.lettermint.models.api.UpdateRouteInboundSettingsData inboundSettings = new co.lettermint.models.api.UpdateRouteInboundSettingsData();
inboundSettings.inboundSpamThreshold = 3.0;

co.lettermint.models.api.UpdateRouteData routeUpdate = new co.lettermint.models.api.UpdateRouteData();
routeUpdate.settings = settings;
routeUpdate.inboundSettings = inboundSettings;

co.lettermint.models.api.UpdateProjectData projectUpdate = new co.lettermint.models.api.UpdateProjectData();
projectUpdate.redactEmailContent = false;

co.lettermint.models.api.ProjectData project = new co.lettermint.models.api.ProjectData();
project.redactEmailContent = true;

co.lettermint.models.api.StoreProjectData projectCreate = new co.lettermint.models.api.StoreProjectData();
projectCreate.shortToken = true;

co.lettermint.models.api.BlockedFileTypesResponse blockedFileTypes = new co.lettermint.models.api.BlockedFileTypesResponse();
blockedFileTypes.extensions = Collections.singletonList("exe");
blockedFileTypes.mimeTypes = Collections.singletonList("application/x-msdownload");

assertFalse(routeUpdate.settings.disablePlaintextGeneration);
assertEquals(3.0, routeUpdate.inboundSettings.inboundSpamThreshold);
assertFalse(projectUpdate.redactEmailContent);
assertTrue(projectCreate.shortToken);
assertTrue(project.redactEmailContent);
assertEquals("global", co.lettermint.models.api.SuppressionScope.GLOBAL);
assertEquals("application/x-msdownload", blockedFileTypes.mimeTypes.get(0));
}

@Test
void apiExposesDocumentedOperations() throws Exception {
ApiClient api = Lettermint.api("api-token");
Expand All @@ -131,6 +189,7 @@ void apiExposesDocumentedOperations() throws Exception {
methods.put("domain.verifySpecificDnsRecord", api.domains().getClass().getMethod("verifyDnsRecord", String.class, String.class));
methods.put("domain.updateProjects", api.domains().getClass().getMethod("updateProjects", String.class, co.lettermint.models.api.UpdateDomainProjectsData.class));
methods.put("v1.ping", api.getClass().getMethod("ping"));
methods.put("v1.blockedFileTypes", api.getClass().getMethod("blockedFileTypes"));
methods.put("message.index", api.messages().getClass().getMethod("list"));
methods.put("message.show", api.messages().getClass().getMethod("retrieve", String.class));
methods.put("message.events", api.messages().getClass().getMethod("events", String.class));
Expand Down
Loading