Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Retriever.kt
Browse files Browse the repository at this point in the history
- Functions internal
- Values private
  • Loading branch information
Doomsdayrs committed Jan 8, 2021
1 parent ad77048 commit aac7454
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/github/doomsdayrs/jikan4java/core/Retriever.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import java.util.concurrent.CompletionException
* @author github.com/doomsdayrs
*/
class Retriever(
val client: OkHttpClient = getDefaultOkHttpClient(),
private val client: OkHttpClient = getDefaultOkHttpClient(),
@Suppress("MemberVisibilityCanBePrivate")
val builder: Request.Builder = getDefaultRequestBuilder(),
val format: Json = getDefaultJSONParser(),
private val builder: Request.Builder = getDefaultRequestBuilder(),
private val format: Json = getDefaultJSONParser(),
) {

/**
Expand All @@ -51,17 +51,17 @@ class Retriever(
* @return response from jikan
* @throws IOException something went wrong
*/
fun request(url: String): ResponseBody? {
internal fun request(url: String): ResponseBody? {
println(url)
val request: Request = builder.url(url).build()
val call = client.newCall(request)
return call.execute().body
}

inline operator fun <reified T> invoke(url: String) =
internal inline operator fun <reified T> invoke(url: String) =
retrieve<T>(url)

inline fun <reified T> retrieve(
internal inline fun <reified T> retrieve(
url: String
): JCompletableFuture<T> = GlobalScope.future {
var response = ""
Expand Down

0 comments on commit aac7454

Please sign in to comment.