πWeb API Service
Custom API
Import the library
implementation(libs.compass.geocoding.web)Create your endpoints
public typealias ForwardEndpoint = HttpApiEndpoint<String, List<Coordinates>>
public typealias ReverseEndpoint = HttpApiEndpoint<Coordinates, List<Place>>public class MyForwardEndpoint : ForwardEndpoint {
override fun url(param: String): String {
return "https://my-api.com/api/geocode?query=$param"
}
override suspend fun mapResponse(response: HttpResponse): List<Coordinates> {
val result = response.body<MyAPIResponse>().resultsOrThrow()
// Map the response to the Coordinates object
return result.toCoordinates()
}
}Create the Geocoder
Customizing the HTTP request
Last updated