|
| 1 | +package com.openmeteo.apix.geocoding |
| 2 | + |
| 3 | +import com.openmeteo.apix.common.http.Endpoint |
| 4 | +import com.openmeteo.apix.common.query.Query |
| 5 | +import com.openmeteo.apix.common.time.TimeZone |
| 6 | +import kotlinx.serialization.SerialName |
| 7 | +import kotlinx.serialization.Serializable |
| 8 | +import java.net.URL |
| 9 | + |
| 10 | +open class GeocodingGet( |
| 11 | + val id: Int, |
| 12 | + context: URL = Companion.context, |
| 13 | +) : Endpoint(context) { |
| 14 | + |
| 15 | + companion object { |
| 16 | + val context = URL("https://geocoding-api.open-meteo.com/v1/get") |
| 17 | + } |
| 18 | + |
| 19 | + @Serializable |
| 20 | + open class Response( |
| 21 | + val id: Int, |
| 22 | + val name: String, // #2 |
| 23 | + private val _3: String? = null, |
| 24 | + val latitude: Float, // #4 |
| 25 | + val longitude: Float, // #5 |
| 26 | + val ranking: Float, // #6 |
| 27 | + val elevation: Float, // #7 |
| 28 | + // https://www.geonames.org/export/codes.html enum? |
| 29 | + @SerialName("feature_code") |
| 30 | + val featureCode: String, // #8 |
| 31 | + // https://en.wikipedia.org/wiki/List_of_FIPS_country_codes enum? |
| 32 | + @SerialName("country_code") |
| 33 | + val countryCode: String, // #9 |
| 34 | + @SerialName("admin1_id") |
| 35 | + val admin1Id: Int? = null, // #10 |
| 36 | + @SerialName("admin2_id") |
| 37 | + val admin2Id: Int? = null, // #11 |
| 38 | + @SerialName("admin3_id") |
| 39 | + val admin3Id: Int? = null, // #12 |
| 40 | + @SerialName("admin4_id") |
| 41 | + val admin4Id: Int? = null, // #13 |
| 42 | + val timezone: TimeZone, // #14 |
| 43 | + val population: Int, // #15 |
| 44 | + private val _16: Int? = null, |
| 45 | + val postcodes: Array<String>, // #17 |
| 46 | + @SerialName("country_id") |
| 47 | + val countryId: Int, |
| 48 | + val country: String, |
| 49 | + val admin1: String? = null, |
| 50 | + val admin2: String? = null, |
| 51 | + val admin3: String? = null, |
| 52 | + val admin4: String? = null, |
| 53 | + ) |
| 54 | + |
| 55 | + operator fun invoke() = invoke<Response>() |
| 56 | + operator fun invoke(query: Query) = invoke<Response>(query) |
| 57 | + |
| 58 | +} |
0 commit comments