Ayodele
06/30/2020, 10:19 AMHamza
06/30/2020, 10:20 AMAyodele
06/30/2020, 10:22 AMRémy
06/30/2020, 10:24 AMAyodele
06/30/2020, 10:27 AMRémy
06/30/2020, 10:32 AMAyodele
06/30/2020, 10:43 AMval client = HttpClient()
val data = <http://client.post|client.post><String>(requestURL) {
header("Authorization", Auth.authKey)
body =
"""{
|"pickup_stop": {"lat": ${start.lat}, "lng": ${start.lng}},
|"destination_stops": [{"lat": ${end.lat}, "lng": ${end.lng}}],
|"payment_method_id": "${paymentMethod}",
|"payment_method_type": "default",
|"timezone": "${timeZone}",
|"preliminary": "true"
|}""".trimMargin()
}
client.close()
return data
get("/BoltRides") {
call.respondText(getBoltRides(location(51.5073509, -0.1277583), location(51.5073509, -0.1277583)))
}
Rémy
06/30/2020, 10:47 AMAyodele
06/30/2020, 10:49 AMRémy
06/30/2020, 10:51 AMAyodele
06/30/2020, 10:52 AMimport io.ktor.client.HttpClient
Rémy
06/30/2020, 10:53 AMarjun
06/30/2020, 10:53 AM<http://httpClient.post|httpClient.post><ClassName>
can u replace the className with a data class ?Rémy
06/30/2020, 10:56 AMAyodele
06/30/2020, 10:57 AMRémy
06/30/2020, 10:58 AMAyodele
06/30/2020, 10:59 AMarjun
06/30/2020, 11:00 AMRémy
06/30/2020, 11:03 AMAyodele
06/30/2020, 11:05 AMRémy
06/30/2020, 11:07 AMAyodele
06/30/2020, 11:09 AMRémy
06/30/2020, 11:11 AMAyodele
06/30/2020, 11:12 AMRémy
06/30/2020, 11:13 AMAyodele
06/30/2020, 11:14 AMRémy
06/30/2020, 11:26 AMarjun
06/30/2020, 11:28 AMRémy
06/30/2020, 11:28 AMAyodele
06/30/2020, 11:31 AMRémy
06/30/2020, 11:35 AMval data = <http://client.post|client.post><UberDataDto>(requestURL) { //...
https://ktor.io/clients/http-client/quick-start/responses.html You have to deserialized the response into an object.
https://ktor.io/clients/http-client/features/json-feature.html <-Ayodele
06/30/2020, 11:42 AMRémy
06/30/2020, 11:53 AMAyodele
06/30/2020, 11:59 AMRémy
06/30/2020, 12:01 PMarjun
06/30/2020, 12:04 PMfun getRides(request: PickupRequest): PickupResponse {
return try {
val response = <http://httpClient.post|httpClient.post><PickupResponse> {
header("Content-Type", ContentType.Application.Json.toString())
url(requestUrl)
body = request
}
response
} catch(e: Exception) {
logger.error(e.message, e)
null
}
}
Ayodele
06/30/2020, 12:12 PMdata class BoltResponse (
val message : String,
val city : String,
val searchCategories : List<Rides>
):Serializable
Rémy
06/30/2020, 1:30 PMAyodele
06/30/2020, 1:32 PMERROR Application - Unhandled: GET - /BoltRides
java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED
get("/BoltRides") {
call.respond(getBoltRides(location(51.5073509, -0.1277583), location(51.5073509, -0.1277583)))
}
Rémy
07/01/2020, 6:51 AMAyodele
07/01/2020, 6:51 AMRémy
07/01/2020, 6:52 AMAyodele
07/01/2020, 6:52 AMRémy
07/01/2020, 6:54 AMAyodele
07/01/2020, 6:59 AMinstall(ContentNegotiation) {
gson {
}
}
Rémy
07/01/2020, 6:59 AMAyodele
07/01/2020, 7:02 AMRémy
07/01/2020, 7:03 AMAyodele
07/01/2020, 7:04 AMERROR Application - Unhandled: GET - /BoltRides
io.ktor.client.call.NoTransformationFoundException: No transformation found: class <http://kotlinx.coroutines.io|kotlinx.coroutines.io>.ByteBufferChannel
Rémy
07/01/2020, 7:06 AMAyodele
07/01/2020, 7:10 AMRémy
07/01/2020, 7:12 AMAyodele
07/01/2020, 7:17 AMRémy
07/01/2020, 8:00 AMAyodele
07/01/2020, 8:01 AMRémy
07/01/2020, 8:04 AMAyodele
07/01/2020, 8:09 AMRémy
07/01/2020, 8:28 AMAyodele
07/01/2020, 1:19 PMfun getRides(request: PickupRequest): PickupResponse {
return try {
val response = <http://httpClient.post|httpClient.post><PickupResponse> {
header("Content-Type", ContentType.Application.Json.toString())
url(requestUrl)
body = request
}
response
} catch(e: Exception) {
logger.error(e.message, e)
null
}
}
Rémy
07/01/2020, 1:23 PMAyodele
07/01/2020, 1:25 PMRémy
07/01/2020, 1:35 PMAyodele
07/01/2020, 1:36 PMarjun
07/01/2020, 2:31 PMAyodele
07/03/2020, 9:30 AMRémy
07/03/2020, 9:32 AMAyodele
07/03/2020, 10:17 AMarjun
07/03/2020, 10:17 AMinstall(CallLogging) {
level = <http://Level.INFO|Level.INFO>
}
Ayodele
07/03/2020, 10:18 AMarjun
07/03/2020, 10:18 AMAyodele
07/03/2020, 12:27 PMRémy
07/03/2020, 2:09 PMAyodele
07/03/2020, 2:11 PMval signUpParameters = call.receive<parameters>()
call.receive<DTO>()
?Rémy
07/03/2020, 2:20 PMAyodele
07/03/2020, 2:24 PMRémy
07/03/2020, 2:27 PMAyodele
07/06/2020, 1:36 PMRémy
07/06/2020, 1:49 PMAyodele
07/06/2020, 1:55 PMoverride suspend fun getResponse(start: Location, end: Location): List<MyDTOResponse>? {
val myResponse = listOf< MyDTOResponse>()
val apiRes = getApiRes(start, end)!!.data.rideCategories
}
Rémy
07/06/2020, 1:59 PMAyodele
07/06/2020, 1:59 PMRémy
07/06/2020, 2:03 PMAyodele
07/06/2020, 2:09 PMRémy
07/06/2020, 2:30 PMAyodele
07/06/2020, 2:36 PMRémy
07/06/2020, 5:38 PMAyodele
07/07/2020, 10:15 AMRémy
07/07/2020, 10:17 AMarjun
07/07/2020, 10:32 AMBearer JwtToken
Ayodele
07/07/2020, 10:33 AMarjun
07/07/2020, 10:33 AMAyodele
07/07/2020, 10:33 AMarjun
07/07/2020, 10:42 AM