Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use jvm overloads on constrctor for better use on java #20

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}