Skip to content

OneSky Platform API - Java Wrapper

License

Notifications You must be signed in to change notification settings

vovkss/onesky-java

Repository files navigation

OneSky Java API Library

Java 11+ License Build Status

Java wrapper for OneSky API.

For the list of API wrappers in other programming languages, see the OneSky Platform API documentation.

Dependency Information

The library is available in Maven Central Repository, the coordinates are:

info.datamuse:onesky-java:1.0.0

For example, Apache Maven dependency would be:

<dependency>
  <groupId>info.datamuse</groupId>
  <artifactId>onesky-java</artifactId>
  <version>1.0.0-alpha</version>
</dependency>

How to use

Create a client instance:

// Create the HttpClient and configure it as needed
var httpClient = HttpClient.newHttpClient();

var oneSkyClient = new OneSkyClient(
    "<api-key>", "<api-secret>", httpClient
);

Asynchronous vs synchronous usage:

Every API call returns a CompletableFuture which allows asynchronous API usage, e.g.:

oneSkyClient.locales().list().whenComplete(
    (locales, throwable) -> {
        if (locales != null) {
            final String localesString = locales.stream().map(Locale::toString).collect(Collectors.joining(", "));
            System.out.println("OneSky locales: " + localesString);
        } else if (throwable != null) {
            System.out.println("OneSky API call failed: " + throwable.getMessage());
        }
    }
);

To use the API synchronously, just invoke CompletableFuture.join(), e.g.:

List<Locale> locales = oneSkyClient.locales().list().join();

Project Groups API example:

OneSkyProjectGroupsApi.ProjectGroup javaGroup = oneSkyClient.projectGroups().create("Java", Locale.CHINESE).join();

Page<OneSkyProjectGroupsApi.ProjectGroup> groups = oneSkyClient.projectGroups().pagedList(1, 50).join();

OneSkyProjectGroupsApi.ProjectGroup group4711 = oneSkyClient.projectGroups().retrieve(4711).join();

oneSkyClient.projectGroups().delete(1147).join();

Project Types API example:

List<OneSkyProjectTypesApi.ProjectType> projectTypes = oneSkyClient.projectTypes().list().join();
projectTypes.forEach(projectType -> 
    System.out.println(projectType.getCode() + ": " + projectType.getName())
);

Locales API example:

List<Locale> oneSkyLocales = oneSkyClient.locales().list().join();

Authors and contributors

About

OneSky Platform API - Java Wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages