Added config builder. Closes #3
This commit is contained in:
parent
aaed5f45ce
commit
d0aa48dbee
5 changed files with 247 additions and 12 deletions
29
README.md
29
README.md
|
@ -1,8 +1,8 @@
|
|||
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||
[](https://kotlinlang.org/)
|
||||
[](https://kotlinlang.org/)
|
||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/isgd-shorten/)
|
||||
[](https://github.com/ethauvin/isgd-shorten/releases/latest)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten)
|
||||
[](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten)
|
||||
|
||||
[](https://sonarcloud.io/dashboard?id=ethauvin_isgd-shorten)
|
||||
[](https://github.com/ethauvin/isgd-shorten/actions/workflows/gradle.yml)
|
||||
|
@ -67,8 +67,31 @@ dependencies {
|
|||
implementation("net.thauvin.erik:isgd-shorten:0.9.2")
|
||||
}
|
||||
```
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/isgd-shorten).
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten).
|
||||
|
||||
## Java
|
||||
|
||||
To make it easier to use the library with Java, configuration builders are available:
|
||||
|
||||
```java
|
||||
var config = new Config.Builder()
|
||||
.url("https://www.example.com/")
|
||||
.shorturl("foobar")
|
||||
.callback("test")
|
||||
.logstats(true)
|
||||
.format(Format.JSON)
|
||||
.build();
|
||||
|
||||
Isgd.shorten(config);
|
||||
```
|
||||
```java
|
||||
var config = new Config.Builder()
|
||||
.shortUrl("https://is.gd/Pt2sET")
|
||||
.format(Format.XML)
|
||||
.build();
|
||||
|
||||
Isgd.lookup(config)
|
||||
```
|
||||
### Errors
|
||||
|
||||
An `IsgdException` is thrown when an API error occurs. The error message (text, XML or JSON) and HTTP status code can be retrieved as follows:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue