ryabenko-pro / java-sdk

Elarian Java SDK

Home Page:https://elarianltd.github.io/java-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elarian

The SDK provides convenient access to the Elarian APIs from applications written in Kotlin, Java, and Scala.

Project Status: Still under ACTIVE DEVELOPMENT, APIs are unstable and may change at any time until release of v1.0.0.

Documentation

Take a look at the API docs here. For detailed info on this SDK, see the reference.

Install

You can depend on the .jar through Maven:

<dependency>
  <groupId>com.elarian</groupId>
  <artifactId>elarian-core</artifactId>
  <version>0.2.4</version>
</dependency>

or sbt:

libraryDependencies += "com.elarian" % "elarian-core" % "0.2.4"

or Gradle:

dependencies{
  implementation 'com.elarian:elarian-core:0.2.4'
  // Or if you're building for android
  // implementation 'com.elarian:elarian-android:0.2.4'
}

Usage

The SDK needs to be initialized with your API key, which you get from the dashboard.

import com.elarian.*;
import com.elarian.model.*;

// ...

String appId = "test_app";
String orgId = "test_org";
String apiKey = "test_api_key";

Elarian app = new Elarian(apiKey, orgId, appId);

app.connect(new ConnectionListener() {
    @Override
    public void onPending() {
        log.info("Pending...");
    }

    @Override
    public void onConnecting() {
        log.info("Connecting...");
    }

    @Override
    public void onClosed() {
        log.info("Connection Closed");
    }

    @Override
    public void onError(Throwable throwable) {
        log.error("Failed to connect: " + throwable.getMessage());
    }

    @Override
    public void onConnected() {
        log.info("Connected!");
        Tag tag = new Tag("some-key", "some-value");
        MessagingChannel channel = new MessagingChannel("2020", MessagingChannel.Channel.SMS);
        Message message = new Message(new MessageBody("This is a test"));
        app.sendMessageByTag(tag, channel, message)
                .subscribe(
                        res -> log.info(res.description),
                        err -> err.printStackTrace()
                );
    }
});
try {
    Thread.currentThread().join();
} catch (InterruptedException e) {
    e.printStackTrace();
}

See examples for more usage examples.

Development

See SDK Spec for reference.

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

Known Issues

  • Elarian domain name not resolving on Android

About

Elarian Java SDK

https://elarianltd.github.io/java-sdk/

License:MIT License


Languages

Language:Java 98.9%Language:Kotlin 1.0%Language:Scala 0.0%