diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 42bc1da..658abb4 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -39,7 +39,7 @@ jobs:
- name: Test with Gradle
uses: gradle/gradle-build-action@v2
with:
- arguments: build check --stacktrace
+ arguments: build check --stacktrace --scan
- name: SonarCloud
if: success() && matrix.java-version == env.SONAR_JDK
diff --git a/.github_changelog_generator b/.github_changelog_generator
new file mode 100644
index 0000000..a12ba88
--- /dev/null
+++ b/.github_changelog_generator
@@ -0,0 +1 @@
+future-release=1.0.0
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..48ea182
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,19 @@
+# Changelog
+
+## [1.0.0](https://github.com/ethauvin/isgd-shorten/tree/1.0.0) (2023-09-25)
+
+[Full Changelog](https://github.com/ethauvin/isgd-shorten/compare/0.9.1...1.0.0)
+
+**Implemented enhancements:**
+
+- Add config builder [\#3](https://github.com/ethauvin/isgd-shorten/issues/3)
+- Use UrlEncoder instead of java.net.URLEncoder [\#2](https://github.com/ethauvin/isgd-shorten/issues/2)
+- Implement a way to retrieve the error response message. [\#1](https://github.com/ethauvin/isgd-shorten/issues/1)
+
+## [0.9.1](https://github.com/ethauvin/isgd-shorten/tree/0.9.1) (2020-06-10)
+
+[Full Changelog](https://github.com/ethauvin/isgd-shorten/compare/60c449feed0ddced600d7135766243e7058d683a...0.9.1)
+
+
+
+\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
diff --git a/README.md b/README.md
index 0e7a2fa..ef83280 100644
--- a/README.md
+++ b/README.md
@@ -24,8 +24,7 @@ Isgd.lookup("https://is.gd/Pt2sET") // returns https://www.example.com
```
- - View [Kotlin](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/kotlin/com/example/IsgdExample.kt) or [Java](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/java/com/example/IsgdSample.java) Examples.
-
+- View [Kotlin](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/kotlin/com/example/IsgdExample.kt) or [Java](https://github.com/ethauvin/isgd-shorten/blob/master/examples/src/main/java/com/example/IsgdSample.java) Examples.
### JSON or XML
@@ -53,11 +52,13 @@ Isgd.shorten(
logstats = true,
format = Format.JSON)
```
+
returns:
```js
test({ "shorturl": "https://is.gd/foobar" });
```
+
### Gradle
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/isgd-shorten/blob/master/examples/build.gradle.kts) file:
@@ -69,9 +70,10 @@ repositories {
}
dependencies {
- implementation("net.thauvin.erik:isgd-shorten:0.9.2")
+ implementation("net.thauvin.erik:isgd-shorten:1.0.0")
}
```
+
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/isgd-shorten).
## Java
@@ -81,14 +83,15 @@ To make it easier to use the library with Java, configuration builders are avail
```java
var config = new Config.Builder()
.url("https://www.example.com/")
- .shorturl("foobar")
+ .shortUrl("foobar")
.callback("test")
- .logstats(true)
+ .logStats(true)
.format(Format.JSON)
.build();
Isgd.shorten(config);
```
+
```java
var config = new Config.Builder()
.shortUrl("https://is.gd/Pt2sET")
@@ -97,9 +100,10 @@ var config = new Config.Builder()
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:
+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:
```kotlin
try {
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index 33af313..ca16f83 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -16,7 +16,7 @@ repositories {
}
dependencies {
- implementation("net.thauvin.erik:isgd-shorten:0.9.2-SNAPSHOT")
+ implementation("net.thauvin.erik:isgd-shorten:1.0.0")
}
java {
diff --git a/examples/src/main/java/com/example/IsgdSample.java b/examples/src/main/java/com/example/IsgdSample.java
index 2f431cb..b79d095 100644
--- a/examples/src/main/java/com/example/IsgdSample.java
+++ b/examples/src/main/java/com/example/IsgdSample.java
@@ -1,5 +1,7 @@
package com.example;
+import net.thauvin.erik.isgd.Config;
+import net.thauvin.erik.isgd.Format;
import net.thauvin.erik.isgd.Isgd;
import net.thauvin.erik.isgd.IsgdException;
@@ -10,6 +12,7 @@ public final class IsgdSample {
try {
if (arg.contains("is.gd")) {
System.out.println(arg + " <-- " + Isgd.lookup(arg));
+ System.out.print(Isgd.lookup(new Config.Builder().shortUrl(arg).format(Format.WEB).build()));
} else {
System.out.println(arg + " --> " + Isgd.shorten(arg));
}
diff --git a/pom.xml b/pom.xml
index 2e58948..b1cfd73 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
4.0.0
net.thauvin.erik
isgd-shorten
- 0.9.2-SNAPSHOT
+ 1.0.0
isgd-shorten
A simple implementation of the is.gd URL shortening and lookup APIs
https://github.com/ethauvin/isgd-shorten
diff --git a/settings.gradle.kts b/settings.gradle.kts
index e93f35f..cf129ff 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,5 +1,5 @@
plugins {
- id("com.gradle.enterprise").version("3.6.3")
+ id("com.gradle.enterprise").version("3.15")
}
gradleEnterprise {
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/Config.kt b/src/main/kotlin/net/thauvin/erik/isgd/Config.kt
index f6bcb9d..3c132cf 100644
--- a/src/main/kotlin/net/thauvin/erik/isgd/Config.kt
+++ b/src/main/kotlin/net/thauvin/erik/isgd/Config.kt
@@ -44,19 +44,21 @@ class Config private constructor(
) {
/**
* Configures the parameters to create/lookup an is.gd shortlink.
+ *
+ * See the [is.gd API](https://is.gd/apishorteningreference.php).
*/
data class Builder(
- var url: String = "",
- var shorturl: String = "",
- var callback: String = "",
- var logstats: Boolean = false,
- var format: Format = Format.SIMPLE,
- var isVgd: Boolean = false
+ private var url: String = "",
+ private var shorturl: String = "",
+ private var callback: String = "",
+ private var logstats: Boolean = false,
+ private var format: Format = Format.SIMPLE,
+ private var isVgd: Boolean = false
) {
fun url(url: String) = apply { this.url = url }
- fun shorturl(shorturl: String) = apply { this.shorturl = shorturl }
+ fun shortUrl(shortUrl: String) = apply { this.shorturl = shortUrl }
fun callback(callback: String) = apply { this.callback = callback }
- fun logstats(logstats: Boolean) = apply { this.logstats = logstats }
+ fun logStats(logStats: Boolean) = apply { this.logstats = logStats }
fun format(format: Format) = apply { this.format = format }
fun isVgd(isVgd: Boolean) = apply { this.isVgd = isVgd }
diff --git a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
index e01e4ee..9ec930a 100644
--- a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
@@ -84,7 +84,7 @@ class IsgdTest {
assertFailsWith(
message = "lookup(config:empty)",
exceptionClass = IllegalArgumentException::class,
- block = { Isgd.lookup(Config.Builder().shorturl("").build()) }
+ block = { Isgd.lookup(Config.Builder().shortUrl("").build()) }
)
}
@@ -96,10 +96,10 @@ class IsgdTest {
@Test
fun testLookupDefaultConfig() {
- assertEquals(url, Isgd.lookup(Config.Builder().shorturl(shortUrl).build()), "lookup(config)")
+ assertEquals(url, Isgd.lookup(Config.Builder().shortUrl(shortUrl).build()), "lookup(config)")
assertEquals(
url, Isgd.lookup(
- Config.Builder().shorturl(shortVgdUrl).isVgd(true).build()
+ Config.Builder().shortUrl(shortVgdUrl).isVgd(true).build()
), "lookup(config:isVgd)"
)
}
@@ -119,12 +119,12 @@ class IsgdTest {
fun testLookupJsonConfig() {
assertEquals(
"{ \"url\": \"$url\" }",
- Isgd.lookup(Config.Builder().shorturl(shortUrl).format(Format.JSON).build()), "lookup(config)"
+ Isgd.lookup(Config.Builder().shortUrl(shortUrl).format(Format.JSON).build()), "lookup(config)"
)
assertEquals(
"test({ \"url\": \"$url\" });",
- Isgd.lookup(Config.Builder().shorturl(shortUrl).callback("test").format(Format.JSON).build()),
+ Isgd.lookup(Config.Builder().shortUrl(shortUrl).callback("test").format(Format.JSON).build()),
"lookup(config:callback)"
)
}
@@ -141,7 +141,7 @@ class IsgdTest {
fun testLookupXmlConfig() {
assertEquals(
"",
- Isgd.lookup(Config.Builder().shorturl(shortUrl).format(Format.XML).build()),
+ Isgd.lookup(Config.Builder().shortUrl(shortUrl).format(Format.XML).build()),
"lookup(config:xml)"
)
}
@@ -172,7 +172,7 @@ class IsgdTest {
assertFailsWith(
message = "shorten(config:shorturl)",
exceptionClass = IsgdException::class,
- block = { Isgd.shorten(Config.Builder(url).shorturl("test").build()) }
+ block = { Isgd.shorten(Config.Builder(url).shortUrl("test").build()) }
)
}
@@ -191,7 +191,7 @@ class IsgdTest {
Isgd.shorten(Config.Builder().url(url).isVgd(true).build()),
"shorten(config:isVgd)"
)
- assertThat(Isgd.shorten(Config.Builder().url(url).logstats(true).build()), "shorten(config:callback)")
+ assertThat(Isgd.shorten(Config.Builder().url(url).logStats(true).build()), "shorten(config:callback)")
.matches("https://is.gd/\\w{6}".toRegex())
}
diff --git a/version.properties b/version.properties
index 5040329..4b9c7b3 100644
--- a/version.properties
+++ b/version.properties
@@ -1,8 +1,8 @@
#Generated by the Semver Plugin for Gradle
#Sun May 02 21:57:08 PDT 2021
version.buildmeta=
-version.major=0
-version.minor=9
-version.patch=2
-version.prerelease=SNAPSHOT
-version.semver=0.9.2-SNAPSHOT
+version.major=1
+version.minor=0
+version.patch=0
+version.prerelease=
+version.semver=1.0.0