Skip to content

OkaeriPoland/okaeri-sdk-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Okaeri SDK for Java

License Total lines Repo size Contributors Discord

Currently supported services:

Full documentation available on wiki.okaeri.eu in:

Installation

Maven

Add repository to the repositories section:

<repository>
    <id>okaeri-repo</id>
    <url>https://storehouse.okaeri.eu/repository/maven-public/</url>
</repository>

Add dependency to the dependencies section:

<dependency>
    <groupId>eu.okaeri</groupId>
    <artifactId>okaeri-sdk</artifactId>
    <version>1.4.5</version>
</dependency>

In public projects that are not standalone systems you may also like to relocate the following:

<relocation>
    <pattern>kong.unirest.</pattern>
    <shadedPattern>my.package.lib.unirest.</shadedPattern>
</relocation>
<relocation>
    <pattern>org.apache.</pattern>
    <shadedPattern>my.package.lib.apache.</shadedPattern>
</relocation>
<relocation>
    <pattern>com.google.gson.</pattern>
    <shadedPattern>my.package.lib.gson.</shadedPattern>
</relocation>

Gradle

Add repository to the repositories section:

maven { url "https://storehouse.okaeri.eu/repository/maven-public/" }

Add dependency to the maven section:

implementation('eu.okaeri:okaeri-sdk:1.4.5')

Example usage

OK! AI.Censor

See full docs in: Polish, English

import eu.okaeri.sdk.aicensor.AiCensorClient;
import eu.okaeri.sdk.aicensor.error.AiCensorException;
import eu.okaeri.sdk.aicensor.model.AiCensorPredictionInfo;

final class Demo {
    public static void main(String[] args) {
        AiCensorClient aicensor = new AiCensorClient("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
        AiCensorPredictionInfo prediction;
        try {
            prediction = aicensor.getPrediction("o cie k u r//w@!");;
        } catch (AiCensorException exception) {
            exception.printStackTrace(); // FIXME: error handling
            return;
        }
        boolean swear = prediction.getGeneral().isSwear();
        System.out.println(swear ? "Tak, to jest wulgarne." : "Nie, to nie jest wulgarne");
    }
}

OK! No.Proxy

See full docs in: Polish, English

import eu.okaeri.sdk.noproxy.NoProxyClient;
import eu.okaeri.sdk.noproxy.error.NoProxyException;
import eu.okaeri.sdk.noproxy.model.NoProxyAddressInfo;

final class Demo {
    public static void main(String[] args) {
        NoProxyClient noproxy = new NoProxyClient("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
        NoProxyAddressInfo info;
        try {
            info = noproxy.getInfo("1.1.1.1");
        } catch (NoProxyException exception) {
            exception.printStackTrace(); // FIXME: error handling
            return;
        }
        boolean proxy = info.getRisks().isProxy();
        boolean verify = info.getSuggestions().isVerify();
        boolean block = info.getSuggestions().isBlock();
        System.out.println("proxy: " + proxy + ", verify: " + verify + ", block: " + block);
    }
}

OK! OpenVote

See full docs in: Polish, English

import eu.okaeri.sdk.openvote.OpenVoteClient;
import eu.okaeri.sdk.openvote.error.OpenVoteException;
import eu.okaeri.sdk.openvote.model.list.OpenVoteListVote;

import java.util.UUID;

final class Demo {
    public static void main(String[] args) {
        OpenVoteClient openvote = new OpenVoteClient();
        OpenVoteListVote vote;
        try {
            vote = openvote.getListVote(UUID.fromString("3fa85f64-5717-4562-b3fc-2c963f66afa6"));
        } catch (OpenVoteException exception) {
            exception.printStackTrace(); // FIXME: error handling
            return;
        }
        String server = vote.getServer();
        String list = vote.getList();
        System.out.println("server: " + server + ", list: " + list);
    }
}