Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bramhaag committed May 5, 2017
0 parents commit 4b274ae
Show file tree
Hide file tree
Showing 28 changed files with 1,109 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
11 changes: 11 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/modules/jre7/jre7.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/modules/jre8/jre8.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions .idea/modules/owo-java.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Bram Hagens

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# owo.java

## OwO What's This?
This is an API wrapper for <https://whats-th.is/> written in Java.
This wrapper requires Java 7 or above (currently separate versions for Java 7 and 8 are available) to function,
it has also been confirmed working with Android (Minimum version is Marshmallow, because of Java 7).

## Usage
To start, create a new OwO object
```java
//Create a new OwO object, these objects can be reused.
OwO owo = new OwO("YOUR-TOKEN-HERE");
```

With this OwO object, you can shorten links and uploading files, simply by doing
```java
owo.shorten("http://my_domain.com");
owo.upload(new File("my_image.png"));
```
These methods return an `OwOAction<T>`. This means that the action has been prepared, but has not been send yet.
There are multiple ways to send this action, they can be send sync, async and with or without error handling.
```java
//Sync (These methods *can* throw errors, so you'll need to surround them with a try catch block)
String url = owo.shorten("http://my_domain.com").executeSync();
OwOFile file = owo.upload(new File("my_image.png")).executeSync();

//Async (no error handling)
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()));

//Async (with error handling)
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 files is located in `jre7/build/lib` and `jre8/build/lib`
##### Without dependencies
1. Run `gradlew build` in project's root
2. The files is located in `jre7/build/lib` and `jre8/build/lib` (Note that you will need to supply the dependencies yourself!)

## Which version to use
The jre7 version is a port of the jre8 version, this means that it *might* not have all features the jre8 version has,
but that is not likely to happen. I do recommend to use the jre8 version, unless you **have** to use Java 7.


## TODO
- Maven repo
- Javadoc
33 changes: 33 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
group 'me.bramhaag'
version '1.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'

allprojects {
group 'me.bramhaag'
version '1.1-SNAPSHOT'

apply plugin: 'java'

repositories {
mavenCentral()
}

dependencies {
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-scalars:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.google.code.gson:gson:2.8.0'

compileOnly "org.projectlombok:lombok:1.16.14"
}

sourceSets {
main {
java {
srcDir 'src'
}
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Fri May 05 21:49:40 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Loading

0 comments on commit 4b274ae

Please sign in to comment.