Skip to content

Examples

Christian KASSE edited this page Apr 2, 2026 · 1 revision

Examples

Available Examples

The examples/ directory contains ready-to-run example files:

Example File Description
Basic Usage BasicUsageExample.java Client initialization, CRUD operations across modules
Spring Boot SpringBootExample.java Auto-configuration, injection, service layer usage

Quick Examples

Initialize the Client

Essabu essabu = Essabu.builder()
    .apiKey("ess_live_xxxxxxxxxxxx")
    .tenantId("your-tenant-uuid")
    .build();

HR: Manage Employees

// Create
Map employee = essabu.hr().employees().create(Map.of(
    "firstName", "John", "lastName", "Doe", "email", "john@company.com"
));

// List with pagination
var page = essabu.hr().employees().list(companyId,
    PageRequest.builder().page(0).size(20).sort("lastName,asc").build()
);

// Get leave balance
Map balance = essabu.hr().employees().getLeaveBalance(employeeId);

Accounting: Invoice Workflow

// Create invoice
Map invoice = essabu.accounting().invoices().create(Map.of(
    "customerId", customerId,
    "items", List.of(Map.of("description", "Consulting", "amount", 1500.00))
));

// Finalize and send
essabu.accounting().invoices().finalize(invoiceId);
essabu.accounting().invoices().sendByEmail(invoiceId, Map.of("to", "client@example.com"));

// Download PDF
byte[] pdf = essabu.accounting().invoices().downloadPdf(invoiceId);

Identity: Authentication

// Login
Map tokens = essabu.identity().auth().login(Map.of(
    "email", "user@example.com", "password", "secret"
));

// Enable 2FA
Map qr = essabu.identity().auth().enable2FA(Map.of());
essabu.identity().auth().verify2FA(Map.of("code", "123456"));

Trade: CRM and Orders

// Create customer
Map customer = essabu.trade().customers().create(Map.of(
    "name", "Acme Corp", "email", "contact@acme.com"
));

// Track opportunity
Map opp = essabu.trade().opportunities().create(Map.of(
    "name", "Enterprise Deal", "value", 50000, "customerId", customerId
));

Payment: Process Payments

// Create and confirm a payment
Map intent = essabu.payment().intents().create(Map.of(
    "amount", 5000, "currency", "USD", "customerId", customerId
));
essabu.payment().intents().confirm(intentId);

// Create a refund
Map refund = essabu.payment().refunds().create(Map.of(
    "transactionId", txId, "amount", 1000, "reason", "Customer request"
));

E-Invoice: Submit and Verify

// Submit
Map einv = essabu.einvoice().invoices().submit(Map.of(
    "invoiceId", invoiceId, "buyerTin", "123456789", "buyerName", "Acme Corp"
));

// Check status
Map status = essabu.einvoice().invoices().getSubmissionStatus(einvId);

// Verify (public, no auth)
Map result = essabu.einvoice().verification().verify("INV-2026-001-ABCDEF");

Project: Task Management

// Create project
Map proj = essabu.project().projects().create(Map.of(
    "name", "Website Redesign", "startDate", "2026-04-01", "endDate", "2026-06-30"
));

// Create task with comment
Map task = essabu.project().tasks().create(Map.of(
    "projectId", projectId, "title", "Design mockups", "assigneeId", userId
));
essabu.project().tasks().createComment(Map.of("taskId", taskId, "content", "Looking good!"));

Asset: Fleet Management

// Register vehicle
Map vehicle = essabu.asset().vehicles().create(Map.of(
    "make", "Toyota", "model", "Hilux", "year", 2025, "licensePlate", "ABC-1234"
));

// Log fuel and trips
essabu.asset().fleet().createFuelLog(Map.of(
    "vehicleId", vehicleId, "liters", 45.0, "costPerLiter", 1.85, "date", "2026-03-26"
));
essabu.asset().fleet().createTripLog(Map.of(
    "vehicleId", vehicleId, "driverId", driverId,
    "startOdometer", 15230, "endOdometer", 15380
));

Clone this wiki locally