whats-this / owo.java

Read-only mirror of https://owo.codes/whats-this/owo.java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

owo.java

Download CircleCI

This is an API wrapper for https://whats-th.is/ written in Java. This wrapper requires Java 7 or above to function, it has also been confirmed working with Android (Minimum version is Marshmallow, because of Java 7).

Download

Replace VERSION with a specific version. The latest version can be found at the top of the readme Maven:

<dependencies>
    <dependency>
      <groupId>me.bramhaag</groupId>
      <artifactId>owo-java</artifactId>
      <version>VERSION</version>
    </dependency>
</dependencies>

Gradle:

repositories {
    jcenter()
}

dependencies {
    compile 'me.bramhaag:owo-java:VERSION'
}

Or you can build the jar yourself (see below)

Usage

To get started, create an OwO object using the Builder class.

REQUIRED TOKEN should be replaced with your own unique OwO API key
(OPTIONAL) You can set endpoint to use a custom endpoint, default endpoint is https://api.awau.moe/
(OPTIONAL) You can set uploadUrl to use a custom upload url, default upload URL is https://owo.whats-th.is/
(OPTIONAL) You can set shortenUrl to use a custom shorten url, default upload URL is https://awau.moe/

OwO owo = new OwO.Builder()
                .setKey("TOKEN")
                .setUploadUrl("https://owo.whats-th.is/")
                .setShortenUrl("https://thats-a.link/")
                .build();

Next, we can use our newly created owo object to upload files and shorten urls

OwO#upload and OwO#shorten both return OwoActions, these can be executed async using the execute method, but can also be executed sync using the executeSync method

owo.shorten("http://my_domain.com").execute(url -> System.out.println("Shortened link: " + url));
owo.upload(new File("my_image.png")).execute(file -> System.out.println("Image URL: " + file.getUrl()));

This code can throw an exception when something goes wrong, to handle this exception we can add an extra throwable argument to the execute method

owo.shorten("http://my_domain.com").execute(url -> System.out.println("Shortened link: " + url), throwable -> /* handle error */);
owo.upload(new File("my_image.png")).execute(file -> System.out.println("Image URL: " + file.getUrl()), throwable -> /* handle error */);

How to build

With dependencies
  1. Run gradlew shadowJar in project's root.
  2. The file is located in build/lib.
Without dependencies
  1. Run gradlew build in project's root.
  2. The file is located in build/lib.

Contributing

Pull requests are accepted, but please make sure your code actually works.

License

The contents of this repository are licensed under the MIT license. A copy of the MIT license can be found in LICENSE.

About

Read-only mirror of https://owo.codes/whats-this/owo.java

License:MIT License


Languages

Language:Java 100.0%