Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Latest commit

History

35 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Codeship Status for StuartApp/stuart-client-java

Nexus

Stuart Java Client

For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.

Install

If you're using Maven, add the following dependency to your pom.xml file:

<dependency>
<groupId>com.github.stuartapp</groupId>
<artifactId>stuart-client-java</artifactId>
<version>1.0.0</version>
</dependency>

Usage

Initialize HTTP client

Environmentenvironment = Environment.SANDBOX;
StringapiClientId = "c6058849d0a056fc743203acb8e6a850dad103485c3edc51b16a9260cc7a7689"; // can be found here: https://dashboard.sandbox.stuart.com/settings/apiStringapiClientSecret = "aa6a415fce31967501662c1960fcbfbf4745acff99acb19dbc1aae6f76c9c618"; // can be found here: https://dashboard.sandbox.stuart.com/settings/apiAuthenticatorauthenticator = newAuthenticator(environment, apiClientId, apiClientSecret);
HttpClienthttpClient = newHttpClient(authenticator);

Custom request

publicvoidcreateAJobExample() {
JsonObjectjob = newJsonObject();
job.addProperty("transport_type", "bike");
JsonArraypickups = newJsonArray();
JsonObjectpickup = buildLocation(
"46 Boulevard Barbès, 75018 Paris",
"Wait outside for an employee to come.",
"Martin",
"Pont",
"+33698348756",
"KFC Paris Barbès"
);
pickups.add(pickup);
JsonArraydropoffs = newJsonArray();
JsonObjectdropoff = buildLocation(
"156 rue de Charonne, 75011 Paris",
"code: 3492B. 3e étage droite. Sonner à Durand.",
"Alex",
"Durand",
"+33634981209",
"Durand associates."
);
dropoff.addProperty("client_reference", "reference-id-01");
dropoffs.add(dropoff);
JsonObjectroot = newJsonObject();
job.add("pickups", pickups);
job.add("dropoffs", dropoffs);
root.add("job", job);
ApiResponseapiResponse = httpClient.performPost("/v2/jobs", root.toString());
}
publicJsonObjectbuildLocation(Stringaddress, Stringcomment, Stringfirstname, Stringlastname, Stringphone, Stringcompany) {
JsonObjectlocation = newJsonObject();
location.addProperty("address", address);
location.addProperty("comment", comment);
JsonObjectcontact = newJsonObject();
location.add("contact", contact);
contact.addProperty("firstname", firstname);
contact.addProperty("lastname", lastname);
contact.addProperty("phone", phone);
contact.addProperty("company", company);
returnlocation;
}

About

Stuart Java client

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages