class YourRequester(
host: String,
userId: String? = null,
userToken: String? = null,
connectionErrorMessage: String,
enableCertificatesValidation: Boolean = false
): Requester( // extends the Requester to inherit the base methods
host = host,
userId = userId,
userToken = userToken,
connectionErrorMessage = connectionErrorMessage,
enableCertificatesValidation = enableCertificatesValidation
) {
// exec a GET request, this works also for other request methods available
suspend fun sendYourRequest(): JSONObject {
return execGet(
endpoint = "yourEndpoint"
)
}
}
fun main() {
val requester = YourRequester(
host = "host",
userId = "userId",
userToken = "userToken",
connectionErrorMessage = "connectionErrorMessage",
enableCertificatesValidation = true / false
)
// send the request and manage the response scenarios
requester.sendRequest(
request = {
sendYourRequest()
},
onSuccess = {
// manage a successful request
},
onFailure = {
// manage a failed request
},
onConnectionError = {
// manage a connection error
}
)
// send a request with a paginated formatted response
requester.sendPaginatedRequest(
request = {
sendYourRequest()
},
serialiazr = Home.serializer(),
onSuccess = { page ->
// use the page formatted from the response
println(page.data) // list of homes instantiated with the supplier lambda function
},
onFailure = {
// manage a failed request
},
onConnectionError = {
// manage a connection error
}
)
}
If you need help using the library or encounter any problems or bugs, please contact us via the following links:
Thank you for your help!
If you want support project and developer
Crypto | Address | Network |
---|---|---|
3H3jyCzcRmnxroHthuXh22GXXSmizin2yp | Bitcoin | |
0x1b45bc41efeb3ed655b078f95086f25fc83345c4 | Ethereum | |
AtPjUnxYFHw3a6Si9HinQtyPTqsdbfdKX3dJ1xiDjbrL | Solana |
If you want support project and developer with PayPal
Copyright © 2025 Tecknobit