Wrapper for the unofficial azur lane json api in Kotlin
Gradle
repositories {
maven(url = "https://jitpack.io")
}
dependencies {
implementation("com.github.azurlane-api:AzurLaneKt:Tag")
}
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.azurlane-api</groupId>
<artifactId>AzurLaneKt</artifactId>
<version>Tag</version>
</dependency>
Async request
package com.example
import com.github.azurlane_api.api.AzurLane
import com.github.azurlane_api.api.Category
object Example {
@JvmStatic
fun main(args: Array<String>) {
val azurlane = AzurLane("custom_ua/v0.1.0")
val result = azurlane.getShips(Category.TYPE, "Destroyer").complete { result ->
val (ships, exception) = result
when (result) {
is Result.Success -> {
if (!ships.isNullOrEmpty())
ships.forEach { ship -> println("[${ship.id}]: (${ship.name})") }
}
is Result.Failure -> {
println(exception)
}
}
}
}
}
Blocking request
package com.example
import com.github.azurlane_api.api.AzurLane
import com.github.azurlane_api.api.Category
object Example {
@JvmStatic
fun main(args: Array<String>) {
val azurlane = AzurLane("custom_ua/v0.1.0")
val result = azurlane.getShips(Category.RARITY, "Super Rare").complete()
val (ships, exception) = result
when (result) {
is Result.Success -> {
if (!ships.isNullOrEmpty())
ships.forEach { ship -> println("[${ship.id}]: (${ship.name})") }
}
is Result.Failure -> {
println(exception)
}
}
}
}