Fivexer

Java

The Java SDK (com.fivexer:fivexer-sdk) targets Java 11 bytecode and works on the JVM and Android.

Install

Maven:

xml
<dependency>
  <groupId>com.fivexer</groupId>
  <artifactId>fivexer-sdk</artifactId>
  <version>0.3.0</version>
</dependency>

Gradle:

groovy
implementation 'com.fivexer:fivexer-sdk:0.3.0'

Quickstart

java
import io.fivexer.sdk.Fivexer;
import io.fivexer.sdk.model.*;
import java.util.List;

Fivexer client = new Fivexer("https://api.fivexer.com", "sk_test_...");
client.workers().upsert(new UpsertWorker("agent_1").tags(List.of("english", "billing")));
Task task = client.tasks().create(new CreateTask(List.of("english", "billing")).priority(90));
System.out.println(task.getId() + " " + task.getStatus());

Async

The sync Fivexer blocks on CompletableFuture internally. For async callers, use the async variants directly or wrap calls:

java
CompletableFuture<Task> future = CompletableFuture.supplyAsync(() -> client.tasks().create(input));

Worker portal

java
import io.fivexer.sdk.FivexerWorker;
import io.fivexer.sdk.model.WorkerLogin;

try (FivexerWorker worker = new FivexerWorker("https://api.fivexer.com")) {
    worker.login(new WorkerLogin("ws_1", "agent_1", "4821"));
    worker.accept(worker.queue().getTaskIds().get(0));
}

Supervisor

java
import io.fivexer.sdk.FivexerSupervisor;
import io.fivexer.sdk.model.AcceptSupervisorInvite;
import io.fivexer.sdk.model.SupervisorOverview;

try (FivexerSupervisor sv = new FivexerSupervisor("https://api.fivexer.com")) {
    sv.acceptInvite(new AcceptSupervisorInvite(tokenFromLink));

    SupervisorOverview board = sv.overview();
    sv.assign(board.getParked().get(0).getId(), board.getCrew().get(0).getWorkerId());
}

Both session clients are AutoCloseable. Supervisor actions are flat methods (unpark, setPriority, assign, setAvailability) — see the supervisor plane.

Errors and quotas

java
try {
    client.tasks().create(new CreateTask(List.of("english")));
} catch (FivexerApiException e) {
    System.out.println(e.getStatusCode() + " " + e.getCode());
    System.out.println(e.getRetryAfterSeconds());
    System.out.println(client.getQuota().getTaskRateRemaining());
}

Webhooks

java
import io.fivexer.sdk.webhook.Webhook;
import io.fivexer.sdk.webhook.WebhookEvent;

WebhookEvent event = Webhook.constructEvent(rawBodyBytes, signatureHeader, "whsec_...");

Build & test

bash
./gradlew check

Was this page helpful?