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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ All notable changes to this project are documented here. The format follows

### Added

- `designs()` (`DesignsResource`) for the create suite: `list`, `create`, `get`, `update`,
`delete`, `versions`, `restoreVersion`, `duplicate`, `export`, `bulk`, `posts`, `textToSlides`
and `fromPost`, with `DesignParams` and the `Design`, `DesignVersion`, `DesignSaved`,
`DesignDeleted`, `DesignExport`, `DesignPost` and `TextSlides` records. The design document is
a `Map<String, Object>` passed through unchanged. `textToSlides` also needs `ai`.
- `fonts()` (`FontsResource`): `list`, `upload` from a `Path`, bytes or a `FileInput`, and
`delete`, with `FontList`, `LibraryFont` and `UploadedFont`.
- `videoEdits()` (`VideoEditsResource`): `ops`, `list`, `create` and `get`, with `VideoEdit`,
`VideoEditOp` and `VideoEditOperation`. A step that uses AI also needs `ai`.
- `media().generateAltText(mediaId)` (`AltText`) writes and saves alt text for one image. Needs
`ai`.
- `posts().validateImport` and `posts().commitImport` gain overloads taking a `List<String>`
of account ids or platform names, sent comma-separated and applied to every CSV row whose
own `accounts` cell is empty.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ calls `ApiClient.unwrap(...)` and `convert(...)`/`convertList(...)` into a recor
- `FoPost` instances are immutable and safe to share across threads.

**Resources wired today:** `posts`, `accounts` (with `accounts().communities()`), `workspaces`,
`labels`, `webhooks`, `analytics`, `automations`, `media`, `ai`, `inbox`, `contacts`, `broadcasts`, `sequences`, `ads`, `googleAds`, `validate`. This is
`labels`, `webhooks`, `analytics`, `automations`, `media`, `ai`, `inbox`, `contacts`, `broadcasts`, `sequences`, `ads`, `googleAds`, `validate`, `designs`, `fonts`, `videoEdits`. This is
the most complete of the FoPost SDKs — do not narrow it. `FoPost.request(...)` is the escape hatch for
anything unwrapped.

Expand Down
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ long failed = client.posts().stream(PostListParams.create().workspaceId(workspac
| `webhooks()` | `list`, `create`, `update`, `delete`, `test`, `deliveries`, `delivery`, `redeliver`, `verify` |
| `analytics()` | `overview`, `timeSeries`, `topPosts`, `labels`, `postsTable`, `postingStreak`, `demographics`, `collect`, `decay`, `frequency`, `timeline`, `changes`, `collectPost`, `nativePosts`, `inbox` |
| `automations()` | `list`, `get`, `create`, `update`, `delete`, `toggle`, `runs`, `run`, `trigger`, `stats`, `versions`, `version`, `restoreVersion` |
| `media()` | `list`, `limits`, `upload`, `presign`, `complete`, `uploadDirect`, `delete` |
| `media()` | `list`, `limits`, `upload`, `presign`, `complete`, `uploadDirect`, `generateAltText`, `delete` |
| `ai()` | `credits`, `generateCaption`, `rewrite`, `repurposeUrl` |
| `inbox()` | `list`, `threads`, `conversations`, `unreadCount`, `accounts`, `platforms`, `markThreadRead`, `markConversationRead`, `refresh`, `update`, `editComment`, `reply`, `hide`, `unhide`, `delete`, `like`, `unlike`, `repost`, `unrepost`, `bookmark`, `unbookmark`, `vote`, `pin`, `unpin`, `react`, `startConversation`, `setTyping`, `passThreadControl`, `takeThreadControl`, `handover`, `listApprovals`, `approveReply`, `rejectReply` |
| `contacts()` | `list`, `get`, `create`, `update`, `delete`, `conversations`, `importCsv`, `listFields`, `createField`, `updateField`, `updateFieldOptions`, `deleteField`, `conversationAnalytics` |
Expand All @@ -121,6 +121,9 @@ long failed = client.posts().stream(PostListParams.create().workspaceId(workspac
| `googleBusiness()` | `getLocation`, `updateLocation`, `getAttributes`, `updateAttributes`, `getMenus`, `replaceMenus`, `getServices`, `replaceServices`, `listMedia`, `addMedia`, `deleteMedia`, `listPlaceActions`, `createPlaceAction`, `updatePlaceAction`, `deletePlaceAction`, `getVerificationOptions`, `startVerification`, `completeVerification`, `getPerformance`, `getSearchKeywords`, `assign` |
| `blogs()` | `listBlogs`, `listArticles`, `getArticle`, `createArticle`, `updateArticle`, `deleteArticle`, `listProducts`, `updateProduct` |
| `validate()` | `post`, `length`, `media`, `subreddit` |
| `designs()` | `list`, `create`, `get`, `update`, `delete`, `versions`, `restoreVersion`, `duplicate`, `export`, `bulk`, `posts`, `textToSlides`, `fromPost` |
| `fonts()` | `list`, `upload`, `delete` |
| `videoEdits()` | `ops`, `list`, `create`, `get` |
| `queue()` | `listSlots`, `createSlot`, `updateSlot`, `deleteSlot`, `next`, `preview` |
| `connectSessions()` | `create`, `get` |
| `logs()` | `list` |
Expand Down Expand Up @@ -248,6 +251,53 @@ files under `files` (at most five). Otherwise it uploads each file directly, the
JSON request with the results attached as media items. An update without new content reads the
post first and appends to what its first block already holds.

## Designs and video

`designs()` holds the create suite's designs. The design document is a plain
`Map<String, Object>` sent and returned unchanged, keys and nulls included:

```java
Design design = client.designs().create(
DesignParams.Create.of(workspace.id(), "post", document).name("Launch card"));

DesignSaved saved = client.designs().update(design.id(),
DesignParams.Update.create().document(edited).createVersion(true));

// Each file lands in the media library, ready to attach to a post.
DesignExport export = client.designs().export(design.id(), DesignParams.Export.of("png"));
String mediaId = export.files().get(0).mediaId();

// One design per row, filling text and image layers by layer id or name.
List<Design> cards = client.designs().bulk(design.id(),
List.of(Map.of("headline", "Spring sale"), Map.of("headline", "Summer sale")), "headline");
```

`fonts()` lists the font library and the workspace's uploaded fonts, and uploads one TTF, OTF,
WOFF or WOFF2 file of up to 5 MB:

```java
UploadedFont font = client.fonts().upload(workspace.id(),
FileInput.of(Path.of("BrandSans-Bold.woff2")), "Brand Sans", 700, "normal");
```

`videoEdits()` runs steps such as `trim`, `subtitles` or `reframe` over a library video as a
background job. `ops()` lists every step and whether it can run; a job comes back `queued`, so
read it again with `get` until it is `succeeded` or `failed`:

```java
VideoEdit job = client.videoEdits().create(mediaId, List.of(
VideoEditOperation.of("trim", Map.of("startSec", 2, "endSec", 12)),
VideoEditOperation.of("reframe", Map.of("aspect", "9:16"))));

job = client.videoEdits().get(job.id());
```

`media().generateAltText(mediaId)` writes alt text for one image and saves it on the item.

All of these need the `posts` scope and create access on the workspace. `textToSlides`,
`generateAltText` and any video step whose `usesAi()` is true spend AI, so they also need `ai`; an
empty balance answers `402`.

## Webhooks

The signing secret is returned by the create call and never shown again — store it then.
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/fopost/sdk/FoPost.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.fopost.sdk.resource.BroadcastsResource;
import com.fopost.sdk.resource.ConnectSessionsResource;
import com.fopost.sdk.resource.ContactsResource;
import com.fopost.sdk.resource.DesignsResource;
import com.fopost.sdk.resource.FontsResource;
import com.fopost.sdk.resource.BlogsResource;
import com.fopost.sdk.resource.InboxResource;
import com.fopost.sdk.resource.KnowledgeResource;
Expand All @@ -28,6 +30,7 @@
import com.fopost.sdk.resource.QueueResource;
import com.fopost.sdk.resource.SequencesResource;
import com.fopost.sdk.resource.ValidateResource;
import com.fopost.sdk.resource.VideoEditsResource;
import com.fopost.sdk.resource.WebhooksResource;
import com.fopost.sdk.resource.WhatsappResource;
import com.fopost.sdk.resource.WorkspacesResource;
Expand Down Expand Up @@ -80,6 +83,9 @@ public final class FoPost {
private final AnalyticsResource analytics;
private final AutomationsResource automations;
private final MediaResource media;
private final DesignsResource designs;
private final FontsResource fonts;
private final VideoEditsResource videoEdits;
private final AiResource ai;
private final ContactsResource contacts;
private final BroadcastsResource broadcasts;
Expand Down Expand Up @@ -111,6 +117,9 @@ private FoPost(ApiClient http) {
this.analytics = new AnalyticsResource(http);
this.automations = new AutomationsResource(http);
this.media = new MediaResource(http);
this.designs = new DesignsResource(http);
this.fonts = new FontsResource(http);
this.videoEdits = new VideoEditsResource(http);
this.ai = new AiResource(http);
this.whatsapp = new WhatsappResource(http);
this.inbox = new InboxResource(http);
Expand Down Expand Up @@ -192,6 +201,21 @@ public MediaResource media() {
return media;
}

/** Designs from the create suite: versions, exports, bulk and text-to-slides. */
public DesignsResource designs() {
return designs;
}

/** The font library and the workspace's uploaded fonts. */
public FontsResource fonts() {
return fonts;
}

/** Video edit jobs over videos in the media library. */
public VideoEditsResource videoEdits() {
return videoEdits;
}

public ActivityResource activity() {
return activity;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/fopost/sdk/internal/Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyName;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
Expand All @@ -21,6 +22,13 @@ private Json() {}

public static final ObjectMapper MAPPER = create();

private static final ObjectMapper VERBATIM = new ObjectMapper().registerModule(new JavaTimeModule());

/** A caller-shaped payload as a tree, keys and nulls exactly as given. */
public static JsonNode verbatim(Object value) {
return VERBATIM.valueToTree(value);
}

private static ObjectMapper create() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/fopost/sdk/model/AltText.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fopost.sdk.model;

import java.util.List;

/**
* Alt text generated for an image, now saved on the media item.
*
* @param altTextSource {@code ai} for generated text
* @param tags subject tags for searching the library
*/
public record AltText(String altText, String altTextSource, List<String> tags) {}
26 changes: 26 additions & 0 deletions src/main/java/com/fopost/sdk/model/Design.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.fopost.sdk.model;

import java.time.Instant;
import java.util.Map;

/**
* A design from the create suite: a story, post, carousel, thumbnail, card or collage.
*
* @param kind {@code story}, {@code post}, {@code carousel}, {@code thumbnail}, {@code card} or
* {@code collage}
* @param document the design document as the API stores it (pages, layers, size), passed through
* unchanged; null on a list, which leaves it out
* @param thumbnailMediaId the media library item holding the first-page preview, once rendered
* @param thumbnailUrl a membership-checked URL for that preview
*/
public record Design(
String id,
String name,
String kind,
Integer width,
Integer height,
Map<String, Object> document,
String thumbnailMediaId,
String thumbnailUrl,
Instant createdAt,
Instant updatedAt) {}
3 changes: 3 additions & 0 deletions src/main/java/com/fopost/sdk/model/DesignDeleted.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.fopost.sdk.model;

public record DesignDeleted(String id, boolean deleted) {}
16 changes: 16 additions & 0 deletions src/main/java/com/fopost/sdk/model/DesignExport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.fopost.sdk.model;

import java.util.List;

/**
* The files an export rendered, each already in the media library.
*
* @param format {@code png}, {@code jpg}, {@code pdf}, {@code mp4} or {@code gif}
*/
public record DesignExport(String format, List<File> files) {

/**
* @param pageIndex the page this file shows; null for a file covering the whole design
*/
public record File(String mediaId, Integer pageIndex, String mimeType, String previewUrl) {}
}
22 changes: 22 additions & 0 deletions src/main/java/com/fopost/sdk/model/DesignPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.fopost.sdk.model;

import java.time.Instant;
import java.util.List;

/**
* A post that uses an export of a design.
*
* @param text the start of the post's first block, at most 280 characters
* @param engagement summed across the post's networks; null until something was measured
* @param views summed the same way
*/
public record DesignPost(
String id,
String status,
String title,
String text,
Instant scheduleAt,
Instant publishedAt,
List<String> platforms,
Long engagement,
Long views) {}
8 changes: 8 additions & 0 deletions src/main/java/com/fopost/sdk/model/DesignSaved.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.fopost.sdk.model;

/**
* The result of an update or a version restore.
*
* @param version the version row this save wrote, or null when it did not write one
*/
public record DesignSaved(Design design, DesignVersion version) {}
11 changes: 11 additions & 0 deletions src/main/java/com/fopost/sdk/model/DesignVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fopost.sdk.model;

import java.time.Instant;
import java.util.Map;

/**
* A saved version of a design.
*
* @param document set only when the versions were listed with their documents
*/
public record DesignVersion(String id, Integer version, Map<String, Object> document, Instant createdAt) {}
11 changes: 11 additions & 0 deletions src/main/java/com/fopost/sdk/model/FontList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fopost.sdk.model;

import java.util.List;

/**
* The fonts a design can use.
*
* @param library the fonts FoPost ships
* @param uploaded the workspace's own fonts; empty when no workspace was named
*/
public record FontList(List<LibraryFont> library, List<UploadedFont> uploaded) {}
17 changes: 17 additions & 0 deletions src/main/java/com/fopost/sdk/model/LibraryFont.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.fopost.sdk.model;

import java.util.List;

/**
* A font family FoPost ships.
*
* @param category {@code sans}, {@code serif}, {@code display}, {@code handwriting} or
* {@code monospace}
* @param scripts {@code latin}, {@code arabic}
*/
public record LibraryFont(
String slug, String family, String category, List<String> scripts, List<String> weights, List<File> files) {

/** One font file of the family, covering one subset. */
public record File(String path, String subset, String weight, String style, String unicodeRange) {}
}
20 changes: 20 additions & 0 deletions src/main/java/com/fopost/sdk/model/TextSlides.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.fopost.sdk.model;

import java.util.List;

/**
* Text split into carousel slides: a cover, the slides, a closing call to action, and the brand
* the slides should wear.
*/
public record TextSlides(Cover cover, List<Slide> slides, Cta cta, Brand brand) {

public record Cover(String title, String subtitle) {}

public record Slide(String heading, String body) {}

public record Cta(String heading, String body) {}

public record Brand(List<String> colors, Fonts fonts, String logoMediaId) {}

public record Fonts(String heading, String body) {}
}
13 changes: 13 additions & 0 deletions src/main/java/com/fopost/sdk/model/UploadedFont.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.fopost.sdk.model;

import java.time.Instant;

/**
* A font uploaded into a workspace.
*
* @param style {@code normal} or {@code italic}
* @param format the stored file format, such as {@code woff2} or {@code ttf}
* @param fileUrl where the file is served, after a membership check
*/
public record UploadedFont(
String id, String family, String style, Integer weight, String format, String fileUrl, Instant createdAt) {}
35 changes: 35 additions & 0 deletions src/main/java/com/fopost/sdk/model/VideoEdit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.fopost.sdk.model;

import java.time.Instant;
import java.util.List;
import java.util.Map;

/**
* A video edit job: the source video, the steps, and what they produced.
*
* @param status {@code queued}, {@code running}, {@code succeeded} or {@code failed}
* @param progress 0 to 100
* @param resultMediaId the media library item holding the edited video, once it succeeded
* @param extraOutputs further files a step produced, such as clips or a subtitle file
* @param result step-specific output, such as a transcript; null until there is one
* @param error why it failed, in plain words
*/
public record VideoEdit(
String id,
String status,
Integer progress,
String sourceMediaId,
List<VideoEditOperation> operations,
String resultMediaId,
ResultMedia resultMedia,
List<ExtraOutput> extraOutputs,
Map<String, Object> result,
String error,
Instant createdAt,
Instant updatedAt,
Instant completedAt) {

public record ResultMedia(String id, String previewUrl, String mimeType) {}

public record ExtraOutput(String mediaId, String label, String mime, String previewUrl) {}
}
9 changes: 9 additions & 0 deletions src/main/java/com/fopost/sdk/model/VideoEditOp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.fopost.sdk.model;

/**
* A video edit step the API knows.
*
* @param available false when this deployment cannot run it right now
* @param usesAi true when it spends AI, so an API key also needs the {@code ai} scope
*/
public record VideoEditOp(String name, boolean available, boolean usesAi) {}
Loading
Loading