diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 7b57c8d..50d91fe 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
- java-version: [ 11, 17, 18 ]
+ java-version: [ 11, 17, 20 ]
steps:
- uses: actions/checkout@v3
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 79ee123..d91f848 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 9a55c2d..f8467b4 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 430ef3b..c55e354 100644
--- a/README.md
+++ b/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/jokeapi/)
[](https://github.com/ethauvin/jokeapi/releases/latest)
-[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/jokeapi)
+[](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi)
[](https://sonarcloud.io/dashboard?id=ethauvin_jokeapi)
[](https://github.com/ethauvin/jokeapi/actions/workflows/gradle.yml)
@@ -36,7 +36,7 @@ data class Joke(
val lang: Language
)
```
-- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokeTest.kt#L31)...
+- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokeTest.kt#L64)...
To retrieve multiple jokes:
@@ -48,7 +48,7 @@ frenchJokes.forEach {
}
```
-- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokesTest.kt#L31)...
+- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokesTest.kt#L52)...
If an error occurs, a `JokeException` is thrown, matching the [JokeAPI errors](https://sv443.net/jokeapi/v2/#errors):
@@ -74,7 +74,7 @@ class HttpErrorException(
cause: Throwable? = null
) : IOException(message, cause)
```
-- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ExceptionsTest.kt#L31)...
+- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ExceptionsTest.kt#L57)...
## Java
@@ -98,11 +98,11 @@ repositories {
}
dependencies {
- implementation("net.thauvin.erik:jokeapi:0.9-SNAPSHOT")
+ implementation("net.thauvin.erik:jokeapi:0.9.0")
}
```
-Instructions for using with Maven, Ivy, etc. can be found on Maven Central.
+Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi).
## Raw Jokes
@@ -130,7 +130,7 @@ safe: true
lang: "en"
```
-- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetRawJokesTest.kt#L31)...
+- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetRawJokesTest.kt#L46)...
## Extending
@@ -150,10 +150,4 @@ println(lang)
error: false
code: "fr"
```
-- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L31)...
-
-
-
-
-
-
+- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L48)...
diff --git a/build.gradle.kts b/build.gradle.kts
index b7a2df9..4ed8a4e 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
- id("com.github.ben-manes.versions") version "0.47.0"
+ id("com.github.ben-manes.versions") version "0.48.0"
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("java")
id("maven-publish")
@@ -15,9 +15,9 @@ plugins {
kotlin("jvm") version "1.9.10"
}
-description = "Wrapper for Sv443's JokeAPI"
+description = "Retrieve jokes from Sv443's JokeAPI"
group = "net.thauvin.erik"
-version = "0.9-SNAPSHOT"
+version = "0.9.0"
val deployDir = "deploy"
val gitHub = "ethauvin/$name"
@@ -32,12 +32,12 @@ repositories {
dependencies {
implementation(platform(kotlin("bom")))
- implementation("net.thauvin.erik:urlencoder:1.3.0")
+ implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.4.0")
implementation("org.json:json:20230618")
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
- testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.26.1")
+ testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.27.0")
}
java {
@@ -126,7 +126,7 @@ tasks {
register("deploy") {
description = "Copies all needed files to the $deployDir directory."
group = PublishingPlugin.PUBLISH_TASK_GROUP
- dependsOn(clean, wrapper, build, jar)
+ dependsOn(clean, build, jar)
outputs.dir(deployDir)
inputs.files(copyToDeploy)
mustRunAfter(clean)
diff --git a/detekt-baseline.xml b/detekt-baseline.xml
index 3709007..a53ce7c 100644
--- a/detekt-baseline.xml
+++ b/detekt-baseline.xml
@@ -18,5 +18,6 @@
MagicNumber:JokeUtil.kt$500
MagicNumber:JokeUtil.kt$523
TooManyFunctions:JokeConfig.kt$JokeConfig$Builder
+ WildcardImport:JokeApi.kt$import net.thauvin.erik.jokeapi.models.*
diff --git a/pom.xml b/pom.xml
index 2f101ee..31a633b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,9 +8,9 @@
4.0.0
net.thauvin.erik
jokeapi
- 0.9-SNAPSHOT
+ 0.9.0
jokeapi
- Wrapper for Sv443's JokeAPI
+ Retrieve jokes from Sv443's JokeAPI
https://github.com/ethauvin/jokeapi
@@ -40,7 +40,7 @@
org.jetbrains.kotlin
kotlin-bom
- 1.8.22
+ 1.9.10
pom
import
@@ -50,13 +50,13 @@
org.jetbrains.kotlin
kotlin-stdlib-jdk8
- 1.8.22
+ 1.9.10
compile
- net.thauvin.erik
- urlencoder
- 1.3.0
+ net.thauvin.erik.urlencoder
+ urlencoder-lib-jvm
+ 1.4.0
runtime
diff --git a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt
index 48e9415..b4df9aa 100644
--- a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt
+++ b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt
@@ -33,15 +33,8 @@ package net.thauvin.erik.jokeapi
import net.thauvin.erik.jokeapi.exceptions.HttpErrorException
import net.thauvin.erik.jokeapi.exceptions.JokeException
-import net.thauvin.erik.jokeapi.models.Category
-import net.thauvin.erik.jokeapi.models.Flag
-import net.thauvin.erik.jokeapi.models.Format
-import net.thauvin.erik.jokeapi.models.IdRange
-import net.thauvin.erik.jokeapi.models.Joke
-import net.thauvin.erik.jokeapi.models.Language
-import net.thauvin.erik.jokeapi.models.Parameter
-import net.thauvin.erik.jokeapi.models.Type
-import net.thauvin.erik.urlencoder.UrlEncoder
+import net.thauvin.erik.jokeapi.models.*
+import net.thauvin.erik.urlencoder.UrlEncoderUtil
import org.json.JSONObject
import java.util.logging.Logger
import java.util.stream.Collectors
@@ -85,7 +78,7 @@ object JokeApi {
val param = it.next()
urlBuilder.append(param.key)
if (param.value.isNotEmpty()) {
- urlBuilder.append("=").append(UrlEncoder.encode(param.value))
+ urlBuilder.append("=").append(UrlEncoderUtil.encode(param.value))
}
if (it.hasNext()) {
urlBuilder.append("&")
diff --git a/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt b/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt
index c165512..d9f9b30 100644
--- a/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt
@@ -36,6 +36,7 @@ import assertk.assertions.isGreaterThan
import assertk.assertions.startsWith
import net.thauvin.erik.jokeapi.JokeApi.apiCall
import net.thauvin.erik.jokeapi.models.Format
+import net.thauvin.erik.jokeapi.models.Language
import net.thauvin.erik.jokeapi.models.Parameter
import org.json.JSONObject
import org.junit.jupiter.api.Assertions.assertFalse
@@ -73,4 +74,14 @@ internal class ApiCallTest {
val ping = apiCall(endPoint = "ping", params = mapOf(Parameter.FORMAT to Format.TXT.value))
assertThat(ping, "apiCall(ping, txt)").startsWith("Pong!")
}
+
+ @Test
+ fun `Get Supported Language`() {
+ // See https://v2.jokeapi.dev/languages
+ val lang = apiCall(
+ endPoint = "languages",
+ params = mapOf(Parameter.FORMAT to Format.XML.value, Parameter.LANG to Language.FR.value)
+ )
+ assertThat(lang).startsWith("")
+ }
}