From 586bba13bb8b4cc8f96fa2855912c11aa69fcabc Mon Sep 17 00:00:00 2001 From: Ali Hesari Date: Tue, 3 Nov 2026 11:11:38 +0100 Subject: [PATCH 1/2] feat(inbox): filter lists by status, since and several accounts --- CHANGELOG.md | 5 +++ README.md | 16 +++++-- .../com/fopost/sdk/param/InboxListParams.java | 45 +++++++++++++------ .../fopost/sdk/param/InboxThreadParams.java | 39 +++++++++++----- .../fopost/sdk/resource/InboxResource.java | 6 +-- src/test/java/com/fopost/sdk/InboxTest.java | 26 ++++++++++- 6 files changed, 103 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b38e9e..b5c904b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ All notable changes to this project are documented here. The format follows `CustomConversionRule`. - `UploadConversionsParams` events accept `eventId`, `actionSource`, `sourceUrl`, `externalId`, `clientIpAddress`, `clientUserAgent`, `clickId`, `browserId` and `contentIds` through `with`. +- `InboxListParams` and `InboxThreadParams` take `status` (`unanswered`, `replied`, `resolved`) + and `since`, and `accountId` takes one or more ids (or `accountIds(List)`), sent comma-separated. ### Changed @@ -34,6 +36,9 @@ All notable changes to this project are documented here. The format follows ### Removed +- `InboxListParams` and `InboxThreadParams` drop `state`, `platform` and `q`, and `sort` no longer + takes `unanswered`; the inbox list endpoints no longer read them. Filter by `status` and + `accountId` instead. - `blog()` (`BlogResource`) and the retired `/v1/blog/*` endpoints it wrapped (settings, website secret and test, destinations, keywords, articles), with `BlogParams`, every `Blog*` model and constant class, and `WebhookEvents.ARTICLE_PUBLISHED`. Articles are ordinary posts diff --git a/README.md b/README.md index 9ad6eb8..4431785 100644 --- a/README.md +++ b/README.md @@ -300,10 +300,14 @@ Comments, mentions and direct messages across the connected accounts, with the s (`unread`, `read`, `resolved`, `snoozed`). Lists are pages with `page`, `perPage` and `total`. ```java -InboxPage unread = client.inbox().list( - InboxListParams.create().workspaceId(workspace.id()).state("unread")); - -for (InboxItem item : unread) { +InboxPage unanswered = client.inbox().list( + InboxListParams.create() + .workspaceId(workspace.id()) + .accountId(instagramId, facebookId) + .status("unanswered") + .since(Instant.parse("2026-09-01T00:00:00Z"))); + +for (InboxItem item : unanswered) { if (Boolean.TRUE.equals(item.canReply())) { client.inbox().reply(item.id(), "Thanks for asking, sent you a DM."); } @@ -313,6 +317,10 @@ client.inbox().markThreadRead(workspace.id(), accountId, postExternalId); client.inbox().update(itemId, "snoozed", Instant.parse("2026-09-02T09:00:00Z")); ``` +`status` is `unanswered`, `replied` or `resolved` (a reply also resolves an item), `since` keeps +items the platform dates at or after an instant, `accountId` takes one or more accounts, and +`sort` is `newest` or `oldest`. The same filters apply to `threads` and `conversations`. + `threads` groups comments per platform post (`kind("mentions")` for posts the account was tagged in) and `conversations` per DM thread. `listApprovals` returns replies an automation or the agent drafted that a person still has to send; `approveReply` sends the draft (or your edited text) and diff --git a/src/main/java/com/fopost/sdk/param/InboxListParams.java b/src/main/java/com/fopost/sdk/param/InboxListParams.java index 0d931b0..79efc6c 100644 --- a/src/main/java/com/fopost/sdk/param/InboxListParams.java +++ b/src/main/java/com/fopost/sdk/param/InboxListParams.java @@ -1,6 +1,10 @@ package com.fopost.sdk.param; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** Filters for listing inbox items. Every field is optional. */ @@ -18,25 +22,43 @@ public InboxListParams workspaceId(String workspaceId) { return this; } - /** {@code comment}, {@code mention} or {@code dm}. */ + /** {@code comment}, {@code mention}, {@code review} or {@code dm}. */ public InboxListParams type(String type) { query.put("type", type); return this; } - /** {@code unread}, {@code read}, {@code resolved} or {@code snoozed}. */ - public InboxListParams state(String state) { - query.put("state", state); + /** One or more connected accounts; sent comma-separated. */ + public InboxListParams accountId(String... accountIds) { + return accountIds(accountIds == null ? null : Arrays.asList(accountIds)); + } + + public InboxListParams accountIds(List accountIds) { + List ids = new ArrayList<>(); + if (accountIds != null) { + for (String id : accountIds) { + if (id != null && !id.isEmpty()) { + ids.add(id); + } + } + } + if (ids.isEmpty()) { + query.remove("account_id"); + } else { + query.put("account_id", String.join(",", ids)); + } return this; } - public InboxListParams platform(String platform) { - query.put("platform", platform); + /** {@code unanswered}, {@code replied} or {@code resolved}. A reply also resolves an item. */ + public InboxListParams status(String status) { + query.put("status", status); return this; } - public InboxListParams accountId(String accountId) { - query.put("account_id", accountId); + /** Only items the platform dates at or after this instant. */ + public InboxListParams since(Instant since) { + Params.put(query, "since", Params.iso(since)); return this; } @@ -64,12 +86,7 @@ public InboxListParams direction(String direction) { return this; } - public InboxListParams q(String q) { - query.put("q", q); - return this; - } - - /** {@code newest}, {@code oldest} or {@code unanswered}. */ + /** {@code newest} or {@code oldest}. */ public InboxListParams sort(String sort) { query.put("sort", sort); return this; diff --git a/src/main/java/com/fopost/sdk/param/InboxThreadParams.java b/src/main/java/com/fopost/sdk/param/InboxThreadParams.java index b5ab817..e785299 100644 --- a/src/main/java/com/fopost/sdk/param/InboxThreadParams.java +++ b/src/main/java/com/fopost/sdk/param/InboxThreadParams.java @@ -1,6 +1,10 @@ package com.fopost.sdk.param; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** Filters for listing comment threads and DM conversations. Every field is optional. */ @@ -26,28 +30,41 @@ public InboxThreadParams kind(String kind) { return this; } - public InboxThreadParams platform(String platform) { - query.put("platform", platform); - return this; + /** One or more connected accounts; sent comma-separated. */ + public InboxThreadParams accountId(String... accountIds) { + return accountIds(accountIds == null ? null : Arrays.asList(accountIds)); } - public InboxThreadParams accountId(String accountId) { - query.put("account_id", accountId); + public InboxThreadParams accountIds(List accountIds) { + List ids = new ArrayList<>(); + if (accountIds != null) { + for (String id : accountIds) { + if (id != null && !id.isEmpty()) { + ids.add(id); + } + } + } + if (ids.isEmpty()) { + query.remove("account_id"); + } else { + query.put("account_id", String.join(",", ids)); + } return this; } - /** {@code unread}, {@code read}, {@code resolved} or {@code snoozed}. */ - public InboxThreadParams state(String state) { - query.put("state", state); + /** {@code unanswered}, {@code replied} or {@code resolved}. A reply also resolves an item. */ + public InboxThreadParams status(String status) { + query.put("status", status); return this; } - public InboxThreadParams q(String q) { - query.put("q", q); + /** Only items the platform dates at or after this instant. */ + public InboxThreadParams since(Instant since) { + Params.put(query, "since", Params.iso(since)); return this; } - /** {@code newest}, {@code oldest} or {@code unanswered}. */ + /** {@code newest} or {@code oldest}. */ public InboxThreadParams sort(String sort) { query.put("sort", sort); return this; diff --git a/src/main/java/com/fopost/sdk/resource/InboxResource.java b/src/main/java/com/fopost/sdk/resource/InboxResource.java index f3e28a8..602f8c3 100644 --- a/src/main/java/com/fopost/sdk/resource/InboxResource.java +++ b/src/main/java/com/fopost/sdk/resource/InboxResource.java @@ -30,9 +30,9 @@ * Comments, mentions, reviews and direct messages on the connected accounts. * *
{@code
- * InboxPage unread = client.inbox().list(
- *         InboxListParams.create().workspaceId(workspaceId).state("unread"));
- * for (InboxItem item : unread) {
+ * InboxPage unanswered = client.inbox().list(
+ *         InboxListParams.create().workspaceId(workspaceId).status("unanswered"));
+ * for (InboxItem item : unanswered) {
  *     if (Boolean.TRUE.equals(item.canReply())) {
  *         client.inbox().reply(item.id(), "Thanks for asking, sent you a DM.");
  *     }
diff --git a/src/test/java/com/fopost/sdk/InboxTest.java b/src/test/java/com/fopost/sdk/InboxTest.java
index d4dd265..88b67f1 100644
--- a/src/test/java/com/fopost/sdk/InboxTest.java
+++ b/src/test/java/com/fopost/sdk/InboxTest.java
@@ -13,6 +13,7 @@
 import com.fopost.sdk.model.InboxReplyResult;
 import com.fopost.sdk.param.InboxListParams;
 import com.fopost.sdk.param.InboxReplyParams;
+import com.fopost.sdk.param.InboxThreadParams;
 import com.fopost.sdk.param.StartConversationParams;
 import java.time.Instant;
 import java.util.List;
@@ -36,14 +37,17 @@ void listEncodesSnakeCaseFiltersAndReadsThePage() {
                 .inbox()
                 .list(InboxListParams.create()
                         .workspaceId("w1")
-                        .state("unread")
+                        .accountId("a1", "a2")
+                        .status("unanswered")
+                        .since(Instant.parse("2026-09-01T00:00:00Z"))
                         .postExternalId("ext-9")
                         .page(2)
                         .perPage(10));
 
         assertEquals("GET", transport.last().method());
         assertEquals(
-                "https://api.fopost.test/v1/inbox?workspace_id=w1&state=unread&post_external_id=ext-9&page=2&per_page=10",
+                "https://api.fopost.test/v1/inbox?workspace_id=w1&account_id=a1%2Ca2&status=unanswered"
+                        + "&since=2026-09-01T00%3A00%3A00Z&post_external_id=ext-9&page=2&per_page=10",
                 transport.last().url());
         assertEquals(1, page.size());
         InboxItem item = page.data().get(0);
@@ -55,6 +59,24 @@ void listEncodesSnakeCaseFiltersAndReadsThePage() {
         assertEquals(2, page.meta().page());
     }
 
+    @Test
+    void threadsSendTheStatusAndSortFilters() {
+        FakeTransport transport = new FakeTransport()
+                .enqueue(200, "{\"data\":[],\"meta\":{\"page\":1,\"perPage\":25,\"total\":0}}");
+
+        TestSupport.client(transport)
+                .inbox()
+                .threads(InboxThreadParams.create()
+                        .kind("reviews")
+                        .accountIds(List.of("a1"))
+                        .status("replied")
+                        .sort("oldest"));
+
+        assertEquals(
+                "https://api.fopost.test/v1/inbox/posts?kind=reviews&account_id=a1&status=replied&sort=oldest",
+                transport.last().url());
+    }
+
     @Test
     void replyPostsTheTextAndUnwrapsTheResult() {
         FakeTransport transport = new FakeTransport()

From 94582231a65d9b8142b41b4d30d6e473d1cd73f2 Mon Sep 17 00:00:00 2001
From: Ali Hesari 
Date: Tue, 3 Nov 2026 11:11:38 +0100
Subject: [PATCH 2/2] feat(inbox): add resolve for bulk resolving unanswered
 items

---
 CHANGELOG.md                                  |  3 +
 README.md                                     |  4 ++
 .../fopost/sdk/param/InboxResolveParams.java  | 69 +++++++++++++++++++
 .../fopost/sdk/resource/InboxResource.java    |  9 +++
 src/test/java/com/fopost/sdk/InboxTest.java   | 20 ++++++
 5 files changed, 105 insertions(+)
 create mode 100644 src/main/java/com/fopost/sdk/param/InboxResolveParams.java

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5c904b..8108823 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,9 @@ All notable changes to this project are documented here. The format follows
   `CustomConversionRule`.
 - `UploadConversionsParams` events accept `eventId`, `actionSource`, `sourceUrl`, `externalId`,
   `clientIpAddress`, `clientUserAgent`, `clickId`, `browserId` and `contentIds` through `with`.
+- `inbox().resolve(InboxResolveParams)` resolves every unanswered item of one type in bulk,
+  optionally only on some accounts (`accountId`) or only items dated `before` an instant, and
+  returns how many changed. Nothing reaches a platform. Needs `inbox`.
 - `InboxListParams` and `InboxThreadParams` take `status` (`unanswered`, `replied`, `resolved`)
   and `since`, and `accountId` takes one or more ids (or `accountIds(List)`), sent comma-separated.
 
diff --git a/README.md b/README.md
index 4431785..622f5c0 100644
--- a/README.md
+++ b/README.md
@@ -315,6 +315,10 @@ for (InboxItem item : unanswered) {
 
 client.inbox().markThreadRead(workspace.id(), accountId, postExternalId);
 client.inbox().update(itemId, "snoozed", Instant.parse("2026-09-02T09:00:00Z"));
+
+// Resolve every unanswered comment older than a week, without replying.
+int resolved = client.inbox().resolve(InboxResolveParams.of(workspace.id(), "comment")
+        .before(Instant.now().minus(Duration.ofDays(7))));
 ```
 
 `status` is `unanswered`, `replied` or `resolved` (a reply also resolves an item), `since` keeps
diff --git a/src/main/java/com/fopost/sdk/param/InboxResolveParams.java b/src/main/java/com/fopost/sdk/param/InboxResolveParams.java
new file mode 100644
index 0000000..49e7871
--- /dev/null
+++ b/src/main/java/com/fopost/sdk/param/InboxResolveParams.java
@@ -0,0 +1,69 @@
+package com.fopost.sdk.param;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * What to resolve in bulk: every unanswered item of one type in a workspace, optionally only on
+ * some accounts or only items dated before an instant.
+ *
+ * 
{@code
+ * int resolved = client.inbox().resolve(InboxResolveParams.of(workspaceId, "comment")
+ *         .before(Instant.now().minus(Duration.ofDays(7))));
+ * }
+ */ +public final class InboxResolveParams { + + private final String workspaceId; + private final String type; + private final List accountIds = new ArrayList<>(); + private Instant before; + + private InboxResolveParams(String workspaceId, String type) { + this.workspaceId = Objects.requireNonNull(workspaceId, "workspaceId"); + this.type = Objects.requireNonNull(type, "type"); + } + + /** {@code type} is {@code comment}, {@code mention}, {@code review} or {@code dm}. */ + public static InboxResolveParams of(String workspaceId, String type) { + return new InboxResolveParams(workspaceId, type); + } + + /** Only these connected accounts. */ + public InboxResolveParams accountId(String... accountIds) { + return accountIds(accountIds == null ? null : Arrays.asList(accountIds)); + } + + public InboxResolveParams accountIds(List accountIds) { + if (accountIds != null) { + for (String id : accountIds) { + if (id != null && !id.isEmpty()) { + this.accountIds.add(id); + } + } + } + return this; + } + + /** Only items the platform dates before this instant. */ + public InboxResolveParams before(Instant before) { + this.before = before; + return this; + } + + public Map toMap() { + Map body = new LinkedHashMap<>(); + body.put("workspace_id", workspaceId); + body.put("type", type); + if (!accountIds.isEmpty()) { + body.put("account_id", new ArrayList<>(accountIds)); + } + Params.put(body, "before", Params.iso(before)); + return body; + } +} diff --git a/src/main/java/com/fopost/sdk/resource/InboxResource.java b/src/main/java/com/fopost/sdk/resource/InboxResource.java index 602f8c3..95c0ed4 100644 --- a/src/main/java/com/fopost/sdk/resource/InboxResource.java +++ b/src/main/java/com/fopost/sdk/resource/InboxResource.java @@ -19,6 +19,7 @@ import com.fopost.sdk.model.InboxThread; import com.fopost.sdk.param.InboxListParams; import com.fopost.sdk.param.InboxReplyParams; +import com.fopost.sdk.param.InboxResolveParams; import com.fopost.sdk.param.InboxThreadParams; import com.fopost.sdk.param.StartConversationParams; import java.time.Instant; @@ -138,6 +139,14 @@ public InboxRefreshResult refresh(String workspaceId) { return http.convert(ApiClient.unwrap(http.post("/v1/inbox/refresh", body)), InboxRefreshResult.class); } + /** + * Resolve every unanswered item of one type in bulk. Nothing reaches a platform. Returns how + * many items changed. + */ + public int resolve(InboxResolveParams params) { + return ApiClient.unwrap(http.post("/v1/inbox/resolve", params.toMap())).path("resolved").asInt(0); + } + /** {@code state} is unread, read or resolved. Snoozing needs {@link #update(String, String, Instant)}. */ public InboxItem update(String itemId, String state) { return update(itemId, state, null); diff --git a/src/test/java/com/fopost/sdk/InboxTest.java b/src/test/java/com/fopost/sdk/InboxTest.java index 88b67f1..40f2123 100644 --- a/src/test/java/com/fopost/sdk/InboxTest.java +++ b/src/test/java/com/fopost/sdk/InboxTest.java @@ -13,6 +13,7 @@ import com.fopost.sdk.model.InboxReplyResult; import com.fopost.sdk.param.InboxListParams; import com.fopost.sdk.param.InboxReplyParams; +import com.fopost.sdk.param.InboxResolveParams; import com.fopost.sdk.param.InboxThreadParams; import com.fopost.sdk.param.StartConversationParams; import java.time.Instant; @@ -77,6 +78,25 @@ void threadsSendTheStatusAndSortFilters() { transport.last().url()); } + @Test + void resolvePostsTheTypeAccountsAndCutoff() { + FakeTransport transport = new FakeTransport().enqueue(200, "{\"data\":{\"resolved\":4}}"); + + int resolved = TestSupport.client(transport) + .inbox() + .resolve(InboxResolveParams.of("w1", "comment") + .accountId("a1", "a2") + .before(Instant.parse("2026-09-01T00:00:00Z"))); + + assertEquals("POST", transport.last().method()); + assertEquals("https://api.fopost.test/v1/inbox/resolve", transport.last().url()); + assertEquals( + "{\"workspace_id\":\"w1\",\"type\":\"comment\",\"account_id\":[\"a1\",\"a2\"]," + + "\"before\":\"2026-09-01T00:00:00Z\"}", + transport.lastBody()); + assertEquals(4, resolved); + } + @Test void replyPostsTheTextAndUnwrapsTheResult() { FakeTransport transport = new FakeTransport()