|
| 1 | +package com.openmeteo.apix.airquality |
| 2 | + |
| 3 | +import com.openmeteo.apix.common.http.Endpoint |
| 4 | +import com.openmeteo.apix.common.query.* |
| 5 | +import com.openmeteo.apix.common.response.ResponseCoordinates |
| 6 | +import com.openmeteo.apix.common.response.ResponseGenerationTimed |
| 7 | +import com.openmeteo.apix.common.response.ResponseHourly |
| 8 | +import com.openmeteo.apix.common.time.Date |
| 9 | +import com.openmeteo.apix.common.time.TimeZone |
| 10 | +import kotlinx.serialization.SerialName |
| 11 | +import kotlinx.serialization.Serializable |
| 12 | +import java.net.URL |
| 13 | + |
| 14 | +class AirQuality( |
| 15 | + override val latitude: Float, |
| 16 | + override val longitude: Float, |
| 17 | + override val hourly: Iterable<HourlyOptions>? = null, |
| 18 | + val domains: Domains? = null, |
| 19 | + override val timeZone: TimeZone? = null, |
| 20 | + override val startDate: Date? = null, |
| 21 | + override val endDate: Date? = null, |
| 22 | + override val pastDays: Int? = null, |
| 23 | + context: URL = Companion.context, |
| 24 | +) : Endpoint(context), |
| 25 | + QueryCoordinates, |
| 26 | + QueryHourly, |
| 27 | + QueryDateRange, |
| 28 | + QueryTimeFormat { |
| 29 | + |
| 30 | + companion object { |
| 31 | + val context = URL("https://air-quality-api.open-meteo.com/v1/air-quality") |
| 32 | + } |
| 33 | + |
| 34 | + @Serializable |
| 35 | + class Response( |
| 36 | + override val latitude: Float, |
| 37 | + override val longitude: Float, |
| 38 | + @SerialName("utc_offset_seconds") |
| 39 | + override val utcOffsetSeconds: Int, |
| 40 | + @SerialName("timezone") |
| 41 | + override val timeZone: TimeZone, |
| 42 | + @SerialName("timezone_abbreviation") |
| 43 | + override val timeZoneAbbreviation: String, |
| 44 | + @SerialName("hourly_units") |
| 45 | + override val hourlyUnits: HourlyUnits? = null, |
| 46 | + @SerialName("hourly") |
| 47 | + override val hourlyValues: HourlyValues? = null, |
| 48 | + @SerialName("generationtime_ms") |
| 49 | + override val generationTimeMs: Float, |
| 50 | + ) : ResponseCoordinates, |
| 51 | + ResponseHourly, |
| 52 | + ResponseGenerationTimed |
| 53 | + |
| 54 | + operator fun invoke(query: Query? = null) = query<Response>(query) |
| 55 | + |
| 56 | +} |
0 commit comments