Skip to content

Commit 5ee8ea3

Browse files
authored
feat(api): add team RBAC and fix email tags, settings, and batch headers (#36)
* Sync SDK with current OpenAPI specifications * Fix email tags, settings, and batch idempotency
1 parent 788f4e9 commit 5ee8ea3

54 files changed

Lines changed: 472 additions & 165 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/co/lettermint/api/ApiClient.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,6 @@ public ProjectRotateTokenResponse rotateToken(String projectId) {
193193
return client.post("/projects/" + segment(projectId) + "/rotate-token", null, ProjectRotateTokenResponse.class);
194194
}
195195

196-
public ProjectUpdateMembersResponse updateMembers(String projectId, UpdateProjectMembersData payload) {
197-
return client.put("/projects/" + segment(projectId) + "/members", payload, ProjectUpdateMembersResponse.class);
198-
}
199-
200-
public ProjectAddMemberResponse addMember(String projectId, String teamMemberId) {
201-
return client.post("/projects/" + segment(projectId) + "/members/" + segment(teamMemberId), null, ProjectAddMemberResponse.class);
202-
}
203-
204-
public ProjectRemoveMemberResponse removeMember(String projectId, String teamMemberId) {
205-
return client.delete("/projects/" + segment(projectId) + "/members/" + segment(teamMemberId), ProjectRemoveMemberResponse.class);
206-
}
207-
208196
public RouteIndexResponse routes(String projectId) {
209197
return routes(projectId, null);
210198
}
@@ -305,13 +293,25 @@ public TeamUsageDetailData usage(Map<String, String> query) {
305293
return client.get("/team/usage", TeamUsageDetailData.class, query);
306294
}
307295

296+
public TeamRolesResponse roles() {
297+
return client.get("/team/roles", TeamRolesResponse.class);
298+
}
299+
308300
public TeamMembersResponse members() {
309301
return members(null);
310302
}
311303

312304
public TeamMembersResponse members(Map<String, String> query) {
313305
return client.get("/team/members", TeamMembersResponse.class, query);
314306
}
307+
308+
public TeamMemberData member(String userId) {
309+
return client.get("/team/members/" + segment(userId), TeamMemberData.class);
310+
}
311+
312+
public TeamMemberData updateMemberAssignment(String userId, UpdateTeamMemberAssignmentData payload) {
313+
return client.put("/team/members/" + segment(userId) + "/assignment", payload, TeamMemberData.class);
314+
}
315315
}
316316

317317
public static class WebhooksEndpoint {

src/main/java/co/lettermint/client/LettermintClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ public <T> T post(String path, Object payload, Class<T> responseClass, Map<Strin
9292
}
9393

9494
public <T> T post(String path, Object payload, TypeReference<T> responseType) {
95-
return request("POST", url(path, null), payload, null, responseType, null);
95+
return post(path, payload, responseType, null);
96+
}
97+
98+
public <T> T post(String path, Object payload, TypeReference<T> responseType, Map<String, String> headers) {
99+
return request("POST", url(path, null), payload, null, responseType, headers);
96100
}
97101

98102
public <T> T get(String path, Class<T> responseClass) {

src/main/java/co/lettermint/endpoints/EmailEndpoint.java

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class EmailEndpoint extends Endpoint {
2626
private List<Attachment> attachments;
2727
private String route;
2828
private Map<String, Object> metadata;
29-
private List<String> tags;
29+
private String tag;
30+
private Map<String, Object> settings;
3031
private String idempotencyKey;
3132

3233
public EmailEndpoint(LettermintClient client) {
@@ -50,7 +51,8 @@ private void reset() {
5051
this.attachments = new ArrayList<>();
5152
this.route = null;
5253
this.metadata = new LinkedHashMap<>();
53-
this.tags = new ArrayList<>();
54+
this.tag = null;
55+
this.settings = null;
5456
this.idempotencyKey = null;
5557
}
5658

@@ -196,10 +198,18 @@ public EmailEndpoint metadata(String key, Object value) {
196198
}
197199

198200
/**
199-
* Add tags to the email.
201+
* Set the email tag.
200202
*/
201-
public EmailEndpoint tag(String... tags) {
202-
this.tags.addAll(Arrays.asList(tags));
203+
public EmailEndpoint tag(String tag) {
204+
this.tag = tag;
205+
return this;
206+
}
207+
208+
/**
209+
* Set per-email settings that override the selected route.
210+
*/
211+
public EmailEndpoint settings(Map<String, Object> settings) {
212+
this.settings = new LinkedHashMap<>(settings);
203213
return this;
204214
}
205215

@@ -231,7 +241,17 @@ public SendEmailResponse send() {
231241
}
232242

233243
public List<SendMailResponse> sendBatch(List<SendMailRequest> payloads) {
234-
return client.post("/send/batch", payloads, new TypeReference<List<SendMailResponse>>() {});
244+
Map<String, String> requestHeaders = null;
245+
246+
if (idempotencyKey != null && !idempotencyKey.isEmpty()) {
247+
requestHeaders = Collections.singletonMap("Idempotency-Key", idempotencyKey);
248+
}
249+
250+
try {
251+
return client.post("/send/batch", payloads, new TypeReference<List<SendMailResponse>>() {}, requestHeaders);
252+
} finally {
253+
reset();
254+
}
235255
}
236256

237257
public String ping() {
@@ -289,8 +309,12 @@ private Map<String, Object> buildPayload() {
289309
payload.put("metadata", metadata);
290310
}
291311

292-
if (!tags.isEmpty()) {
293-
payload.put("tags", tags);
312+
if (tag != null) {
313+
payload.put("tag", tag);
314+
}
315+
316+
if (settings != null) {
317+
payload.put("settings", settings);
294318
}
295319

296320
return payload;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package co.lettermint.models.api;
2+
3+
public final class BuiltInTeamRole {
4+
public static final String OWNER = "owner";
5+
public static final String ADMIN = "admin";
6+
public static final String MEMBER = "member";
7+
8+
private BuiltInTeamRole() {}
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package co.lettermint.models.api;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.util.List;
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
public class CursorPaginator {
9+
@JsonProperty("data")
10+
public List<String> data;
11+
12+
@JsonProperty("path")
13+
public String path;
14+
15+
@JsonProperty("per_page")
16+
public Integer perPage;
17+
18+
@JsonProperty("next_cursor")
19+
public String nextCursor;
20+
21+
@JsonProperty("next_page_url")
22+
public String nextPageUrl;
23+
24+
@JsonProperty("prev_cursor")
25+
public String prevCursor;
26+
27+
@JsonProperty("prev_page_url")
28+
public String prevPageUrl;
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package co.lettermint.models.api;
2+
3+
public final class DkimMode {
4+
public static final String LEGACYTXT = "legacy_txt";
5+
public static final String MANAGEDCNAME = "managed_cname";
6+
7+
private DkimMode() {}
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package co.lettermint.models.api;
2+
3+
public final class DnsRecordPurpose {
4+
public static final String RETURNPATH = "return_path";
5+
public static final String DMARC = "dmarc";
6+
public static final String DKIMLEGACY = "dkim_legacy";
7+
public static final String DKIMPRIMARY = "dkim_primary";
8+
public static final String DKIMSECONDARY = "dkim_secondary";
9+
10+
private DnsRecordPurpose() {}
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package co.lettermint.models.api;
2+
3+
public final class DnsVerificationScope {
4+
public static final String REQUIRED = "required";
5+
public static final String RECOMMENDED = "recommended";
6+
public static final String MIGRATION = "migration";
7+
public static final String DEPRECATED = "deprecated";
8+
9+
private DnsVerificationScope() {}
10+
}

src/main/java/co/lettermint/models/api/DomainData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public class DomainData {
1313
@JsonProperty("domain")
1414
public String domain;
1515

16+
@JsonProperty("dkim_mode")
17+
public String dkimMode;
18+
19+
@JsonProperty("rotation_ready")
20+
public Boolean rotationReady;
21+
1622
@JsonProperty("status_changed_at")
1723
public String statusChangedAt;
1824

src/main/java/co/lettermint/models/api/DomainDnsRecordData.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DomainDnsRecordData {
99
public String id;
1010

1111
@JsonProperty("type")
12-
public RecordType type;
12+
public String type;
1313

1414
@JsonProperty("hostname")
1515
public String hostname;
@@ -21,7 +21,16 @@ public class DomainDnsRecordData {
2121
public String content;
2222

2323
@JsonProperty("status")
24-
public DnsRecordStatus status;
24+
public String status;
25+
26+
@JsonProperty("purpose")
27+
public String purpose;
28+
29+
@JsonProperty("verification_scope")
30+
public String verificationScope;
31+
32+
@JsonProperty("required_for_verification")
33+
public Boolean requiredForVerification;
2534

2635
@JsonProperty("verified_at")
2736
public String verifiedAt;

0 commit comments

Comments
 (0)