Minor cleanups
This commit is contained in:
parent
89b51307b3
commit
1a3c7fbac2
3 changed files with 11 additions and 20 deletions
22
pom.xml
22
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik</groupId>
|
||||||
<artifactId>jokeapi</artifactId>
|
<artifactId>jokeapi</artifactId>
|
||||||
<version>0.9.1</version>
|
<version>0.9.2-SNAPSHOT</version>
|
||||||
<name>jokeapi</name>
|
<name>jokeapi</name>
|
||||||
<description>Retrieve jokes from Sv443's JokeAPI</description>
|
<description>Retrieve jokes from Sv443's JokeAPI</description>
|
||||||
<url>https://github.com/ethauvin/jokeapi</url>
|
<url>https://github.com/ethauvin/jokeapi</url>
|
||||||
|
@ -18,25 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib</artifactId>
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
<version>1.9.21</version>
|
<version>1.9.22</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-common</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-jdk7</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
|
||||||
<version>1.9.21</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -45,6 +45,9 @@ import java.util.stream.Collectors
|
||||||
object JokeApi {
|
object JokeApi {
|
||||||
private const val API_URL = "https://v2.jokeapi.dev/"
|
private const val API_URL = "https://v2.jokeapi.dev/"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logger instance.
|
||||||
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val logger: Logger by lazy { Logger.getLogger(JokeApi::class.java.simpleName) }
|
val logger: Logger by lazy { Logger.getLogger(JokeApi::class.java.simpleName) }
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,9 @@ private fun httpError(responseCode: Int): HttpErrorException {
|
||||||
return httpException
|
return httpException
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse Error.
|
||||||
|
*/
|
||||||
internal fun parseError(json: JSONObject): JokeException {
|
internal fun parseError(json: JSONObject): JokeException {
|
||||||
val causedBy = json.getJSONArray("causedBy")
|
val causedBy = json.getJSONArray("causedBy")
|
||||||
val causes = List<String>(causedBy.length()) { i -> causedBy.getString(i) }
|
val causes = List<String>(causedBy.length()) { i -> causedBy.getString(i) }
|
||||||
|
@ -136,6 +139,9 @@ internal fun parseError(json: JSONObject): JokeException {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse Joke.
|
||||||
|
*/
|
||||||
internal fun parseJoke(json: JSONObject, splitNewLine: Boolean): Joke {
|
internal fun parseJoke(json: JSONObject, splitNewLine: Boolean): Joke {
|
||||||
val jokes = mutableListOf<String>()
|
val jokes = mutableListOf<String>()
|
||||||
if (json.has("setup")) {
|
if (json.has("setup")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue