Prerequisites
To get the most out of this guide, you’ll need to:
1. Install
To install the API client library to your local Maven repository, simply execute:
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
Maven users
Add this dependency to your project’s POM:
<dependency>
<groupId>io.sendx</groupId>
<artifactId>sendx-java-sdk</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
Gradle users
Add this dependency to your project’s build file:
repositories {
mavenCentral()
mavenLocal()
dependencies {
implementation "io.sendx:sendx-java-sdk:1.0.1"
}
Others
At first generate the JAR by executing:
Then manually install the following JARs:
target/sendx-java-sdk-1.0.1.jar
target/lib/*.jar
2. Getting Started
// Import classes:
import sendx_java_sdk.ApiClient;
import sendx_java_sdk.ApiException;
import sendx_java_sdk.Configuration;
import sendx_java_sdk.auth.*;
import sendx_java_sdk.models.*;
import sendx_java_sdk.CampaignApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.sendx.io/api/v1/rest");
// Configure API key authorization: apiKeyAuth
ApiKeyAuth apiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("apiKeyAuth");
apiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKeyAuth.setApiKeyPrefix("Token");
ContactApi apiInstance = new ContactApi(defaultClient);
ContactRequest contactRequest = new ContactRequest(); // ContactRequest |
contactRequest.setFirstName("John")
contactRequest.setLastName("Doe")
contactRequest.setEmail("john.doe@sendx.io")
contactRequest.setCompany("SendX")
contactRequest.setLastTrackedIp("32.342.12.322")
// Set tags as a list of strings
List<String> tags = Arrays.asList("sner1jin3ij34b4", "234bjk2n42ednj32";
contactRequest.setTags(tags)
try {
OperationResponse result = apiInstance.createContact(contactRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CampaignApi#createCampaign");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
3. Try it for yourself