Skip to content

Commit

Permalink
feat: use jvm overloads on constrctor for better use on java (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
aripiprazole authored Jul 21, 2023
1 parent c013993 commit 88e5bc3
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions src/main/kotlin/WooviSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public suspend fun main() {
}

@OptIn(ExperimentalSerializationApi::class)
public class WooviSDK(
override val coroutineContext: CoroutineContext = Executors.newCachedThreadPool().asCoroutineDispatcher(),
public class WooviSDK @JvmOverloads public constructor(
private val appId: String,
private val baseUrl: String = "https://api.openpix.com.br/",
override val coroutineContext: CoroutineContext = Executors.newCachedThreadPool().asCoroutineDispatcher(),
private var json: Json = Json {
explicitNulls = true
ignoreUnknownKeys = true
Expand Down Expand Up @@ -93,7 +93,7 @@ public class WooviSDK(
allPayments()
}

public suspend fun createPaymentAsync(builder: PaymentBuilder): Future<PaymentResponseObject> = future {
public fun createPaymentAsync(builder: PaymentBuilder): Future<PaymentResponseObject> = future {
createPayment(builder) {}
}

Expand Down Expand Up @@ -182,26 +182,4 @@ public class WooviSDK(
ignoreUnknownKeys = value
}
}

public companion object {
@JvmStatic
public fun of(executor: Executor, appId: String): WooviSDK {
return WooviSDK(executor.asCoroutineDispatcher(), appId)
}

@JvmStatic
public fun of(executor: Executor, appId: String, baseUrl: String): WooviSDK {
return WooviSDK(executor.asCoroutineDispatcher(), appId, baseUrl)
}

@JvmStatic
public fun of(executor: Executor, appId: String, baseUrl: String, json: Json): WooviSDK {
return WooviSDK(executor.asCoroutineDispatcher(), appId, baseUrl, json)
}

@JvmStatic
public fun of(executor: Executor, appId: String, json: Json, baseUrl: String, httpClient: HttpClient): WooviSDK {
return WooviSDK(executor.asCoroutineDispatcher(), appId, baseUrl, json, httpClient)
}
}
}

0 comments on commit 88e5bc3

Please sign in to comment.