The Java SDK provides a comprehensive library for easily integrating with the Mambo API. This client library simplifies development by handling authentication, request formatting, and response parsing, allowing you to focus on your application logic. The JAR bundle includes source code with contextual JavaDocs to facilitate development.
To connect to the Mambo API, use one of the service classes provided in the services package. See the code samples below for implementation examples.
Use the request options object to provide configuration on a per-request basis. This object can be used to provide idempotency keys or request specific timeouts.
Here's a complete example showing how to initialise the client and make a basic API call:
Java
import io.mambo.sdk.MamboClient;
import io.mambo.sdk.model.Activity;
import io.mambo.sdk.params.ActivityCreateParams;
public class QuickStart {
public static void main(String[] args) {
// Create client with your API credentials
MamboClient client = new MamboClient( "your_public_key", "your_private_key" );
ActivityBehaviourAttrsData attrs = new ActivityBehaviourAttrsData();
attrs.setVerb( "purchase" );
ActivityRequestData data = new ActivityRequestData();
data.setUUID( "user_uuid" );
data.setAttrs( attrs );
// Call API and handle response
try {
AggregateId id = client.activities().createAsync( "acmeinc", data );
System.out.println( "Activity created with ID: " + id );
} catch (Exception e) {
System.err.println( "Error creating activity: " + id );
}
}
}